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

Free Support Forum - aspose.com

Export Data through AsposeCell

Hi

I am using Aspose Cell to export data into data table in .net

the problem is that I am using ExportTodataTable method

and in my excel sheet in 1st row there is a numeric value and in 2nd row there is alphanumeric value

and when I am trying to export into data table its giving me message that value should not be string

I can not use ExportToDataTableString method, because I am having date field also

pleas help me in this scenario, i am having licence version of Aspose cell.


When I am using Cells.ExportDataTableAsString then numeric and alpha numeric problem gets solved but for date field it reads date like 02-03-2011, it should read like 02/03/2011.

I also tried method- .Cells.ExportDataTable(startRow, startColumn, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1, new ExportTableOptions() { CheckMixedValueType = true });

But for date field still same problem.


kindly help me in this senario

Hi Ashish,


Thank you for contacting Aspose support.

I have evaluated your presented scenario while using the sample “Excel file with Date field.xls” and I believe the format of the date values is being changed in the exported DataTable due to localization. Please try the following piece of code on your side as I am able to get correct results with it.

C#

var book = new Workbook(dir + “Excel+file+with+Date+field.xls”);
book.Settings.Region = CountryCode.Default;
var cells = book.Worksheets[“COMPLEX”].Cells;
var table = cells.ExportDataTable(0, 0, cells.MaxDataRow + 1, cells.MaxDataColumn + 1, new ExportTableOptions() { CheckMixedValueType = true });
foreach (DataRow row in table.Rows)
{
Console.WriteLine(row[0].ToString());
}

Hello Babar Raza


Thanks for replying, But the problem in the code, shared by you that after exporting into DataTable it gets exported like Column1, Column2. I want to get export with actual column name of excel sheet.

kindly provide me code , in which I can export data with actual column name including date field and numeric and alphanumeric in a same column.

Thanks !

Hi Ashish,


Please turn on the ExportTableOptions.ExportColumnName property. Please check the bold text from below statement. It will export the original column names to the DataTable.

C#

var table = cells.ExportDataTable(0, 0, cells.MaxDataRow + 1, cells.MaxDataColumn + 1, new ExportTableOptions() { CheckMixedValueType = true, ExportColumnName = true });