We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ImportDataTable function data type convert issue

Thread ID:





73654 May 14,2008 06:49 AM UTC May 25,2011 09:39 AM UTC ASP.NET Web Forms (Classic) 7
Tags: XlsIO
Asked On May 14, 2008 06:49 AM UTC


I try to use ImportDataTable method to populate the Data Table data to excel sheet and generate excel file. But in my data source has some data like '200-02', '300-11','500-03'. SF automatically convert these data to date time format not keep string format. So do you have any way I can keep these data original format?

I think SF makes '200-02' as '1/1/0200 12:00:00 AM'.

Thank you very much

Yavanaarasi G [Syncfusion]
Replied On May 15, 2008 08:47 AM UTC

Hi Tommy,

Thank you for your interest in Syncfusion products.

As per your requirements I tried converting the value '200-02' to '1/1/0200 12:00:00 AM' same as in Ms excel and the vaue '200-02' is not converted to the datetime format in Engilsh regional setting, because this is an incorrect date format. It is the default behaviour of the excel.

Please refer the vidoe clip:


Please try to check with Ms Excel and let me know if you have any other concerns.


Replied On May 15, 2008 07:35 PM UTC


Thanks for your reply.
I saw your video. but you use excel to do convert.I think it is fine. But I need use SF get database data and generate excel file without MS Excel.
In attachment file: left data is original data from DB. right side data is come from generated excel via SF. (Please assume I do not have MS Excel). you can see the 800-29,800-19 keep original data format. because -29,-19 is more than 12. so it can not convert to MONTH. but other data is converted to incorrect date time format.
So please use SF to create excel file with these kind of data. maybe you can reproduce my issue.

Thanks again



Yavanaarasi G [Syncfusion]
Replied On May 17, 2008 07:15 AM UTC

Hi Tommy,

I am not able to reproduce the issue that you mentioned here. I have created a simple sample and import the datatable to excel with the data as you have mentioned. Here the data is not converted to date time format. It is in the string format. Please refer the sample in the below link:


Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution?


Replied On May 27, 2008 04:52 PM UTC


Thanks for your sample file.
I think I miss this parameter "preserveType" in the mySheet.ImportDataTable(GetTable(),true,1,1,bool preserveType);Now it works well.

Thank you very much.


Yavanaarasi G [Syncfusion]
Replied On May 28, 2008 08:48 AM UTC

Hi Tommy,

Thank you for your update.

Glad to hear that the problem could be solved.

Please let me know if you have any other concerns.


Sandhya Doddi
Replied On July 13, 2010 08:54 PM UTC

I am trying to import a data table to spread sheet which has a column start and end date. But, I am treating them as string values, the value in my data table shows 3/2/2010, but when it is imported on to spread sheet I see 03/02/2010. My datatable has all the column data types as string.

I have used preserveTypes= true,
sheet.ImportDataTable(dtTable, true, 3, 1, true); that didn't help

Can you please guide me in the right direction so, that I can resolve this problem..

Replied On May 25, 2011 09:39 AM UTC

Hi all Please give your ideas on the following question.

1)I have a data table with some columns say customer_id,Customer_name , Address, balance, loan. how to export only some columns in it to excel say only customer_id,Customer_name , Address, balance.

2)If i have two columns say discription and description_detail.How can i combine both the column and show as a single column in the excel if both the columns have data.

Thanks in advance,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon