智能表格中用AirScript脚本无法获取获取【应用-台账】中的数据

阅读次数 70
let sheets = Application.ActiveWorkbook.Sheets;
sheets = Application.Sheets;
// 打印所有工作表的名称
for (let i = 1; i <= sheets.Count; i++) {
Application.Sheets.Item(i).Activate();
  console.log(`工作表
              名称 为:${sheets.Item(i).Name},
              ID 为:${sheets.Item(i).Id},
              Index 为:${sheets.Item(i).Index},
              Type 为:${sheets.Item(i).Type}
              `);
console.log(Application.Sheets.Item(i).UsedRange);//第一种方法,智能表格的脚本
}
console.log(Application.Record.GetRecords({ SheetId: 1 }));//第二种方法,多维表的脚本

上面两种方法都获取不到数据 多维表的方法直接报错 TypeError:Cannot read properties of undefined (reading 'GetRecords')

1 Answers

多维表前加Activate(),切换表格模式GetRecords就不会报错了,下边工作表如果在引用range前不Activate()工作表也会报错