Groups | Blog | Home
all groups > dotnet ado.net > november 2005 >

dotnet ado.net : Insert columns into existing excel + OLEDB



rcm29
11/30/2005 12:00:00 AM
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,
Paul Clement
11/30/2005 8:37:54 AM
[quoted text, click to view]

¤ 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
~~~~
Reshma via DotNetMonster.com
12/1/2005 12:00:00 AM
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
AddThis Social Bookmark Button