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

前端 未结 7 829
离开以前
离开以前 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:02

    try dt.ToOADate().ToString().Replace (",", ".") instead of dt.ToOADate().ToString()

    For some working code samples see http://www.codeproject.com/KB/office/ExcelOpenXMLSDK.aspx

    EDIT:

    please change your code to this:

    dt.ToOADate().ToString(new CultureInfo("en-US"));
    

提交回复
热议问题