如何使用 ExcelPackage 库将单元格的数据类型设置为 Number?
我的问题可能是一个愚蠢的问题,但我自己找不到解决方案。 我遇到了 (ExcelPackage) 的问题。有没有办法设置单元格的Excel数据类型? cell.DataType 属性是字符串,那么允许使用哪些数据类型?基本上我需要为某些列/单元格设置数字格式。
感谢您花时间。
My question is probably a stupid one, but I can't find solution on my own.
I've run into a problem with (ExcelPackage). Is there any way to set cell's Excel data type ? And the cell.DataType property is string so which DataTypes are allowed ? Basically I need to set numeric formatting for certain columns/cells.
Thanks for the time spend.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我需要显示文本等数值,然后在值的末尾添加了一个空字符串(“”)。即:
此外,单元格(
contRow
、contCol
)的格式类似于文本。这对我有用。
我希望这对你有用。
I needed to show numeric values like text, then I added an empty string (" ") at the end of my value. i.e:
Also, the cell (
contRow
,contCol
) was formatted like Text.And this work for me.
I hope this is useful for you.
这是一个论坛帖子,似乎可以回答您的问题:
http://excelpackage.codeplex.com/discussions/50205?ProjectName=excelpackage
看起来 Excel 文档应该检测您在单元格中输入的数据类型,但如果您想覆盖它,上面的链接应该可以帮助您。不幸的是,这样做并不容易。
Here is a forum post that seems to answer your question:
http://excelpackage.codeplex.com/discussions/50205?ProjectName=excelpackage
It looks like the Excel document should detect which type of data you are entering into the cell but if you want to override that, the above link should help you out. Unfortunately, it isn't simple to do so.