【问题标题】:Excelize freeze rows generates a file with errorsExcelize 冻结行生成有错误的文件
【发布时间】:2021-01-24 10:21:52
【问题描述】:

我正在尝试冻结工作表的顶行和前两列。

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 表格打开文件,它的工作正常。

【问题讨论】:

    标签: go excelize 360entsecgroup-skylar-excelize


    【解决方案1】:

    我终于明白了

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2021-07-18
        • 2017-07-25
        • 1970-01-01
        • 1970-01-01
        • 2022-08-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多