I’m using Aspose.Cells for .Net and have to import a custom project that has DateTimeOffset field.
ImportCustomObjects seems to use ‘dateFormatString’ parameter only for DateTime type, but not for DateTimeOffset type.
Code example below.
Can we do something about it?
using System;
using Aspose.Cells;
namespace CellsDateTimeFormat
{
class Program
{
static void Main(string[] args)
{
var foo = new Foo
{
FooDateTime = DateTime.UtcNow,
FooDateTimeOffset = DateTimeOffset.UtcNow
};
var workbook = new Workbook(FileFormatType.Xlsx);
var sheet = workbook.Worksheets.Add("Foo");
sheet.Cells.ImportCustomObjects(new[] {foo}, null, true, 0, 0, 1, true, "yyyy-mm-dd", true);
workbook.Save(@"C:\temp\foo.xlsx");
}
}
class Foo
{
public DateTime FooDateTime { get; set; }
public DateTimeOffset FooDateTimeOffset { get; set; }
}
}
We were able to observe this issue as per your description in the output Excel file. We have logged it in our database for investigation and for a fix if possible. Once, we will have some news for you, we will update you in this topic asap.
This issue has been logged as
CELLSNET-46178 - ImportCustomObjects DateTimeOffset format
This is to inform you that your issue has been fixed. After implementing QA and adding other extensions and fixes, we will soon provide a fixed version.
Thanks for a really quick fix! I’m using .Net Core, so I couldn’t use provided DLL even after adding System.Drawing.Common and System.Text.Encoding.CodePages through NuGet, I got an exception:
Unhandled Exception: System.NotSupportedException: No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
at System.Text.Encoding.GetEncoding(Int32 codepage)
at .(Int32 )
at .(Stream , String )
at .( , String )
at .()
at .()
at .(String , FontStyle , Boolean )
at .(String , Single , String , FontStyle)
at ??.(String , Double , FontStyle )
at Aspose.Cells.WorksheetCollection. ()
at Aspose.Cells.WorksheetCollection..ctor(Workbook )
at Aspose.Cells.Workbook..ctor(FileFormatType fileFormatType)
at CellsDateTimeFormat.Program.Main(String[] args) in
Our app is using .Net Core and NuGet for package management.
Do you have an idea when it might be available there?
Normally we provide fixes for .NET 2.0 and .NET 4.0 framework versions in the forums. We will check if we could provide you .NET Core fix. Alternatively, the fix might be included in the the .NET Core version of the upcoming official release, i.e., Aspose.Cells for .NET v18.6. We only publish official releases onto Nuget/Maven repos.