Insert columns into existing excel + OLEDB

R

rcm29

MyCase:
I have an excel file Example1.xls which has file columns say A,B,C,D,E.

Now when some error occurs i have to retrieve data from the input row index
(this im doing by retrieving from the dataset) and insert the same data along
with a new error message into the same file Example1.xls. So as a result my
file should now have 6 columns A,B,C,D,E and ErrorMessage.

I tried using ALTER table query to add a new column. But it doesnt work...!!
It gives error " Invalid Operation".
another option would be to copy the contents of the file into a temp table
add a column and then copy it back to my file. but this would not be a very
optimal solution when the file has a lot of data.

Is there any other way to add a new column to the existing excel file??
Please help.

Regards,
Resh
 
P

Paul Clement

¤ MyCase:
¤ I have an excel file Example1.xls which has file columns say A,B,C,D,E.
¤
¤ Now when some error occurs i have to retrieve data from the input row index
¤ (this im doing by retrieving from the dataset) and insert the same data along
¤ with a new error message into the same file Example1.xls. So as a result my
¤ file should now have 6 columns A,B,C,D,E and ErrorMessage.
¤
¤ I tried using ALTER table query to add a new column. But it doesnt work...!!
¤ It gives error " Invalid Operation".
¤ another option would be to copy the contents of the file into a temp table
¤ add a column and then copy it back to my file. but this would not be a very
¤ optimal solution when the file has a lot of data.
¤
¤ Is there any other way to add a new column to the existing excel file??
¤ Please help.
¤
¤ Regards,
¤ Resh

I'm not sure how you are creating the Excel Worksheet but why not just start with six columns. The
sixth column will be empty unless there is an error message for the row.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
R

Reshma via DotNetMonster.com

This is for a generic case where i can have any excel file as input. So every
excel file can have any number of columns. When an error occurs i must be
able to retrieve data from a particular row in the excel file and append it
at the end of the file along with an error message which must come in a new
column after all the columns...
So inserting of the new column must happen at run time...

--
Regards,
Resh

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-ado-net/200512/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

Top