Hi,
We have written an app that lets a client load excel spreadsheets in to a
database. Most of the time this is working OK but occasionally we get a file
that simply misses a column in the spreadsheet, or sometimes it will only
read a few hundred lines from the spreadsheet.
There are no obvious formatting/data irregularities that I can see but if I
save the file as .CSV, open that and save it as .XLS again the file then
works fine.
Has anyone got any idea why this might be happening/how to fix it?
Thanks in advance,
Stu
The code:
cnExcel = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source
= c:\test.xls;Extended Properties=Excel 8.0;")
cnExcel.Open()
lookup = cnExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables , Nothing)
Dim cmdExcel As New OleDbCommand("SELECT * FROM [" &
lookup.Rows(0)("TABLE_NAME") & "]", cnExcel)
Dim drExcel As OleDbDataReader
drExcel = cmdExcel.ExecuteReader
Do While drExcel.Read
for i = 0 to drExcel.FieldCount
txtOut.appendText(drExcel(i) & vbcrlf)
next
txtOut.appendText(vbcrlf & vbcrlf)
Loop
'then close & tidy etc...