Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Export data to Excel

Reply
Thread Tools

Export data to Excel

 
 
Grey
Guest
Posts: n/a
 
      01-09-2004
is it possible to export excel directly from ASP.NET to Excel? My requirement is that the data on the datagrid is exported to MS Excel file after user clicks the button on the web page. Excel will be open automatically with imported data. If so, is need to add any additional controls or tools?


Million Thanks..

Eric Yum

 
Reply With Quote
 
 
 
 
BruceJohnson
Guest
Posts: n/a
 
      01-09-2004
Check out the following link:

http://www.tagconsulting.com/Show.asp?Id=1010&S=2

It describes how to set the response headers so that a page can be
automatically processed by Excel. Even though the example is in ASP,
translating it to ASP.NET shouldn't be a challenge.

HTH

Bruce Johnson
http://www.ObjectSharp.com/Bruce

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
Reply With Quote
 
 
 
 
Glenn
Guest
Posts: n/a
 
      01-09-2004
There is a third party tool called ExcelWriter that allows
you to easily create spreadsheets without having Excel
installed on the server. It is very quick and easy to
use... check it out at www.softartisans.com.

It is a COM component but they have class wrappers that
allow you to use it in .NET. The latest version lets you
create spreadsheet content by binding a DataSet (previous
versions only support ADO recordset binding - you have to
create the rows manually).

Cheers,

Glenn.

>-----Original Message-----
>is it possible to export excel directly from ASP.NET to

Excel? My requirement is that the data on the datagrid is
exported to MS Excel file after user clicks the button on
the web page. Excel will be open automatically with
imported data. If so, is need to add any additional
controls or tools?
>
>
>Million Thanks..
>
>Eric Yum
>

 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      01-09-2004
This article gives a number of possible solutions:
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

And here's another technique that might work for you:
http://support.microsoft.com/default...;EN-US;Q306572

And these 3rd party components are of high quality:
http://www.aspose.com/Products/Aspose.Excel/
http://officewriter.softartisans.com/

I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net



"Grey" <> wrote in message news:%...
is it possible to export excel directly from ASP.NET to Excel? My requirement is that the data on the datagrid is exported to MS Excel file after user clicks the button on the web page. Excel will be open automatically with imported data. If so, is need to add any additional controls or tools?


Million Thanks..

Eric Yum
 
Reply With Quote
 
=?Utf-8?B?cGRtMg==?=
Guest
Posts: n/a
 
      04-02-2004
I have looked high and low for a simple solution to export a DataGrid to MS Excel in ASP.NET. I weeded out this code from Microsoft support. Simply create a button called ExportToExcel and place this code in the Click event and rename DataGrid1 in the code to whatever your datagrid is called. When you run the page and click your button you will be prompted to open excel in ie or save whatever data is in your datagrid to an excel file of your choice. I hope this saves beginner programmers such as myself some time and effort

sub ExportToExcel_Click(sender As Object, e As EventArgs

' Set the content type to Excel
Response.ContentType = "application/vnd.ms-excel
' Remove the charset from the Content-Type header
Response.Charset = "
' Turn off the view state
Me.EnableViewState = Fals

Dim tw As New System.IO.StringWriter(
Dim hw As New System.Web.UI.HtmlTextWriter(tw
' Get the HTML for the control
DataGrid1.RenderControl(hw
' Write the HTML back to the browser
Response.Write(tw.ToString()
' End the response
Response.End(
End I

End Su

 
Reply With Quote
 
=?Utf-8?B?cGRtMg==?=
Guest
Posts: n/a
 
      04-02-2004
I have looked high and low for a simple solution to export a DataGrid to MS Excel in ASP.NET. I weeded out this code from Microsoft support. Simply create a button called ExportToExcel and place this code in the Click event and rename DataGrid1 in the code to whatever your datagrid is called. When you run the page and click your button you will be prompted to open excel in ie or save whatever data is in your datagrid to an excel file of your choice. I hope this saves beginner programmers such as myself some time and effort

sub ExportToExcel_Click(sender As Object, e As EventArgs

' Set the content type to Excel
Response.ContentType = "application/vnd.ms-excel
' Remove the charset from the Content-Type header
Response.Charset = "
' Turn off the view state
Me.EnableViewState = Fals

Dim tw As New System.IO.StringWriter(
Dim hw As New System.Web.UI.HtmlTextWriter(tw
' Get the HTML for the control
DataGrid1.RenderControl(hw
' Write the HTML back to the browser
Response.Write(tw.ToString()
' End the response
Response.End(
End I

End Su

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to Excel (Default File Type - Excel) =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?= ASP .Net 15 05-21-2009 12:01 PM
Export to excel in asp.net using excel template Grey ASP .Net 4 10-17-2007 08:08 AM
using Microsoft Excel image for Export to Excel button =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 0 12-09-2005 08:58 PM
Export data from grid to Excel Deva ASP .Net 1 01-13-2004 07:54 AM
export data from an asp .net web form to Excel Joy ASP .Net 2 08-22-2003 08:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57