x-spreadsheet
x-spreadsheet copied to clipboard
非初始化的導入多 sheet 後,切換 sheet 會出現 this.data is undefined 的問題
初始化使用 loadData()
可以正常切換多個 sheet,但我想要做導入 Excel 的功能,所以點了按鈕之後才使用 loadData()
init = () => {
spreadsheet.value = new Spreadsheet(spreadsheetContainer.value as HTMLDivElement, {
showToolbar: true,
showGrid: true,
view: {
width: () => props.mainWidth,
height: () => props.mainHeight
},
row: {
len: 500,
height: 25
}
})
}
onClick = () => {
spreadsheet.value.loadData(workbook.value)
}
結果要切換不同工作表時,就出現錯誤
Cannot destructure property 'rows' of 'this.data' as it is undefined.
目前看起來是沒有取到 this.data,導致後續問題
有人碰過類似的問題嗎?
目前想到比較爛的解法是先銷毀再創建實例,但我也沒找到銷毀的方法 ....