Excel C#

  • Thread starter Thread starter Krish
  • Start date Start date
K

Krish

I have a two dimensional array which I would like to set to a RANGE

I know the length of the array, I know it has 2 columns too.

I would like to do something like

What I would like to do is something like

A1 - only cell reference given.


Could someone please tell me how to construct something programmatically
using get_Range / get_offset which will give me the whole
range area I want populated.

thanks
 
Hello,
Suppose you have a 2-D array, object[,] doubleArray.
and also you have got the Range, such that Range rng =
worksheet.get_Range("A1",Type.Missing);
To resize this range to the size of the data you have in the
doubleArray, do following,

rng = rng.get_Resize(doubleArray.GetUpperBound(0) + 1,
doubleArray.GetUpperBound(1) + 1);

to insert data in the worksheet, do following,

rng.Value2 = doubleArray;

I hope this will help.

Maqsood Ahmed
Kolachi Advanced Technologies

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Back
Top