0

这是代码:

/**
 * This sample renames a worksheet from "Sheet1" to "SALES".
 */
function main(workbook: ExcelScript.Workbook) {
  // Get a worksheet named "Sheet1".
  const sheet = workbook.getWorksheet('Sheet1');

  // Set its name to SALES.
  sheet.setName('SALES');

  // Get a worksheet named "SALES".
  //const sheet = workbook.getWorksheet('SALES');
  // Position the worksheet at the beginning of the workbook.
  sheet.setPosition(0);
}
4

1 回答 1

1

您可以使用此代码使用 sales01、sales02 等约定重命名文件中的所有工作表。

  function main(workbook: ExcelScript.Workbook) {
let worksheets : ExcelScript.Worksheet[] = workbook.getWorksheets()
let sheetsCount: number = worksheets.length
for (let i = 0; i < sheetsCount; i++) {
  worksheets[i].setName(`SALES0${i + 1}`)
}

}

于 2021-08-25T16:10:03.427 回答