Search code examples
goexcelize360entsecgroup-skylar-excelize

Excelize freeze rows generates a file with errors


I am trying to freeze the top row and the first two columns of the 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"}]}`)

If I open the file in excel I get the below alert and after I try to recover the recovery log shows nothing removed:

Alert:

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.

Recovery log:

    <?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>

This is not a problem with the data as the file works fine if I remove the setPanes method. What am I doing wrong?

Also note that if I open the file with google sheets its working fine.


Solution

  • I figured it out in the end

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