Hi,
I am exporting datatable to excel using Aspose and showing the save options on the click on button.
This link button is placed on the user control; I am calling a helper class on the button click to generate the xls. I am using below code in the helper class to get the xls.
WorkSheet1.Cells.ImportDataTable(dt, true, "A4");
System.Web.HttpResponse responseStream = System.Web.HttpContext.Current.Response;
Workbook1.Save(responseStream,name,Aspose.Cells.ContentDisposition.Attachment,new Aspose.Cells.XlsSaveOptions());
responseStream.End();
This code works fine in the separate ASP .net page , but when I call it from the user control the response.end gives error.
Any help on this will be much appreciated.
Hi,
You need to use OoxmlSaveOptions and not XlsSaveOptions. This is the correct code. I have bolden the OoxmlSaveOptions.
[C#]
Workbook wb =new Workbook();
Worksheet sheet = wb.Worksheets[0];
Cell cell = sheet.Cells[“A1”];
cell.PutValue(“Hello!”);
OoxmlSaveOptions xSaveOptions=new OoxmlSaveOptions();
xSaveOptions.SaveFormat=SaveFormat.Xlsx;
System.Web.HttpResponse responseStream = System.Web.HttpContext.Current.Response;
wb.Save(responseStream, “Hello.xlsx”, ContentDisposition.Attachment, xSaveOptions);
responseStream.End();
Hi,
Thanks for the quick reply.
I tried the above code still getting same error. Below is the error message :
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
Hi,
I think, you have to rebuild everything. First do Clean Build and then Rebuild.
Hi,
May be this is because of using wrong DLL?
Are you using the DLL under the directory “net2.0”, you should not use “net3.5_ClientProfile”?
And please check the readme.txt under the directory
“Bin”.
Please see this image for more help.