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. Image for the cookie policy date
close icon

ImportDataTable function data type convert issue

Hi,

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




7 Replies

YG Yavanaarasi G Syncfusion Team 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:

http://websamples.syncfusion.com/samples/F73654/Excel.zip

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

Regards,
G.Yavana




TO Tommy May 15, 2008 07:35 PM UTC

Hi,

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

Tommy




Original_Data.zip


YG Yavanaarasi G Syncfusion Team 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:

http://websamples.syncfusion.com/samples/XlsIO.Web/6.2.0.40/73654/73654.Zip


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?

Regards,
G.Yavana






TO Tommy May 27, 2008 04:52 PM UTC

Hi,

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.


Tommy




YG Yavanaarasi G Syncfusion Team 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.

Regards,
G.Yavana



SD Sandhya Doddi 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..


M. m.vishwanathan 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,
Vishy


Loader.
Live Chat Icon For mobile
Up arrow icon