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

Created Unassigned: VTFileTime custom properties incorrectly set as unspecified kind at load [9462]

$
0
0
XLWorkbook_Load.cs, LoadSpreadsheetDocument, the section which loads date time values, uses:

DateTime.ParseExact(m.VTFileTime.Text, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture);

Which sets the DateTimeKind to Unspecified, which if saved again, is converted to UTC, changing the file time property each time the document is loaded and saved. This line should be:

DateTime.ParseExact(m.VTFileTime.Text, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);

to set the Kind to UTC.

Also, the unit test example class WorkbookProperties is incorrectly coded and does not match the example file, it should be setting the date value to

new DateTime(2011, 1, 2, 0, 0, 0, DateTimeKind.Utc)

, not:

new DateTime(2011, 1, 1, 17, 0, 0, DateTimeKind.Utc)

Viewing all articles
Browse latest Browse all 1877

Trending Articles