You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am trying to recreate a sheet by removing current sheets, adding new sheets, and populating the cells. So far so good, the sheet remove and recreate works, value set works, but when I try to set cell formats it presents the error below.
Sheet reloading process, this is the failing process.
async function getAllSheets() {
//loading the sheet from local storage
const sampleSheet = localStorage.getItem("samplesheet")
const convertedSheet = JSON.parse(sampleSheet)
//Removing all sheets from the list
for (let i = 0; i < sheetList.length; i++) {
workbookRef.current?.deleteSheet({ 'id': sheetList[i].id })
}
sheetList = []
//Sheet creation
for (let i = 0; i < convertedSheet.length; i++) {
await workbookRef.current?.addSheet()
workbookRef.current?.setSheetName(convertedSheet[i].name)
//Adding data
for (let j = 0; j < convertedSheet[i].data.length; j++) {
for (let k = 0; k < convertedSheet[i].data[j].length; k++) {
if (convertedSheet[i].data[j][k] !== null) {
workbookRef.current?.setCellValue(j, k, convertedSheet[i].data[j][k].v);
}
}
}
//set cell format - ### it fails here ###
cellFormat()
}
}
Cell format function
function cellFormat() {
//set cell format
for (let i = 0; i < 30; i++) {
if (workbookRef.current?.getCellValue(i, 0) !== null) {
workbookRef.current?.setCellFormat(i, 0, 'bl', 'data');
workbookRef.current?.setCellFormat(i, 0, 'bg', '#eeeeee');
}
}
for (let j = 0; j < 30; j++) {
if (workbookRef.current?.getCellValue(0, j) !== null) {
workbookRef.current?.setCellFormat(0, j, 'bl', 'data');
workbookRef.current?.setCellFormat(0, j, 'bg', '#eeeeee');
}
}
}
Not relevant, but it is here, the saving process for local storage
function saveAllSheets() {
const allSheets = workbookRef.current?.getAllSheets();
localStorage.setItem("samplesheet", JSON.stringify(allSheets))
}
The error happens when getAllSheets() process runs and cellFormat() is called. If I take cellFormat() out of getAllSheets() and use separate buttons, both works.
Expected behavior
I expect to be able to format the sheet in the same process I am creating the sheets.
Additional context
I tried to use CommonOptions to determine the sheet I am referring to, but I am probably doing it wrong. Try to find an example in the documentation or in here with no luck. It would be nice if you can provide me an example.
The text was updated successfully, but these errors were encountered:
Describe the bug
I am trying to recreate a sheet by removing current sheets, adding new sheets, and populating the cells. So far so good, the sheet remove and recreate works, value set works, but when I try to set cell formats it presents the error below.
To Reproduce
Steps to reproduce the behavior:
Sheet reloading process, this is the failing process.
Cell format function
Not relevant, but it is here, the saving process for local storage
The workbook itself:
The error happens when
getAllSheets()
process runs andcellFormat()
is called. If I takecellFormat()
out ofgetAllSheets()
and use separate buttons, both works.Expected behavior
I expect to be able to format the sheet in the same process I am creating the sheets.
Additional context
I tried to use CommonOptions to determine the sheet I am referring to, but I am probably doing it wrong. Try to find an example in the documentation or in here with no luck. It would be nice if you can provide me an example.
The text was updated successfully, but these errors were encountered: