1

How can I clear the styles on a table? I tried recording the macro but when I record it and run it, it will say failed (Table setPredefinedTableStyle: The argument is invalid or missing or has an incorrect format.).

function main(workbook: ExcelScript.Workbook) {
  let selectedSheet = workbook.getActiveWorksheet();
  let mainTable = selectedSheet.getTable("MainTable");
  mainTable.setPredefinedTableStyle("undefined");
}

How can I clear the table style?

https://docs.microsoft.com/en-us/javascript/api/office-scripts/excelscript/excelscript.table?view=office-scripts#setpredefinedtablestyle-predefinedtablestyle-

enter image description here

4

1 回答 1

2

Excel tables in web always has a style. There isn't a way to clear all styles. There doesn't appear to be a way to assign the "none" style, which is the most basic style. I'll follow-up on that.

enter image description here

The closest I can get to was to use TableStyleLight1 style as shown below.

function main(workbook: ExcelScript.Workbook) {
  let selectedSheet = workbook.getActiveWorksheet();
  let mainTable = selectedSheet.getTable("MainTable");
  mainTable.setPredefinedTableStyle('TableStyleLight1')
}
于 2020-11-02T23:55:46.830 回答