NamedRange.Table Method
Creates a data table based on input values and formulas that you define in a worksheet.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Syntax
'Declaration
Function Table ( _
RowInput As Object, _
ColumnInput As Object _
) As Object
Object Table(
Object RowInput,
Object ColumnInput
)
Parameters
RowInput
Type: System.ObjectA single cell to use as the row input for your table.
ColumnInput
Type: System.ObjectA single cell to use as the column input for your table.
Return Value
Type: System.Object
Remarks
Use data tables to perform a what-if analysis by changing certain constant values on your worksheet to see how values in other cells are affected.
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
Examples
The following code example uses the Table method to create a formatted multiplication table in a NamedRange.
This example is for a document-level customization.
Private Sub CreateTable()
Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
= Me.Controls.AddNamedRange(Me.Range("A1", "K11"), _
"namedRange1")
Me.Range("A1").Formula = "=A12*A13"
Dim i As Integer
For i = 2 To 11
CType(Me.Cells(i, 1), Excel.Range).Value2 = i - 1
CType(Me.Cells(1, i), Excel.Range).Value2 = i - 1
Next i
namedRange1.Table(Me.Range("A12"), Me.Range("A13"))
Dim [region] As Excel.Range = Me.Range("A1").CurrentRegion
CType([region].Rows(1), Excel.Range).Font.Bold = True
CType([region].Columns(1), Excel.Range).Font.Bold = True
CType([region].Columns, Excel.Range).AutoFit()
End Sub
private void CreateTable()
{
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A1", "K11"],
"namedRange1");
this.Range["A1"].Formula = "=A12*A13";
for (int i = 2; i <= 11; i++)
{
((Excel.Range)this.Cells[i, 1]).Value2 = i - 1;
((Excel.Range)this.Cells[1, i]).Value2 = i - 1;
}
namedRange1.Table(this.Range["A12"],
this.Range["A13"]);
Excel.Range region = this.Range["A1"].CurrentRegion;
((Excel.Range)region.Rows[1]).Font.Bold = true;
((Excel.Range)region.Columns[1]).Font.Bold = true;
((Excel.Range)region.Columns).AutoFit();
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.