使用Open XML向Excel添加日期 [英] Adding Date to Excel using Open XML
本文介绍了使用Open XML向Excel添加日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Open XML将Date值插入excel文件.
I would like to insert Date value to excel file using Open XML.
这是我的代码示例.
cell.CellValue = new CellValue(value.ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.Date);
推荐答案
显然,应该省略DataType!
Apparently, the DataType should be omitted!
我有相同的概率,但是只需设置CellValue就可以了!
I was having the same prob, but just setting the CellValue did the trick!
cell.CellValue = new CellValue(value.ToOADate().ToString())
这篇关于使用Open XML向Excel添加日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文