Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to freeze a pane in an Excel table using SheetJS?

I use SheetJS to make an Excel table in my node.js application:

const xlsx = require('xlsx');

const workbook = xlsx.utils.book_new();
const worksheet = xlsx.utils.aoa_to_sheet([
    ['Number', 'Name', 'Value'],
    [1, 'Bill', 1500],
    [2, 'John', 2300]
]);
xlsx.utils.book_append_sheet(workbook, worksheet, 'Accounts');
xlsx.writeFile(workbook, 'output.xlsx');

How to freeze a pane of the table, e.g. the first row? Saying "freeze" I mean making a row and/or a column always stay on the top of a table viewer interface.

like image 685
Finesse Avatar asked Feb 07 '18 04:02

Finesse


People also ask

Why won't Excel let me freeze panes?

One of the most common reasons why the Freeze Panes feature is not working is if your Excel file is not in normal file preview mode. Depending on the situation, you can address this problem by setting your preview to Normal or Page Break Preview.

Can you freeze panes in the middle of a spreadsheet?

As the result, you'll be able to scroll through the sheet content while continuing to view the frozen cells in the first two rows: Notes: Microsoft Excel allows freezing only rows at the top of the spreadsheet. It is not possible to lock rows in the middle of the sheet.

How do I freeze panes vertically and horizontally at the same time?

To freeze horizontal and vertical headings simultaneously: Select the cell in the upper-left corner of the range you want to remain scrollable. Select View tab, Windows Group, click Freeze Panes from the menu bar. Excel inserts two lines to indicate where the frozen panes begin.

How do I freeze E panes?

On the View tab, select the Freeze Panes command, then choose Freeze Panes from the drop-down menu. The rows will be frozen in place, as indicated by the gray line. You can scroll down the worksheet while continuing to view the frozen rows at the top.


1 Answers

It seems there were some tries to implement this feature, but as of version 0.14.1 it is still not available.

It seems someone in Apr 2, 2017 tried to implement it. I even tried using the sample code on the javascript comments but it didn't work.

Reference: Commit history on GitHub

Doing a code search on v.0.14.1 I found 3 instances of the word "Freeze":

0x0087: 'FREEZE.PANES', // On line 11478
case 'FreezePanes': break; // On line 15746
/* FreezePanes */ // On line 16113

So, it seems there were some tries to implement it but there were removed/abandoned, at least on the community version as of 0.14.

like image 161
tuliomir Avatar answered Oct 25 '22 16:10

tuliomir