We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Question about aspose.excel & datagrids

I have a web application where I have multiple datagrids on the screen at one time.

One datagrid is the result of a SQL query, and the other subsequent datagrids are further filters of that first query. I’d take a business area, and then drill down to a single SKU.

Can ASPose.excel export all of these to an excel workbook?

Currently, we can do it, but there is an error in opening certain spreadsheets (we get a “Could not open file” message) when we get this.

Any help or advice regarding this product and how it might work with multiple datagrids on a single web page would be appreciated.

I’m trying to see if this product would be a workable, reliable alternative to what we have in place now.



Hi, thanks for your consideration.

I am not very clear about your question.

Do you want to export data in these datagrids to excel workbook? If so, Aspose.Excel can fully meet your need. You can export data to data tables and use Cells.ImportDataTable to import them to an excel workbook.

About “Could not open file” message, did you mean when you use Excel.Open method, this message showed? Or when you use MS Excel to open the result the file, the message appeared?

If you meant the first, I guess you open a design file concurrently in several threads or processes. You can avoid it by using file stream api to open it in read only mode, convert to a memory stream and the use Excel.Open(MemoryStream) function to import to Aspose.Excel.

For example,

Excel excel = new Excel();
FileStream fs1 = new FileStream(“d:\formula.xls”, FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);
MemoryStream ms1 = new MemoryStream(data1);


If you meant the second, please email me your problem excel file.

Laurence: Thanks for your reply.

I just emailed you the spreadsheets.


Dear Steve,

I got your file. Thank you.

One of your file cannot be opened in MS Excel, right? I used ultraEdit or notepad to open it and found it’s not an excel file but a html file.

What caused this problem? In my experience, because of security setting and other issues related to MS IE, sometime if you create Excel file in Button_Click event, this problem may occure.

So my suggestion is: if you want to transfer generate Excel file to client, do it in Page_Load event. In the Button_Click event, you can redirect to a new aspx page, then in the Page_Load event, create excel file and send it to client.

And please download new fix at

We are glad to share that Aspose.Cells is introduced which is an advanced version of Aspose.Excel (discontinued now). Aspose.Cells supports all the latest features of MS Excel and is much better in performance and variety of functionalities required by the spreadsheets. You can export the data in the grid to Excel file using this latest product also as shown in the following sample code:

string filename = Session.SessionID + "_out.xls";

string path = (this.Master as Site).GetDataDir() + "\\GridWebBasics\\";

// Saves to the file.
this.GridWeb1.SaveToExcelFile(path + filename);

// Sents the file to browser.
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=" + filename);
Response.WriteFile(path + filename);

For more information on this topic, please refer to the following article:
Export Microsoft Excel File

The latest version of this product can be downloaded from the following link:
Aspose.Cells for .NET (Latest Version)

For testing purposed, a ready to run solution with hundreds of examples is available and can be downloaded here.