Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Unassigned: While Writing to Excel file its throwing an error "'.', hexadecimal value 0x00, is an invalid character." [9421]

$
0
0
Hi All,

While Writing to Excel File using the ClosedXML facing an issue. Above is the error mentioned into caption which I am getting.

Have attached the Excel File which I am trying to Write by passing the DataSet.

Please Reply ASAP.

Thanks,
Samir.
Comments: This also affects us - can reproduce this with the following: ``` byte[] data; using (var stream = new MemoryStream()) { var wb = new XLWorkbook(); wb.AddWorksheet("Sheet1").FirstCell().SetValue("\u0018"); wb.SaveAs(stream); data = stream.ToArray(); } using (var stream = new MemoryStream(data)) { var wb = new XLWorkbook(stream); Assert.AreEqual("\u0018", wb.Worksheets.First().FirstCell().Value); } ``` The above fails on the call to wb.SaveAs, however even if saved correctly the cell value ends up being read as "_x0018_" and the assert will fail. The [ECMA-376 Specification (part 1)](http://www.ecma-international.org/publications/standards/Ecma-376.htm) says the following under the bstr element > Unicode characters that cannot be directly represented in XML as defined by the XML 1.0 specification, shall be escaped using the Unicode numerical character representation escape character format _xHHHH_, where H represents a hexadecimal character in the character's value. [Example: The Unicode character 8 is not permitted in an XML 1.0 document, so it shall be escaped as _x0008_. end example] To store the literal form of an escape sequence, the initial underscore shall itself be escaped (i.e. stored as _x005F_). [Example: The string literal _x0008_ would be stored as _x005F_x0008_. end example] I had a look at how to fix this with the intention of preparing a pull request, but I'm not familiar enough with OpenXml to identify where this encoding method should be applied - at the minimum it needs to be applied to the shared strings, but it looks like this might also apply to other strings too.

Viewing all articles
Browse latest Browse all 1877

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>