我尝试创建一个office脚本,它的功能与下面的excel makro相同:
Sub clear()
Rows("2:" & Rows.Count).ClearContents
End Sub我的办公脚本如下所示:
function main(workbook: ExcelScript.Workbook)
{
let table = workbook.getTable("Table1");
let rowCount = workbook.getTables()[0].getRowCount();
table.deleteRowsAt(2, rowCount);
}我得到以下错误:
Line 9: Cannot read property 'deleteRowsAt' of undefined我不明白为什么属性"deleteRowsAt“是未定义的。
它需要是一个办公脚本,因为我想使用power automate自动执行一个流程。
发布于 2021-07-12 20:21:00
不知道为什么在rowCount代码中没有使用table。你甚至不确定你是否能得到那张桌子。
假设您的表从第2行开始,标题在第1行,要删除该表,请参阅以下代码。
function main(workbook: ExcelScript.Workbook) {
let table = workbook.getTable("Table1");
let rowCount = table.getRowCount();
table.deleteRowsAt(0, rowCount);
}发布于 2021-07-12 15:22:16
office脚本正常工作,您需要检查表名是否真的是您的表名
https://stackoverflow.com/questions/68343062
复制相似问题