模板设计的时候,给单元格绑定了数据源字段,但是获取不到数据源,得到的是个null
get() {
const spread = this.designer.getWorkbook();
const sheetCount = spread.getSheetCount();
// 遍历工作簿中的每个工作表
let sourceCount = {};
for (let i = 0; i < sheetCount; i++) {
// 获取当前工作表
let sheet = spread.getSheet(i);
// 使用 name() 方法获取工作表名称
let sheetName = sheet.name();
let dataSource = null;
const dataSourceObject = sheet.getDataSource();
console.log(dataSourceObject, "dataSourceObject");
if (
dataSourceObject !== null &&
typeof dataSourceObject.getSource === "function"
) {
dataSource = dataSourceObject.getSource();
} else {
dataSource = sheet.getDataSource();
}
// console.log(dataSource, "dataSource");
sourceCount[sheetName] = dataSource;
}
console.log(sourceCount, "sourceCountsourceCount");
},
|