问题描述
我有一个要在C#中带有openxml组件的excel文件上导出的字符串.我的文本具有'\ u001f'字符,而openxml对此字符有错误.错误文本:十六进制值0x1f,是无效字符".
i have a string that i want to export on excel file with openxml component in C#. My text has '\u001f' character and openxml has error with this character. error text: "hexadecimal value 0x1f, is an invalid character".
我将测试直接复制到excel,没有问题,复制成功.
i copy that test directly to excel and no problem and copy is success.
OpenXml是否具有用于解决此问题或我如何解决此问题的配置.
Does OpenXml have configs for solving this problem or How i can solve this problem.
谢谢.
推荐答案
您需要使用_xHHHH_
格式编写,其中H
代表十六进制字符.在您的特定实例中,您需要将值设置为"_x001F_"
.
You need to write it using the format _xHHHH_
where H
represents a hexadecimal character. In your particular instance you need to set the value to "_x001F_"
.
从单元格值:
ST_Xstring
(取自 ECMA- 376标准)记录为:
这篇关于Excel接受一些字符,而OpenXml有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!