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/
masoud-s
Member
81 Points
196 Posts
When I have to create excel file in asp.net
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?
guinnesslee
Participant
1050 Points
197 Posts
Re: When I have to create excel file in asp.net
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!
twitter
www.mashupweb.wordpress.com
aarsh
Participant
1543 Points
428 Posts
Re: When I have to create excel file in asp.net
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:
http://www.codeproject.com/Tips/190144/Export-Database-to-Excel-PDF-HTML-RTF-XML-etc-for
http://www.aspsnippets.com/Articles/Export-ASPNet-Web-Page-with-images-to-PDF-using-ITextsharp.aspx Or http://www.aspsnippets.com/Articles/Export-DataSet-or-DataTable-to-Word-Excel-PDF-and-CSV-Formats.aspx
http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html
If you are using ASPOSE : http://www.aspose.com/community/forums/post/139794/convert-data-from-a-datatable-to-pdf.aspx
If you want to go for reporting, herer is the complete walkthrough using the default reporting controls provided with Visaul Studio:
http://www.codeproject.com/Articles/15597/Using-the-ASP-NET-2-0-ReportViewer-in-Local-Mode
A related MSDN Article if you can use the webservice:
http://msdn.microsoft.com/en-us/magazine/cc163837.aspx
If you are looking for a very very basic demo for export to Access/Excel/CSV here is my small demo application:
http://sdrv.ms/Vo6TFG
fiftytrini
Member
117 Points
18 Posts
Re: When I have to create excel file in asp.net
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.
sr. application systems analyst
please "Mark As Answer" if this post answers your question or addresses your issue.