We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue saving xlsx data structure to MemoryStream

it seems like saving a Xlsx file to a memory stream results in a corrupt file. Microsoft Excel 2010
complains that the resultning file is broken, but doesn’t seem to find any real issue with it. Please
se the attached sample code on how to re-create the issue. Other file formats doesn’t seem to
be affacted, but I haven’t tested them all… xl_example_02.zip (497 Bytes)

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSCPP-236 – Saving a Xlsx file to a memory stream results in a corrupt file

We have analyzed your code and found the error in the code. You may please modify code as follows to write actual length and share the feedback.

file.write((const char*)buffer->ArrayPoint(), buffer->GetLength());//INCORRECT
file.write((const char*)buffer->ArrayPoint(), memStream->GetLength());//CORRECT

You modifications works just fine, thank you! I presume you use some kind of
pre-allocation strategy in the internal buffer that makes it differ from the actual
length of the data?

Yes, you are right. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.