OpenXML - Writing a date into Excel spreadsheet results in unreadable content

前端 未结 7 815
离开以前
离开以前 2020-12-10 11:21

I am using the following code to add a DateTime to a column in my spreadsheet:

var dt = DateTime.Now;
r.AppendChild(new Cell()
    {         


        
相关标签:
7条回答
  • 2020-12-10 12:22

    As an example you can create your own excel file with date column. Then if you open it with Productivity Tool from Open XML SDK you will find there is no DataType specified for the cell with date value. This means that you should omit DataType when creating date cell. In this case it is also required to pass dt.ToOADate().ToString() as a cell value.

    0 讨论(0)
提交回复
热议问题