我正在尝试冻结工作表的第一行和前两列。
xlsx.SetPanes(sheetName, `{"freeze":true,"x_split":2,"y_split":1,"top_left_cell":"A1","active_pane":"topLeft","panes":[{"sqref":"A1:B1","pane":"topLeft"},{"sqref":"C1:XFD1", "pane":"topRight"},{"sqref":"A2:B2", "pane":"bottomLeft"},{"sqref":"C3:XFD3", "pane":"bottomRight"}]}`)如果我在excel中打开该文件,我会收到以下警报,并且在我尝试恢复后,恢复日志显示未删除任何内容:
警报:
We found a problem with some content in ’test.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.恢复日志:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>Repair Result to test3.xml</logFileName>
<summary>Errors were detected in file ’/test.xlsx’</summary>
<repairedRecords summary="Following is a list of repairs:">
<repairedRecord>Repaired Records: View from /xl/worksheets/sheet1.xml part</repairedRecord>
</repairedRecords>
</recoveryLog>这对于数据来说不是问题,因为如果我删除setPanes方法,文件就可以正常工作。我做错了什么?
还请注意,如果我打开的文件与谷歌工作表,它的工作正常。
发布于 2020-10-09 20:12:48
我最终弄明白了
xlsx.SetPanes(sheetName, `{"freeze":true,"x_split":2,"y_split":1,"top_left_cell":"C2","active_pane":"bottomRight","panes":[{"pane":"topLeft"},{"pane":"topRight"},{"pane":"bottomLeft"},{"active_cell":"C2", "sqref":"C2", "pane":"bottomRight"}]}`)发布于 2020-12-18 21:44:13
这是另一个例子。在第一列和前三行设置冻结:
xlsx.SetPanes(sheet, `
{
"freeze":true,
"x_split":1,
"y_split":3,
"top_left_cell":"B4",
"active_pane":"bottomRight",
"panes":[
{"pane":"topLeft"},
{"pane":"topRight"},
{"pane":"bottomLeft"},
{"active_cell":"B4", "sqref":"B4", "pane":"bottomRight"}
]
}
`)关键似乎决定了你的x_split,y_split值和sqref位置。有点挣扎,但对作者来说是弄清楚的道具。
https://stackoverflow.com/questions/64278295
复制相似问题