OpenExcel method with MemoryStream causes loss of cell formatting

Posted by: darkaraym on 8 September 2017, 2:15 pm EST

  • Posted 8 September 2017, 2:15 pm EST

    Hi,


    I have a report generator that creates reports in FarPoint for Windows Forms v4 using Excel templates. Once the report is completed, it is saved to a MemoryStream using the SaveExcel method, the memorystream is then converted to a ByteArray and stored in a database. To open a report, the ByteArray is converted back to a memorystream and then opened with the OpenExcel method. On the report, cells with a value of 0 are shows as "-". I did this using a GeneralCellType and setting the .FormatString = "$#,##0.00;($#,##0.00);-;".


    Unfortunately once the report is opened, all the cells that should show "-" actually show 0's. Somehow the OpenExcel method removes or forgets the original format string set for the cell. If I save the memory steam to a file everything shows up as intended, but if that memory stream is opened with the OpenExcel method the formatting is gone.


    Please advise.


     

  • Replied 8 September 2017, 2:15 pm EST

    Hello,

    GeneralCellType is considered as custom celltype  by excel if the format doesn't match one of the predefined formats.I am able to replicate the issue as described by you.I have forwarded this to the concerned team, will inform you about any updates soon.

     

    Thanks,

     

     

  • Replied 8 September 2017, 2:15 pm EST

    Thanks for the reply, but it doesn't really make sense in regards to my issue.

    If I save the memory stream to an file of excel format, using a file stream, the formatting looks fine and the 0's look like "-". Because of this it doesn't make sense to me why it's an excel issue, since the formatting fails when I open the memory stream with the FarPoint Spread control. Maybe I'm not understanding what you mean by your post?

     Thanks,

     

  • Replied 8 September 2017, 2:15 pm EST

    Hello,

    The format strings are having some issues while importing/exporting to/from excel.I have reported this issue as a bug to our QA team. It should be fixed in our next maintenance release of Spread.

    Bug Number: 99915116

     

    Thanks,

     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels