Free Support Forum - aspose.com

Losing style when opening document with a MemoryStream?

I used Aspose.Cells 3.7.2.7 to generate an Excel file (no templates). On the first row that we treat as "data", there is an empty cell that is formatted as "Custom m/d/yyyy h:mm", according to Excel. (I used the Aspose style 22 -- datetime -- to do this.)

When I read this file into a MemoryStream and use that stream to open the document using an Excel object, I am finding that the empty datetime cell is now seen by Aspose as a Type "IsNull" with a value null. And so, when I write this document to disk again, the original styling is lost.

What is happening? I don't have a small test case to share, as this is part of a larger application.

Please try this attached fix.

If it still doesn't work, could you post your 2 output files here? Or you can send them to nanjing@aspose.com.

Laurence, this version shows a Type of IsNumeric for the case I summarized above. An empty text field that shows Type "IsNull" in 3.7.2.1. is showing as Type "IsNumeric" in 3.8.1.8.

Also, I should mention that 3.8.1.8 fixes a big problem that I have been having the last couple days with the creation of Excel documents that Excel is "unable to read". It was nice to have this problem go away! :-) The bug that I was seeing had something to do with my use of Excel Comments. Did 3.8.1.8 fix anything with Excel styles, comments, or ranges?

Thanks.

V3.8.1.8 did fix a bug related to style issue.

Could you send me the files if you still find this losing style problem?

I tried following piece of code and all work fine:

Excel excel1 = new Excel();
excel1.Worksheets[0].Cells["A1"].Style.Number = 22;
MemoryStream stream = new MemoryStream();
excel1.Save(stream, FileFormatType.Default);

Excel excel2 = new Excel();
excel2.Open(stream);

Console.WriteLine(excel2.Worksheets[0].Cells["a1"].Type);

excel2.Save("d:\\test\\abc.xls");

Yes. Would you be willing to sign a Non Disclosure Agreement? My company requires one before I can send the Excel files. Could you please provide me an email address to which I can send the agreement for signing?

Laurence, when I tested this last night, I saw IsNumeric as the Type (as mentioned in my prior posting). This morning I coded some test cases using Visual Studio 2005's Unit Test functionality. I have attached the code and the Excel output.

The assertions fail because each test is seeing IsNull as the cell Type. I am not 100% sure that all of the assertions are correctly stated, so maybe there is a misunderstanding on my part.

Thank you.

Please send your NDA to nanjing@aspose.com.

Laurence, did you have a chance to look at the code that I attached in the zip file? Thanks.

Yes. I created a project based on your code because I used vs.net2002.

Please check the comments and code.

Excellent, thank you! I may have had an environmental issue, because the original assertion failures went away with a reboot.

Your comments embedded in the code helped clarify some points for me.