473,323 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Dataset/Excel Problem

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!
Oct 10 '06 #1
2 1109

What is your connection string ?

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


"James" <mi*******@gmail.comwrote in message
news:Of**************@TK2MSFTNGP04.phx.gbl...
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!


Oct 10 '06 #2
A prince among men, thank you.
"sloan" <sl***@ipass.netwrote in message
news:eJ**************@TK2MSFTNGP03.phx.gbl...
>
What is your connection string ?

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


"James" <mi*******@gmail.comwrote in message
news:Of**************@TK2MSFTNGP04.phx.gbl...
>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!



Oct 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
1
by: tkaleb | last post by:
I have to create output file in a text, MS Access, MS Excel and .dbf format from C# Win/ADO.NET application. Data are collected in DataSet and there is no problem to make text file. However, I have...
7
by: kscdavefl | last post by:
I am running the following code to retrieve a DataSet: public DataView CreateGroupSource() { string groupConnect = Session.ToString(); string groupSelect = "Select grpname from Maxusergroups...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
1
by: Bernard O'Flynn | last post by:
Hi I have a pivot table that gets it data from another worksheet in the workbook. I need to update the data worksheet from data in a database (I'm using MS Data Application Block) and get a...
3
by: Schultz | last post by:
I would like to know if it is possible to import data from MS Excel 2000 to a dataset using asp.net. The excel file would need to be uploaded to the server from a web page first, before the loaded...
4
by: Phoebe. | last post by:
Hi, Good Day! Reading 1 excel file into a dataset is fine. How can I read multiple excel with the same data structure into 1 dataset? How can I append those data? Can someone help? Thanks in...
1
by: Vanajakshi Pidatala | last post by:
Hello, I am trying to show data in dataset in to an excel sheet(ASP.NET/VB.NET). I AM DOING THIS ON SERVER(IIS SERVER) WHICH HAS EXCEL VERSION 9. I COULD ADD REFERENCE TO EXCEL VERSION 9 AND...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I am converting Excel data into a Dataset in C#. There are around 24 columns in the Excel Sheet. First I tried to insert one row with correct values in the Excel sheet. i.e. for text columns...
1
by: =?Utf-8?B?Y29uc3RhbnRpbg==?= | last post by:
I have problem with my code I need to read from Excel worksheet into dataset the problem is in this line oleda.Fill(ds). The data adapter should fill dataSet with data from Excel worksheet but...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.