Last post Dec 09, 2008 05:10 AM by dhawalseth
Dec 08, 2008 01:21 PMfirstname.lastname@example.org|LINK
I am trying to automate excel using "jet provider 4.0". iam facing a strange problem, please find my approach and the problem below.
1) i have written the following code to read data from the excelsheet. iam passing source file name (srcFileName ) and worksheetname as parameters to this mehtod.
objAdp.SelectCommand = ObjCommand;
i have used IMEX=1 because my excel sheet contains text inbetween rows, so i was unable to read some of the data and one of the forum suggested in using IMEX=1 to read data in string format.
2) Please find below screenshot of the excel file along with some data. As can bee seen there are values like 6,5 and 6 (1st row) etc., ..but actually when we see these values in the excel formulae bar the values will be 5.923, 5.432, 6.456 respectively
for the first row and similarly for the remaining rows. They have applied some format for the excel cells to display in that manner. When i execute the above code and read excel data into datatable, i sometimes get the values as 6,5,6 and some times i get
the same cells as 5.923, 5.432, 6.456. even without changing any code iam getting this behaviour. Actually i need to read the values as 6,5 and 6 respectively.
Do i need to change anything in my code or do i need to completely remove my code and use interop dlls to read the data in our own format. But my primary concern is i need to read arount 30 excel worksheets with data in the range 0f 100 rows and 10 columns.
jet provider is lot quicker compared to using interop.
Thanks in advance,
C#. NET 2005
.net 2.0 c#
c# com interop cast
Dec 09, 2008 05:10 AM|dhawalseth|LINK
hi i have just finished some coding like this only, please keep me in the loop if any of you can achieve this.