Free Support Forum -

Save xlsx to memory stream


I have upgraded my application from Apose.Cells to to make use of xlsx formats. We are having trouble saving 2007 xlsx formats to a memory stream. After saving the workbook to a memory stream we are getting around 5k where is should be 23k. This prevent us from opening the workbook again from the memory stream. Below is code from my test harness (VS2010 .net 3.5 console app). Attached is the Excel workbook we’re testing.

//Load xlsx file
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
Workbook workbook = new Workbook(@“C:\Development\AsposeCellsTest\Model_80.xlsx”, loadOptions);

//Convert to bytes array
MemoryStream memorystream = new MemoryStream();
workbook.Save(memorystream, SaveFormat.Xlsx);

//Get bytes
byte[] bytes = memorystream.ToArray();
//output the bytes
Console.WriteLine(string.Format(“Byte length: {0}”, bytes.Length));

//convert back to workbook
MemoryStream ms2 = new MemoryStream(bytes);
workbook = new Workbook(ms2, loadOptions);


Help pls. I have tried various save and load options. This all works fine for xls (97-2003) files if load options and save options removed.


Please download the latest version:
Aspose.Cells for .NET 7.0.3

I have tested your file with the code below and it is working fine. Please see the output below.


string path = @“F:\Shak-Data-RW\Downloads\Model_80.xlsx”;

//open a template excel file.

Workbook book = new Workbook(path);

MemoryStream ms = new MemoryStream();

book.Save(ms, SaveFormat.Xlsx);

byte[] bytes = ms.ToArray();




Thanks for the prompt reply. Upgraded to 7.0.3 and now works fine.


I have a XSLT transformed HTML data in MemoryStream (in C#). I am trying to convert this to an Excel format before emailing, preferably conversion happens all in memory again without saving to local disk. I can worry about the email attachment part later. Can anyone point me to a sample on how I could do the conversion from HTML to Excel format either through OpenXML or with Office.Interop.Excel.
Plex Lucky Patcher Kodi


I am afraid, these forums are specific to Aspose APIs, so we cannot help you much if you want to use OpenXML or MS Office interop APIs. Please browse respective forums and post your queries there or search internet to accomplish your task.

Should you have any query or issue with Aspose.Cells, feel free to contact us, we will be happy to assist you soon.