any site recommends for excel c#

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
 
M

mp

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
 

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