By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,881 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,881 IT Pros & Developers. It's quick & easy.

Problems reading certain columns in a Excel spreadsheet...

P: n/a
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...
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.