使用 CarlosAg.ExcelXmlWriter 的十进制数字
我希望得到如何解决以下问题的答案。
我使用 CarlosAg.ExcelXmlWriter,但在 Excel 中格式化十进制数字时遇到问题。
示例:我有 SQL 字段 TestField, Decimal(15,2)) ,值为 123.45
当我使用 CarlosAg.ExcelXmlWriter 将结果(DataSet 和一些 C# 例程)传输到 Excel 中时,结果始终为 12345 - 就好像 Carlos 无法识别十进制数一样正确。
我尝试在 SQL 端和 Carlos 端格式化数据,结果始终是串联数字 (123.45 -> 12345)
旁注 - 我确实通过将数字转换为 varchar 来“解决”问题,但这对于我们的客户,因为他无法格式化 Excel 中的字符串(例如进行求和等),并且他希望 Excel 字段明确为数字而不是字符串。
我几乎确信对此有一些简单的答案。
谢谢 达米尔
我尝试了卡洛斯与 NumberFormat :
//style2.NumberFormat = "Scientific";
//style2.NumberFormat = "General Number";
//style2.NumberFormat = "###,###.00";
//style2.NumberFormat = "###.###,00";
I would appreciate an answer how to solve the following problem.
I use CarlosAg.ExcelXmlWriter and I have a problem with formatting decimal numbers in Excel.
Example: I have SQL field TestField, Decimal(15,2)) with value 123.45
When i transfer the result (DataSet and some C# routine) into Excel with CarlosAg.ExcelXmlWriter the result is always 12345 - as though Carlos does not recognizes decimal number correctly.
I tried formatting data on SQL side and on Carlos side and result is always concatenated number (123.45 -> 12345)
A a side note - i did sort of "solve" the problem by casting the number into varchar but that is not acceptable for our customer because he can not format strings in the excel (like making SUM etc..) and he wants the Excel field to be explicitly numeric not string.
I am almost shure there is some simple answer for that.
Thanks
Damir
I tried Carlos with NumberFormat :
//style2.NumberFormat = "Scientific";
//style2.NumberFormat = "General Number";
//style2.NumberFormat = "###,###.00";
//style2.NumberFormat = "###.###,00";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
……
...
...