Sunday, April 15, 2007  Automating Excel with Ruby: Defining a
Range and Inserting Data  As I previously mentioned, calling the
Value method on an Excel Range object returns an array of arrays
of values. Here's a quick way to get a 2-dimensional array of
all values from a worksheet...  data = worksheet.UsedRange.Value
But, as I failed to mention in that article, you can also insert
a 2-dimensional array into a Range of cells:
worksheet.Range("A2:G7").Value = data  If you have a lot of data
to insert, this will be much faster than inputting the data
cell-by-cell. But it is important that the range of cells be the
same size (number of rows, number of columns) as your 2d array.
Your Array: Number of Rows  Assuming you have data, a
2-dimensional array, you can determine the number of rows by
calling data.size:  rows = data.size  Your Array: Number of
Columns  You can determine the number of columns by calling size
on one of the data array's rows:  cols = data[0].size  Defining
Your Worksheet Range  But to use