Question

I need to export timetable from the database to Excel file on-the-fly on ASP.NET WebForms site.
When user clicks "Export to Excel" link, he gets this file generated. I don't want to generate it explicitly and store on a server to provide download-on-a-demand, because then it'll be hundreds of files. I have all the data to do it, so the question is only about what approach to use.
One of my colleagues done this before in a very ugly way - he created separate web page, pushed all the data needed for export to a StringBuilder instance, then wrote all its contents to Response object, and added an appropriate headers to make it look like Excel file. All this work is 300 loc done in Page_Load event handler.
And our server hasn't Excel installed - yet another tricky thing.
Any suggestions? Thanks in advance

No correct solution

OTHER TIPS

This is effectively a duplicate - you need the answer here:

Building Excel Files with C#

That tells you how to create a .xslx file. Whether you keep it for any time once generated and downloaded is a different matter.

SpreadsheetGear for .NET makes this easy to do.

You can see a number of live samples on our Excel Reporting Samples page here and download the free trial here.

Disclaimer: I own SpreadsheetGear LLC

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top