Softartisans OfficeWriter to generate Excel files. The problem I have is that whenver I assign an empty string (
String.Empty) to a cell, the cell’s value type will turn out to be
Blank instead of
Text, which is what I want. I’ve tried
someCell.ValueType, but it’s a read-only property and I cannot set it to
Any help will be much appreciated!
Note: I work for SoftArtisans
What file format are you using?
In the BIFF file format (.xls), cells assigned to an empty string will be set to a null value when the file is saved, thus causing the ValueType to return blank.
In OOXML (.xlsx) the empty string value is preserved when the file is saved, and the ValueType will return Text for any cells assigned to an empty string.
You can find more information in this KB article: http://blog.softartisans.com/2013/12/30/kb-why-do-some-blank-cells-return-different-values-in-ooxml/
Would using .xlsx files be possible for you?
A possible workaround would be to set the cell value to ‘.
That is a marker for Excel that the cell contains a text value.
Have you tried adding escaped empty quotes to the string?
someCell.Value = "\"\"";