ImportDataTable import error - Unexpected token.Unexpected token type: Identifier, string value:

Hi,

I am trying to import data from database into Excel using ImportDataTable. Few records have some data similar to following causing unExcepted exception

Sample data in table

Contact# Price Desc
T-7916 .1457 Basis + .4389 Board
T-7939 .1647 Basis + .4519 Board
T-7941  .4461 Board + .1274 Basis
T-7946
T-7951 .8403 per lbs del
T-7959 .8675 per lbs del
T-7980 .1431 Basis + .4514 Board
T-7980 .1431 Basis + .4514 Board
T-7981 .1485 Basis + .4514 Board


As you can see, highlighted rows causing the issue. 

How can I import this data as normal text. I tried to set the number format as Text ("@"), disabledFormulaCalculations etc. nothing worked out. Please suggest how to solve this.

Thank you!

Sunil


4 Replies

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 24, 2022 01:41 PM UTC

Hi Sunil, 

Greetings from Syncfusion. 

We are able to reproduce the Unhandled Exception issue while using ImportDataTable at our end and validating it currently. We will share the validation details on January 27th,2022. 

Regards, 
Ramya. 



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 27, 2022 04:18 PM UTC

Hi Sunil, 

We appreciate your patience. 

While Importing the Data table with the highlighted values are working proper. 

We have reproduced the issue only if we use the “Equal to =” symbol before the values, like below. 

Contact# 
Price Desc 
T-7916 
=.1457 Basis + .4389 Board 

If we give like this, the values are considered as the formula, so it throws the exception. To avoid such issue, you need to set the preserved type value to true. If your values are entered with equal sign (“=”), then kindly use the following code snippet to avoid the exception and let us know if it helps. 

Code Snippet: 
worksheet.ImportDataTable(table, true, 1, 1, true); 


Please refer the following kb for preserve data type set in import data table 

Regards, 
Ramya. 



SU Sunil January 28, 2022 05:02 AM UTC

thanks a lot Ramya! that solution worked!!


Thanks,

Sunil



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 31, 2022 12:56 PM UTC

Hi Sunil, 

We are glad that the provided suggestion helped you. Kindly let us know if you need any further assistance. 

Regards, 
Ramya. 


Loader.
Up arrow icon