The Cells.ImportCustomObjects method works with objects that have DateTime properties, but DateOnly properties are brought over as text.
Using the code below:
FirstDate is a date value in the resulting workbook.
SecondDate is text in the resulting workbook, even though it should be a date value.
List<DateTest> customObjects = new();
customObjects.Add(new DateTest { FirstDate = new DateTime(2024, 6, 3), SecondDate = new DateOnly(2024, 6, 4) });
var wb = new Workbook();
wb.Worksheets[0].Cells.ImportCustomObjects(customObjects, 0, 0, new ImportTableOptions { IsFieldNameShown = true, DateFormat = "mm/dd/yyyy" });
wb.Save("test.xlsx");
class DateTest
{
public DateTime FirstDate { get; set; }
public DateOnly SecondDate { get; set; }
}
@sngcdev
By using the sample code to test on the latest version v24.5, we can reproduce the issue. Discovered that DateOnly properties are broken over as text.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-55976
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@sngcdev
We are pleased to inform you that your issue (“CELLSNET-55976”) has been resolved. The fix will be included in an upcoming release (Aspose.Cells v24.7) . You will be notified when the next version is released.
The issues you have found earlier (filed as CELLSNET-55976) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi