excel - How to Clear Table Style in Office Scripts?
问题描述
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?
解决方案
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.
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')
}
推荐阅读
- java - 除非删除特定列,否则无法从 CSV 文件中读取文本
- ios - RTSP 流 xcode 12.5
- javascript - 如何初始化我与前端的合同
- c# - 按下键时如何打印,它会打印一些东西,如果没有,它会打印另一个东西
- reactjs - 反应状态:两次更改状态是否也保证触发两次渲染?
- amazon-web-services - 完全验证 SES 身份时的 AWS SNS 通知?
- django - Celery Beat 如何计算 datetime.now() 和下一个计划的定期任务 django 之间的差异
- javascript - redux 工具包状态重置
- ffmpeg - FFMPEG 没有声音
- elasticsearch - 从 6.5.4 更新到 7.13.2 后,Kibana 服务器尚未准备好