We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Date values when exported to a data table become a long ugly string

Hello,

When I am reading in an excel file and then exporting the file as a data table it is turning a date string into a long ugly string. How can I get the date format in a clean format ?

This is an example of the output date format that I receive

/Date(1392123600000)/


This message was posted using Banckle Live Chat 2 Forum
Hi Patrick,

Thank you for contacting Aspose support.

The presented problem is probably caused due to the reason that the mentioned column isn't specified as Date in the source spreadsheet. You can workaround this situation by defining the DataTable based on the desired DataType for each column in the spreadsheet. Please check the following piece of code snippet for your reference.

C#
ExportTableOptions options = new ExportTableOptions();
options.DataTable = new DataTable(); options.DataTable.Columns.Add("Column1", typeof(DateTime)); options.DataTable.Columns.Add("Column2", typeof(string)); options.DataTable.Columns.Add("Column2", typeof(double)); options.DataTable.Columns.Add("Column2", typeof(int)); // You have to declare the complete column structure

DataTable table = workbook.Worksheets[0].Cells.ExportDataTable(0, 0, 5, 5, options);

Hopefully the above approach will resolve the problem of date string represented in numeric format. In case the problem persists, please provide us the problematic sample spreadsheet for our review & testing.