question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Freeze panes when writing an XLS file

See original GitHub issue

Has anyone figured out how to freeze panes using this library? I tried many things and always get the message that the Excel file is partly unreadable and needs to be repaired.

The XML I am adding looks like this:

<sheetViews>
    <sheetView tabSelected="1" workbookViewId="0">
        <pane xSplit="1" ySplit="1" topLeftCell="B2" activePane="bottomRight" state="frozen" />
        <selection pane="topRight" activeCell="B1" sqref="B1" />
        <selection pane="bottomLeft" activeCell="A2" sqref="A2" />
        <selection pane="bottomRight" activeCell="B2" sqref="B2" />
    </sheetView>
</sheetViews>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:7
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
Finessecommented, Feb 10, 2018

Could anyone share a ready JavaScript code which freezes a pane?

2reactions
SheetJSDevcommented, Mar 13, 2017

@nmalancea @shapiromatron Feature requests like this are tricky because it first involves understanding the feature and how it is represented in the actual raw formats. Let’s focus on XLSX for the moment.

Based on some testing, I think Excel XLSX cares about where the sheetViews appears in the XML file. To test this, I saved a file with a freeze pane, then just moved the sheetViews block around the file. If the sheetViews block appears just after the dimension tag then the file is valid, but moving the block anywhere else in the sheet file causes issues.

This is consistent with other formats too – MS-XLSB worksheet binary format expects the view information to appear after the dimension record.

For example, in the XML this works:

  <dimension ref="A1:H8"/>
  <sheetViews>
    <sheetView workbookViewId="0">
      <pane xSplit="1" ySplit="1" topLeftCell="E5" activePane="bottomRight" state="frozen"/>
      <selection pane="topRight" activeCell="E1" sqref="E1"/>
      <selection pane="bottomLeft" activeCell="A5" sqref="A5"/>
      <selection pane="bottomRight" activeCell="E5" sqref="E5"/>
    </sheetView>
  </sheetViews>
  <sheetFormatPr baseColWidth="10" defaultColWidth="3.6640625" defaultRowHeight="16" x14ac:dyDescent="0.2"/>
  <sheetData>

This does not work:

  <dimension ref="A1:H8"/>
  <sheetFormatPr baseColWidth="10" defaultColWidth="3.6640625" defaultRowHeight="16" x14ac:dyDescent="0.2"/>
  <sheetViews>
    <sheetView workbookViewId="0">
      <pane xSplit="1" ySplit="1" topLeftCell="E5" activePane="bottomRight" state="frozen"/>
      <selection pane="topRight" activeCell="E1" sqref="E1"/>
      <selection pane="bottomLeft" activeCell="A5" sqref="A5"/>
      <selection pane="bottomRight" activeCell="E5" sqref="E5"/>
    </sheetView>
  </sheetViews>
  <sheetData>

(the difference is the relative location of the sheetFormatPr)

@nmalancea can you check if putting the sheetViews block directly after the dimension tag fixes the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel: Freezing Panes and View Options - GCF Global
Select the row below the row(s) you want to freeze. In our example, we want to freeze rows 1 and 2, so we'll...
Read more >
Freeze Panes In Excel With Example - Simplilearn
1. In the windows group, go to the View tab, and click Freeze Panes. Click Freeze Top Row. 2. Go to View >...
Read more >
How to Freeze Rows and Columns in Excel to Lock in Place
On the Microsoft Excel Ribbon, click the View tab · To see the Freeze Pane options, click the arrow on the Freeze Panes...
Read more >
Set freeze panes in Excel document in C#, VB.NET - Syncfusion
Rows and columns in an Excel document can be frozen by using the FreezePanes() method of IRange interface. To freeze the rows or...
Read more >
Excel - Freeze panes to lock rows and columns
To keep an area of a worksheet visible while you scroll to another area of the worksheet, go to the View tab, where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found