Question about aspose.excel & datagrids


#1

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.

Thanks,

SC


#2

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);

excel.Open(ms1);


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


#3

Laurence: Thanks for your reply.

I just emailed you the spreadsheets.

Steve


#4

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 1.8.5.2 at http://www.aspose.com/Products/Aspose.Excel/Fixes/Aspose.Excel.zip.