Click here to Skip to main content
15,881,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When getting data from excelsheet to C# dataset :
I am using

C#
connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 8.0;IMEX=1;HDR=NO;\"";


and

C#
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties=\"Excel 8.0;IMEX=1;HDR=NO;\"";


I have to make general formatting for column(s), so that able to update Database as integer column.

Ex

12,220 --> 12220
15,445 --> 15445
55,881 --> 55881

Number(-1,234) --> Number(General)

I don't want fix(s) by row (by) row operation

it will degrade performance
Posted
Updated 11-Oct-12 0:19am
v2
Comments
Jim Jos 11-Oct-12 20:53pm    
Have you tried string.Format ?
vino2012 12-Oct-12 4:03am    
If I am doing string.format, I have to go [row][column]
Expecting performance, Excel sheet contains around 6 Lakhs records

1 solution

Formatting has nothing to do with importing data from MS Excel sheet.

Read this: Import Excel File to DataSet[^]

If you use: Provider=Microsoft.ACE.OLEDB.12.0 driver, the Extended Properties can NOT use Excel 8.0 value.

More about it, you'll find at: http://www.connectionstrings.com/excel[^] and http://www.connectionstrings.com/excel-2007[^]
Read carefuly about IMEX option ;)

But, if you got trouble with separator for thousends and decimals, try to manually change it[^] or use CultureInfo (System.Globalization)[^] class to change it programmatically (to imitate other settings).
 
Share this answer
 
Comments
vino2012 12-Oct-12 4:06am    
Thanks, I fixed by removing IMEX=1. Default its IMEX=0 checking first 8 rows of data and it deciding the column type and also removing Excel format.
Maciej Los 12-Oct-12 10:59am    
Thank you for accepting solution ;)
If my solution was helpful, please, rate it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900