Dataset/Excel Problem

J

James

I'm querying an Excel Spreadsheet and populating a DataSet with the returned
data. This works fine, and I can bind to a datagrid without problem.
That's assuming I have the first row containing the column headings. If my
first row is data and *not* headings, I want to treat it as if there are
columns called Column0, Column1, Column2, etc.

If I iterate through the columns in the DataTable and set the ColumnName, it
seems to overwrite the first row of data, which I obviously can't have. The
alternative solution (I anticipated) would be to add a record after the bind
with Column0, Column1, etc. etc...but apparently after binding to Excel, the
DataTable has knowledge of the datatype, so if it makes the column of type
Double, then I can't very well add "Column4" in the first row, because the
cast will fail.

I've been scratching my head for far too long on this. Probably overlooking
something very simple, please enlighten me!
 
S

sloan

What is your connection string ?

private static string GetExcelExtendedPropertiesValue(bool
headerRowExists)
{
return "'" + "Excel 8.0" + ";HDR=" + (string)(headerRowExists ? "Yes" :
"No") + ";IMEX=1'"; ;
}
 
J

James

A prince among men, thank you.


sloan said:
What is your connection string ?

private static string GetExcelExtendedPropertiesValue(bool
headerRowExists)
{
return "'" + "Excel 8.0" + ";HDR=" + (string)(headerRowExists ? "Yes" :
"No") + ";IMEX=1'"; ;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top