Free Support Forum -

Postback problem after calling method

Postback problem on the response object.

I have called the
workbook.Save(OriginalFileName, FileFormatType.Default, SaveType.OpenInExcel, Me.Response)

this method. after calling this method my page have to refresh.
but not happening in this scenario.

Could you please help me on this issue?


Well your line of code (involving Aspose.Cells API e.g “workbook.Save(OriginalFileName, FileFormatType.Default, SaveType.OpenInExcel, Me.Response)”) is equal to the following lines of code without involving Aspose.Cells APIs to response the file on the client side:

MemoryStream tempStream = new MemoryStream();
_workbook.Save(tempStream, xSaveOptions);
//You may change it accordingly if you are saving in XLS file format
Response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;
Response.AppendHeader(“Content-Disposition”, “attachment; filename=” + _workbook.FileName);

You may confirm it and use the above lines without involving Aspose.Cells’s APIs to response the file on the client side and you will see the same behavior, so it is the behavior of Response Object.

One thing you may also try is use your Workbook.Save() line at the end of everything where you will not process further or anything. Moreover, please add Response.End() method to your line. For your information any code after either “workbook.Save(OriginalFileName, FileFormatType.Default, SaveType.OpenInExcel, Me.Response)” or the lines in bold (above) won’t be processed, so you have to use them at bottom after all of your code.

If you feel the the lines in bold (above) has different behavior than "workbook.Save(OriginalFileName, FileFormatType.Default, SaveType.OpenInExcel, Me.Response)"
let us know.

Thank you.