Hello there,
I have a procedure like below.
private static void ExportHttpExcel(Workbook _workbook, string _filename)
{
_workbook.Save(_filename + GetExtention(FileFormatType.Excel2003), FileFormatType.Excel2003, Aspose.Cells.SaveType.OpenInBrowser, System.Web.HttpContext.Current.Response);
}
I need to add “Content-Length” header to the response due to an exception being thrown in mobile devices. So, I have tried something like below,
//saving workbook to a stream
MemoryStream stream = new MemoryStream();
_workbook.Save(stream, FileFormatType.Excel2003);
stream.Seek(0, SeekOrigin.Begin);
Byte[] readBytes = new Byte[(int)stream.Length];
readBytes = stream.ToArray();
//adding header
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
if (readBytes != null)
response.AddHeader(“Content-Length”, readBytes.Length.ToString());
response.BinaryWrite(readBytes);
//call save
_workbook.Save(_filename + GetExtention(FileFormatType.Excel2003), FileFormatType.Excel2003, Aspose.Cells.SaveType.OpenInBrowser, response);
But it didn’t succeed. Workbook gets pushed to client (browser), but it’s empty.
Any help on this would be appreciated.
Thanks in advance.