Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 07, 2012 02:24 PM by fiftytrini
Dec 07, 2012 09:56 AM|LINK
In my asp.net application I need my records on excel file so I read some article about using linq to xml for creating excel file.
In these articles use new project for creating this excel file and when run the project , excel file will be created.
I just want download this excel file when I need, so for creating and downloading I have to use all the codes in button click of download of
file or somewhere else?
Dec 07, 2012 10:54 AM|LINK
You can do this with a bit of time using RDLC (Report Definition Language Client), create this using Report Wizard.
RDLC is a language that uses embedded schema information to make the association between items in the report layout and the data that is eventually merged into the layout. The ReportViewer control can use RDLC which requires data source bindings so that
you can pass data to it at run time for generating PDF and Excel reports.
Have a look at my blog post on how you can generate Excel files without having the need to use ReportViewer Control and it generates the Excel file from a dataset using SQL database. https://mashupweb.wordpress.com/2012/02/08/creating-an-online-list-of-users-in-a-database-using-report-wizard/
Hope that helps!
Dec 07, 2012 02:06 PM|LINK
If you are using gridview then you may export it directly to Excel then following are all resources:
If you are using ASPOSE :
If you want to go for reporting, herer is the complete walkthrough using the default reporting controls provided with Visaul Studio:
A related MSDN Article if you can use the webservice:
If you are looking for a very very basic demo for export to Access/Excel/CSV here is my small demo application:
Dec 07, 2012 02:24 PM|LINK
I actually like EPPLus http://epplus.codeplex.com/
and example would be:
protected void ExportQuery_Click( object sender, ImageClickEventArgs e )
var p = new ExcelPackage( );
var sheetName = "MyWorksheet";
ExcelWorksheet ws = p.Workbook.Worksheets.Add( sheetName );
ws.Cells.Style.Font.Size = 11; //Default font size for whole sheet
ws.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet
var ds = GetData( );
if ( ds.Tables.Count > 0 && ds.Tables[ 0 ].Rows.Count > 0 )
ws.Cells[ "A1" ].LoadFromDataTable( ds.Tables[ 0 ], true );
Response.BinaryWrite( p.GetAsByteArray( ) );
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader( "content-disposition", "attachment; filename="+ sheetName +".xlsx" );
There are also numerous samples found on the codeplex project page.