Office.RangeCoordinates interface
按从零开始的行和/或列号指定单元格、行或列。 示例: {row: 3, column: 4} 在第 4 (从零开始) 列中指定第 3 (从零开始的) 行中的单元格。
注解
示例
// 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);
}
}
);
属性详细信息
column
范围的从零开始的列。 如果未指定,则包括 由 row 指定的行中的所有单元格。
column?: number
属性值
number
row
范围的从零开始的行。 如果未指定,则包含指定 column 列中的所有单元格。
row?: number
属性值
number