ToArray: Array;
The ToArray method creates a two-dimension array. The array size is defined by the cell range size.
To transform range into two-dimension array of real values, use the ITabRange.ToDouble2DArray method.
Executing the example requires a form that contains the Button component with the Button1 identifier, the TabSheetBox component with the TabSheetBox1 identifier and the UiTabSheet component with the UiTabSheet1 identifier. Set the UiTabSheet1 component as a data source for the TabSheetBox1 component.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
TSheet: ITabSheet;
TRange: ITabRange;
Arr: Array Of Variant;
i, j: Integer;
Begin
TSheet := UiTabSheet1.TabSheet;
TRange := TSheet.View.Selection.Range;
Arr := TRange.ToArray;
i := Arr.GetUpperBound(1);
j := Arr.GetUpperBound(2);
Debug.WriteLine("Array dimensions: " + i.ToString + ", " + j.ToString);
End Sub Button1OnClick;
Clicking the button creates Arr array which contains values of the cells contained in selected table range. The variable "i" will contain the number of rows in the array, while the variable "j" contains the number of columns.
See also: