您好,setTemplateCell时,第三个参数templateCell是一个对象,可以在配置的属性外,添加您的自定义数据,如下代码:
- columns.forEach((columnName, i) => {
- let obj = {
- type: "List",
- binding: `student[${columnName}]`,
- }
- templateSheet.setValue(0, i, columnName);
- templateSheet.setTemplateCell(1, i, {...obj,...{row: 1, col: i, content: `我是${columnName}`}})
- })
复制代码 在模板预览时,可以通过getTemplateCell获取templateCellInfo , 如下代码:
- document.querySelector(".btn1").addEventListener("click", () => {
- const reportSheet = spread.getActiveSheetTab()
- var activeCellRow = reportSheet.getSheet().getActiveRowIndex();
- var activeCellColumn = reportSheet.getSheet().getActiveColumnIndex();
- const designTemplateCell = reportSheet.getTemplateCell(activeCellRow, activeCellColumn)
- console.log(designTemplateCell)
- })
复制代码
|