any site recommends for excel c#

  • Thread starter Thread starter mp
  • Start date Start date
M

mp

i've been searching google for hours and find lots of stuff but nothing that
works with c#
or that i can figure out how to convert

i'm trying to add 3 rows at the top of an xl worksheet
i can open the doc and read or write but can't find how to add(insert) rows
yet

any tips or sites appreciated
thanks
mark
 
Peter Duniho said:
i've been searching google for hours and find lots of stuff but nothing
that
works with c#
or that i can figure out how to convert

i'm trying to add 3 rows at the top of an xl worksheet
i can open the doc and read or write but can't find how to add(insert)
rows
yet [...]

I'm not sure about what help communities exist for this sort of thing.
However, as far as your specific question goes, I believe you are looking
for the Range.Insert() method.

More generally, one often-reliable way to figure out what code to write to
do something in Excel is to record a macro doing that same thing. You'll
get VBA code, but the interop object model is basically the same as the
VBA object model, so the code is trivial to convert back to .NET
languages.

Pete

exactly what i originally assumed
I keep getting weird errors trying to convert vb/vba to c#
for example this line works in vb/vba
With oWorkSht
Dim rng As Range
Set rng = .Cells(1, 1)
Call rng.EntireRow.Insert
....
but in c# i get the error
Error 10 Non-invocable member 'Excel._Worksheet.Cells' cannot be used like a
method.
and
Error 11 No overload for method 'Insert' takes '0' arguments

with the code...
Range rng = xlWorkSheet.Cells(1, 1);//<------- error 10
rng.EntireRow.Insert();//<------- error 11
 
Back
Top