[Q] How to remove the "frozen" state of a worksheet using ExcelJS
- Dominant language
- JavaScript
- Stars
- 15.5k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
I am attempting to utilize ExcelJS to remove the "frozen" state of a worksheet. My Code is as follows:
```
const workbook = new Workbook();
await workbook.xlsx.readFile(excel_path);
const worksheet = workbook.getWorksheet(sheet_name);
if(worksheet){
if(worksheet?.views[0]){
(worksheet.views as any) = [{
state: 'normal',
zoomScale: 100,
zoomScaleNormal: 100,
rightToLeft: false,
showGridLines: true,
showRowColHeaders: true,
showRuler: true,
workbookViewId: (worksheet.views[0] as any).workbookViewId,
}];
}
}
await workbook.xlsx.writeFile(excel_path);
```
However, upon saving and subsequently attempting to open the saved Excel file with Microsoft Excel, an alert is presented indicating an issue with the worksheet's view that necessitates repair.
I read the saved file using the following code, and then get the worksheet's view property:
```
const workbook = new Workbook();
await workbook.xlsx.readFile(excel_path);
const worksheet = workbook.getWorksheet(sheet_name);
if(worksheet){
console.log(worksheet.views);
}
```
The result I got is:
```
[{
state: 'frozen',
zoomScale: 100,
zoomScaleNormal: 100,
rightToLeft: false,
showGridLines: true,
showRowColHeaders: true,
showRuler: true,
xSplit: 0,
ySplit: 0,
topLeftCell: "A1",
workbookViewId: 0,
}]
```
Indeed, there is a problem. I would like to ask how to correctly remove the "frozen" property of a worksheet?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.