Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Unassigned: Datetime is 1 day off [9497]

$
0
0
Greetings,

I'm trying to write a datetime to a cell using ClosedXML. I set the IXLCell DataType to be XLCellValues.DateTime, and the value to be a new DateTime. I also set the number format id to 14 (mm/dd/yyyy)

When I look at the excel sheet, the date displayed is always one day larger than anticipated. When I read the cell value using ClosedXML (in a unit test), the value read from the file matches the value I wrote, but the actual excel sheet does not show the correct value.

Is this a bug in ClosedXML or am I missing something?

Thanks!
-Adam
Comments: I'm using the latest codebase on the `develop` branch on Github and I can't replicate this problem. Here is my code; ```c# public void Create(String filePath) { var workbook = new XLWorkbook(); var worksheet = workbook.Worksheets.Add("Sample Sheet"); worksheet.Cell("A1").Value = "Hello World!"; var cell = worksheet.Cell("A2"); cell.Value = new DateTime(2016, 1, 1); cell.DataType = XLCellValues.DateTime; cell.Style.NumberFormat.NumberFormatId = 14; workbook.SaveAs(filePath); } ``` If I open the generated Excel file, I see "2016-01-01" in the cell. Can you please post a simple example to reproduce your problem?

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>