Edit

Share via


Office.RangeCoordinates interface

Specifies a cell, or row, or column, by its zero-based row and/or column number. Example: {row: 3, column: 4} specifies the cell in the 3rd (zero-based) row in the 4th (zero-based) column.

Remarks

Examples

// Use RangeCoordinates to target specific cells when applying formatting.
// Both row and column are zero-based. Omitting one targets the entire row or column.
const specificCell: Office.RangeCoordinates = { row: 0, column: 1 };
const entireRow: Office.RangeCoordinates = { row: 2 };

const cellFormats: Office.RangeFormatConfiguration[] = [
    { cells: specificCell, format: { fontStyle: "bold" } },
    { cells: entireRow, format: { fontColor: "red" } }
];

const tableData = new Office.TableData();
tableData.headers = [["Product", "Price"]];
tableData.rows = [["Apple", "$1.00"], ["Banana", "$0.50"], ["Cherry", "$2.00"]];

Office.context.document.setSelectedDataAsync(
    tableData,
    { cellFormat: cellFormats },
    function (asyncResult) {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.error("Error: " + asyncResult.error.message);
        }
    }
);

Properties

column

The zero-based column of the range. If not specified, all cells, in the row specified by row are included.

row

The zero-based row of the range. If not specified, all cells, in the column specified by column are included.

Property Details

column

The zero-based column of the range. If not specified, all cells, in the row specified by row are included.

column?: number

Property Value

number

row

The zero-based row of the range. If not specified, all cells, in the column specified by column are included.

row?: number

Property Value

number