Excelize 冻结行生成一个有错误的文件

Excelize freeze rows generates a file with errors

我正在尝试冻结 sheet 的第一行和前两列。

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 方法,文件工作正常。我做错了什么?

另请注意,如果我用 google sheet 打开文件,它工作正常。

最后我想通了

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"}]}`)

这是另一个例子。在第一列和前三行设置冻结:

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_splity_split 值和 sqref 位置。有点挣扎,但支持作者弄清楚。