Hi,
I have three datagrid control on my aspx page and one export to excel
button, i want to export all the 3 datagrids contents in one excel file. how
can i achive that?
--
Thanks
Hitesh 4 6185
You could try something of this kind.
DataGridItemCol lection dgItem1 = DataGrid1.Items ;
DataGridItemCol lection dgItem2 = DataGrid2.Items ;
DataGridItemCol lection dgItem3 = DataGrid3.Items ;
System.IO.FileS tream f = new
System.IO.FileS tream("c:\\Text 1.csv",System.I O.FileMode.Open OrCreate,System .
IO.FileAccess.W rite);
System.IO.Strea mWriter sr = new System.IO.Strea mWriter(f);
string strOutput = "";
strOutput = "";
strOutput = strOutput + DataGrid1.Colum ns[1].HeaderText + ",";
sr.WriteLine(st rOutput);
foreach(DataGri dItem dgi1 in dgItem1)
{
strOutput = "";
strOutput = dgi1.Cells[0].Text + ",";
strOutput = strOutput + dgi1.Cells[1].Text ;
sr.WriteLine(st rOutput);
}
foreach(DataGri dItem dgi2 in dgItem2)
{
strOutput = "";
strOutput = dgi2.Cells[0].Text + ",";
strOutput = strOutput + dgi2.Cells[1].Text ;
sr.WriteLine(st rOutput);
}
foreach(DataGri dItem dgi3 in dgItem3)
{
strOutput = "";
strOutput = dgi3.Cells[0].Text + ",";
strOutput = strOutput + dg3i.Cells[1].Text ;
sr.WriteLine(st rOutput);
}
sr.Close();
Regards,
--
Tarkeshwar
..Net Programmer
Fifth Generation Technologies
"Hitesh" <Hi****@discuss ions.microsoft. com> wrote in message
news:84******** *************** ***********@mic rosoft.com... Hi, I have three datagrid control on my aspx page and one export to excel button, i want to export all the 3 datagrids contents in one excel file.
how can i achive that? -- Thanks Hitesh
Hi Tarakeshwar,
Thanks for your suggestion yaa that will do the job of exporting multiple
datagrid's contents on one excel sheet, but the problem is all the data will
come on one single sheet only (data will be appended one below another), i
want the data for each datagrid to be on seprate sheets in the same excel
file and secondlly i am using an ASP.NET application.
So, can you help me out further, in achiving that.
Thanks and Regards
Hitesh Jain
"Tarakeshwa r L" wrote: You could try something of this kind.
DataGridItemCol lection dgItem1 = DataGrid1.Items ; DataGridItemCol lection dgItem2 = DataGrid2.Items ; DataGridItemCol lection dgItem3 = DataGrid3.Items ;
System.IO.FileS tream f = new System.IO.FileS tream("c:\\Text 1.csv",System.I O.FileMode.Open OrCreate,System . IO.FileAccess.W rite); System.IO.Strea mWriter sr = new System.IO.Strea mWriter(f); string strOutput = "";
strOutput = ""; strOutput = strOutput + DataGrid1.Colum ns[1].HeaderText + ","; sr.WriteLine(st rOutput);
foreach(DataGri dItem dgi1 in dgItem1) { strOutput = ""; strOutput = dgi1.Cells[0].Text + ","; strOutput = strOutput + dgi1.Cells[1].Text ; sr.WriteLine(st rOutput); }
foreach(DataGri dItem dgi2 in dgItem2) { strOutput = ""; strOutput = dgi2.Cells[0].Text + ","; strOutput = strOutput + dgi2.Cells[1].Text ; sr.WriteLine(st rOutput); }
foreach(DataGri dItem dgi3 in dgItem3) { strOutput = ""; strOutput = dgi3.Cells[0].Text + ","; strOutput = strOutput + dg3i.Cells[1].Text ; sr.WriteLine(st rOutput); }
sr.Close();
Regards, -- Tarkeshwar ..Net Programmer Fifth Generation Technologies
"Hitesh" <Hi****@discuss ions.microsoft. com> wrote in message news:84******** *************** ***********@mic rosoft.com... Hi, I have three datagrid control on my aspx page and one export to excel button, i want to export all the 3 datagrids contents in one excel file. how can i achive that? -- Thanks Hitesh
In that case you have to create an object for an excel application, create
an object for every sheet, and then add data to each sheet. You could go
thru msdn, which has examples on creating excel sheets in dotnet. http://msdn.microsoft.com/office/und...l/excelobj.asp
Use this link to create workbook object and try using it from there.
--
Tarkeshwar
..Net Programmer
Fifth Generation Technologies
"Hitesh" <Hi****@discuss ions.microsoft. com> wrote in message
news:D7******** *************** ***********@mic rosoft.com... Hi Tarakeshwar, Thanks for your suggestion yaa that will do the job of exporting multiple datagrid's contents on one excel sheet, but the problem is all the data
will come on one single sheet only (data will be appended one below another), i want the data for each datagrid to be on seprate sheets in the same excel file and secondlly i am using an ASP.NET application. So, can you help me out further, in achiving that.
Thanks and Regards Hitesh Jain
"Tarakeshwa r L" wrote:
You could try something of this kind.
DataGridItemCol lection dgItem1 = DataGrid1.Items ; DataGridItemCol lection dgItem2 = DataGrid2.Items ; DataGridItemCol lection dgItem3 = DataGrid3.Items ;
System.IO.FileS tream f = new
System.IO.FileS tream("c:\\Text 1.csv",System.I O.FileMode.Open OrCreate,System . IO.FileAccess.W rite); System.IO.Strea mWriter sr = new System.IO.Strea mWriter(f); string strOutput = "";
strOutput = ""; strOutput = strOutput + DataGrid1.Colum ns[1].HeaderText + ","; sr.WriteLine(st rOutput);
foreach(DataGri dItem dgi1 in dgItem1) { strOutput = ""; strOutput = dgi1.Cells[0].Text + ","; strOutput = strOutput + dgi1.Cells[1].Text ; sr.WriteLine(st rOutput); }
foreach(DataGri dItem dgi2 in dgItem2) { strOutput = ""; strOutput = dgi2.Cells[0].Text + ","; strOutput = strOutput + dgi2.Cells[1].Text ; sr.WriteLine(st rOutput); }
foreach(DataGri dItem dgi3 in dgItem3) { strOutput = ""; strOutput = dgi3.Cells[0].Text + ","; strOutput = strOutput + dg3i.Cells[1].Text ; sr.WriteLine(st rOutput); }
sr.Close();
Regards, -- Tarkeshwar ..Net Programmer Fifth Generation Technologies
"Hitesh" <Hi****@discuss ions.microsoft. com> wrote in message news:84******** *************** ***********@mic rosoft.com... Hi, I have three datagrid control on my aspx page and one export to excel button, i want to export all the 3 datagrids contents in one excel
file. how can i achive that? -- Thanks Hitesh
Hi Tarakeshwar,
Thank you very much for pointing to the right thing, finally what you had
suggested given me enough to do the task. One question that i want to ask is,
in this case we definetely needs the Microsoft Excel on the server Is there
anyway where we do not required the Microsoft Excel on the server and still
we can achive the task?
Thanks & Regards
Hitesh Jain
"Tarakeshwa r L" wrote: In that case you have to create an object for an excel application, create an object for every sheet, and then add data to each sheet. You could go thru msdn, which has examples on creating excel sheets in dotnet.
http://msdn.microsoft.com/office/und...l/excelobj.asp
Use this link to create workbook object and try using it from there.
-- Tarkeshwar ..Net Programmer Fifth Generation Technologies
"Hitesh" <Hi****@discuss ions.microsoft. com> wrote in message news:D7******** *************** ***********@mic rosoft.com... Hi Tarakeshwar, Thanks for your suggestion yaa that will do the job of exporting multiple datagrid's contents on one excel sheet, but the problem is all the data will come on one single sheet only (data will be appended one below another), i want the data for each datagrid to be on seprate sheets in the same excel file and secondlly i am using an ASP.NET application. So, can you help me out further, in achiving that.
Thanks and Regards Hitesh Jain
"Tarakeshwa r L" wrote:
You could try something of this kind.
DataGridItemCol lection dgItem1 = DataGrid1.Items ; DataGridItemCol lection dgItem2 = DataGrid2.Items ; DataGridItemCol lection dgItem3 = DataGrid3.Items ;
System.IO.FileS tream f = new System.IO.FileS tream("c:\\Text 1.csv",System.I O.FileMode.Open OrCreate,System . IO.FileAccess.W rite); System.IO.Strea mWriter sr = new System.IO.Strea mWriter(f); string strOutput = "";
strOutput = ""; strOutput = strOutput + DataGrid1.Colum ns[1].HeaderText + ","; sr.WriteLine(st rOutput);
foreach(DataGri dItem dgi1 in dgItem1) { strOutput = ""; strOutput = dgi1.Cells[0].Text + ","; strOutput = strOutput + dgi1.Cells[1].Text ; sr.WriteLine(st rOutput); }
foreach(DataGri dItem dgi2 in dgItem2) { strOutput = ""; strOutput = dgi2.Cells[0].Text + ","; strOutput = strOutput + dgi2.Cells[1].Text ; sr.WriteLine(st rOutput); }
foreach(DataGri dItem dgi3 in dgItem3) { strOutput = ""; strOutput = dgi3.Cells[0].Text + ","; strOutput = strOutput + dg3i.Cells[1].Text ; sr.WriteLine(st rOutput); }
sr.Close();
Regards, -- Tarkeshwar ..Net Programmer Fifth Generation Technologies
"Hitesh" <Hi****@discuss ions.microsoft. com> wrote in message news:84******** *************** ***********@mic rosoft.com... > Hi, > I have three datagrid control on my aspx page and one export to excel > button, i want to export all the 3 datagrids contents in one excel file. how > can i achive that? > -- > Thanks > Hitesh This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin |
last post by:
I'm using a bit of code I wrote awhile ago to render datagrids to Excel
spreadsheets through the browser. The code works great until the number
of rows in the datagrid gets large (approx. 5000), then the user is
prompted for their login credentials a few times then finally they get
a 401 error. The solution for other people who have encountered this
problem is to upgrade their Office 2K to a more current SP. In my case
all my users are...
|
by: Conrad F |
last post by:
Hello All,
I know how to import a specific named excel sheet into a datagrid
using ADO.NET by setting up a JET connection and then SELECTing data
from the sheet. However, for a real world application, I would
typically not know what the names of the sheets are going to be before
I open the Excel file.
I am wondering if there is a SELECT statement that would get me the
list of sheet names so that I can place them in a combobox and
|
by: mark |
last post by:
(windows app not web)
I have a procedure to populate a given datagrid (Datagrid1) with a dataset
from an indexed data connection. It works:
Globals: Dim FileName1 As String
Dim DS As System.Data.DataSet
Dim OleDbConnection1(20) As System.Data.OleDb.OleDbConnection
Dim OleDbDataAdapter1(20) As System.Data.OleDb.OleDbDataAdapter
Dim CurrentIndex As Integer = 0
|
by: Kevin Humphreys |
last post by:
Hi There,
I am trying to export a recordset to an excel file using the Content Type
below in the header.
Response.ContentType = "application/vnd.ms-excel"
Which works fine however the problem is that when I have a number in a
column with a leading zero the zero gets dropped.
|
by: devolper |
last post by:
I am devolping a web application which which .net reports to a excel work book .each report in one excel sheet.i am using the following code..........
Dim objDestinationExcel As New Excel.Application
Dim objDestinationWBS As Excel.Workbooks
objDestinationWBS = objDestinationExcel.Workbooks
objDestinationWBS.Open(TemplateFileName)
Dim objDestinationWB As Excel.Workbook
objDestinationWB...
| |
by: Hiranmoy |
last post by:
I have created four query that gives four different output. Then I have created four macros from that query to export that reports to excel and it is giving four different excel file. Is it possible to make a macro that will give four excel output on four different sheets of a single excel file ?
|
by: TARHEELS721 |
last post by:
I am trying to send the results of a query that runs when I click a button on my form that is based on a parameter query. The code runs without any errors but nothing is exported into my excel spreadsheet and I can't figure out why does anyone see where I went wrong in my code. I am currently using DAO Recordset. Here is what my code looks like:
Private Sub btnJE_Click() 'Exports qryJE results into excel
On Error GoTo Err_btnJE_Click
...
|
by: atlbearcat |
last post by:
Here's one that's been bugging me for about a week now...
I have a form that allows users to filter records, simple enough. But I want to give them the option to export the filtered records to Excel. I don't want to use the docmd.outputTo due to it won't filter the records, it puts all of the records in the file. I've looked around and found some code (actually that I'm already using), but the problem is that it outputs EVERYTHING on the...
|
by: Tempalli |
last post by:
I am exporting the data from ms access to excel where the error displays as Run-time error -2147467259(800004005)
Method 'Copyfromrecordset' of object 'Range' faild.
Ws.Range("A2").CopyFromRecordset rs
One of my Field Name, DATATYPE is set to MEMO
I am testing with DATATYPE As TEXT and the Characters within 255 then the report get's downloaded to Excel, if the DATATYPE is set to MEMO and the characters are more than 255 error...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |