NamedRange.Table Method (Object, Object)


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)

object Table(
	object RowInput,
	object ColumnInput


Type: System.Object

A single cell to use as the row input for your table.

Type: System.Object

A single cell to use as the column input for your table.

Return Value

Type: System.Object

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.

For information on optional parameters, see Optional Parameters in Office Solutions.

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 void CreateTable()
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "K11"],

    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;

    Excel.Range region = this.Range["A1"].CurrentRegion;
    ((Excel.Range)region.Rows[1]).Font.Bold = true;
    ((Excel.Range)region.Columns[1]).Font.Bold = true;
Return to top