I'm experiencing a problem when I assign a text value that contains a symbol in it to a cell.
For example: Cell(1,1).Value = "¡Oy Vey!";
The resulting cell in the worksheet displays a black diamond with a question mark in it where the extended character symbols should be.
When I look at a hex dump of the raw sharedStrings.xml file generated by ClosedXML, I cannot find the "¡" character or 0xA1 in hex in the file. Other extended characters do not work either.
I tried both Cell.Value and SetValue and with and without assigning the DataType to Text. All things I try have the same result.
I am new to ClosedXML, so perhaps there is a setting to enable it to not translate extended characters in text strings assigned to Cell values. I did not find anything related to this in the documentation.
//AJ
Comments: OK to close this issue. I figured out what my problem was. My application read the text from raw text files. It appears that Microsoft .NET StreamReader and TextReader do not handle non-encoded Text files reliably! It appears that others have this problem and some can work around it by specifying various encodings in StreamReader constructor. However, I could not find one that worked. Maybe it would work if I put encoding prefixes in my files. I do not know. My work-around was to use the equivalent to File.ReadAllBytes(...) instead of ReadAllText(...) and then convert the bytes to characters and append the characters to the text for the worksheet cells. This is not a ClosedXML or OpenXML SDK issue! Thanks for your help and great project!!
For example: Cell(1,1).Value = "¡Oy Vey!";
The resulting cell in the worksheet displays a black diamond with a question mark in it where the extended character symbols should be.
When I look at a hex dump of the raw sharedStrings.xml file generated by ClosedXML, I cannot find the "¡" character or 0xA1 in hex in the file. Other extended characters do not work either.
I tried both Cell.Value and SetValue and with and without assigning the DataType to Text. All things I try have the same result.
I am new to ClosedXML, so perhaps there is a setting to enable it to not translate extended characters in text strings assigned to Cell values. I did not find anything related to this in the documentation.
//AJ
Comments: OK to close this issue. I figured out what my problem was. My application read the text from raw text files. It appears that Microsoft .NET StreamReader and TextReader do not handle non-encoded Text files reliably! It appears that others have this problem and some can work around it by specifying various encodings in StreamReader constructor. However, I could not find one that worked. Maybe it would work if I put encoding prefixes in my files. I do not know. My work-around was to use the equivalent to File.ReadAllBytes(...) instead of ReadAllText(...) and then convert the bytes to characters and append the characters to the text for the worksheet cells. This is not a ClosedXML or OpenXML SDK issue! Thanks for your help and great project!!