insert row to Excel using C#

  • Thread starter Thread starter Tim Wallace
  • Start date Start date
T

Tim Wallace

I need to insert a row into an Excel spreadsheet using C#. I get a
reference to the app, the workbook, the sheet. When I attempt to call
Insert, I keep getting errors, probably because I'm not certain what the
args are (and cannot find any documentation to help). I supplied the 2 args
as I thought were correct ( Microsoft.Office.Inerop.Excel.XlDirection.xlUp,
row_num ), but these don't seem correct. Can anyone please help or point me
to a valid Web source?

TIA,

Tim
 
Your argument Microsoft.Office.Inerop.Excel.XlDirection.xlUp,
row_num

Inerop -->Interop
 
Tim Wallace said:
I need to insert a row into an Excel spreadsheet using C#. I get a
reference to the app, the workbook, the sheet. When I attempt to call
Insert, I keep getting errors, probably because I'm not certain what the
args are (and cannot find any documentation to help). I supplied the 2
args as I thought were correct (
Microsoft.Office.Inerop.Excel.XlDirection.xlUp, row_num ), but these don't
seem correct. Can anyone please help or point me to a valid Web source?

Can't you use ADO.NET with an Excel connection string instead? Then you just
use T-SQL INSERT statements :)

http://www.c-sharpcorner.com/Code/2004/June/AccessExcelDb.asp
 
Thanks. I'll give it a try.

By the way, in my code it reads "Interop"; I just mistyped it in my post.

Tim
 
Yes, if he defines a range. You can also use adox to change the schema
without instantiating Excel. Office automation is evil.
 
Back
Top