Search results

Freeze Panes in ASP.NET Core Spreadsheet control

14 Apr 2021 / 2 minutes to read

Freeze Panes helps you to keep particular rows or columns visible when scrolling the sheet content in the spreadsheet. You can specify the number of frozen rows and columns using the frozenRows and frozenColumns properties inside the Sheet property.

Apply freezepanes on UI

User Interface:

In the active spreadsheet, click the cell where you want to create freeze panes. Freeze panes can be done in any of the following ways:

  • Select the View tab in the Ribbon toolbar and choose the Freeze Panes item.
  • Use the freezePanes method programmatically.

FrozenRows

It allows you to keep a certain number of rows visible while scrolling vertically through the rest of the worksheet.

User Interface:

In the active spreadsheet, select the cell where you want to create frozen rows. Frozen rows can be done in any one of the following ways:

  • Select the View tab in the Ribbon toolbar and choose the Freeze Rows item.
  • You can specify the number of frozen rows using the frozenRows property inside the Sheet property.

FrozenColumns

It allows you to keep a certain number of columns visible while scrolling horizontally through the rest of the worksheet.

User Interface:

In the active spreadsheet, select the cell where you want to create frozen columns. Frozen columns can be done in any one of the following ways:

  • Select the View tab in the Ribbon toolbar and choose the Freeze Columns item.
  • You can specify the number of frozen columns using the frozenColumns property inside the Sheet property.

In this demo, the frozenColumns is set as ‘2’, and the frozenRows is set as ‘2’. Hence, the two columns on the left and the top two rows are frozen.

tagHelper
Copied to clipboard
<ejs-spreadsheet id="spreadsheet" created="createdHandler">
            <e-spreadsheet-sheets>
                <e-spreadsheet-sheet name="Gross Salary" frozenRows="2" frozenColumns="2" selectedRange="C1">
                    <e-spreadsheet-ranges>
                        <e-spreadsheet-range dataSource="ViewBag.DefaultData" startCell="A2"></e-spreadsheet-range>
                    </e-spreadsheet-ranges>
                    <e-spreadsheet-rows>
                        <e-spreadsheet-row>
                            <e-spreadsheet-cells>
                                <e-spreadsheet-cell index=1 value="Period">
                                    <e-spreadsheet-cellstyle fontSize="12pt" fontWeight="Bold" textAlign="Center" verticalAlign="Middle"></e-spreadsheet-cellstyle>
                                </e-spreadsheet-cell>
                                <e-spreadsheet-cell index=3 value="Total Gross Salary">
                                    <e-spreadsheet-cellstyle fontSize="12pt" fontWeight="Bold" textAlign="Center" verticalAlign="Middle"></e-spreadsheet-cellstyle>
                                </e-spreadsheet-cell>
                            </e-spreadsheet-cells>
                        </e-spreadsheet-row>
                        <e-spreadsheet-row>
                            <e-spreadsheet-cells>
                                <e-spreadsheet-cell index=2 value="Basic Salary"></e-spreadsheet-cell>
                                <e-spreadsheet-cell value="Revised Basic Salary"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="DA"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Revised DA"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="HRA"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Revised HRA"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Conveyance Allowance"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Revised Conveyance Allowance"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Medical Expenses"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Revised Medical Expenses"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Special Allowance"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Revised Spcial Allowance"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Total Gross Salary"></e-spreadsheet-cell>;
                                <e-spreadsheet-cell value="Revised Total Gross Salary"></e-spreadsheet-cell>;
                            </e-spreadsheet-cells>
                        </e-spreadsheet-row>
                        <e-spreadsheet-row index=26>
                            <e-spreadsheet-cells>
                                <e-spreadsheet-cell index=13 value="Total Amount">
                                    <e-spreadsheet-cellstyle fontSize="12pt" fontWeight="Bold" textAlign="Center" verticalAlign="Middle"></e-spreadsheet-cellstyle>
                                </e-spreadsheet-cell>
                                <e-spreadsheet-cell formula="=SUM(O4:O26)">
                                    <e-spreadsheet-cellstyle fontSize="12pt" fontWeight="Bold" textAlign="Center" verticalAlign="Middle"></e-spreadsheet-cellstyle>
                                </e-spreadsheet-cell>
                                <e-spreadsheet-cell formula="=SUM(P4:P26)">
                                    <e-spreadsheet-cellstyle fontSize="12pt" fontWeight="Bold" textAlign="Center" verticalAlign="Middle"></e-spreadsheet-cellstyle>
                                </e-spreadsheet-cell>
                            </e-spreadsheet-cells>
                        </e-spreadsheet-row>
                    </e-spreadsheet-rows>
                    <e-spreadsheet-columns>
                        <e-spreadsheet-column width="80"></e-spreadsheet-column>
                        <e-spreadsheet-column width="80"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="80"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                        <e-spreadsheet-column width="100"></e-spreadsheet-column>
                    </e-spreadsheet-columns>
                </e-spreadsheet-sheet>
            </e-spreadsheet-sheets>
        </ejs-spreadsheet>

<script>
    function createdHandler() {
        this.wrap("C2:P2");
        this.merge('A1:B1');
        this.merge('C1:P1');
        this.cellFormat({ backgroundColor: '#4e4ee6', color: '#FFFFF4', fontSize: '12pt', fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' }, 'A1:P2');
        this.cellFormat({ backgroundColor: '#4e4ee6', color: '#FFFFF4' }, 'A3:B26');
        this.numberFormat('$#,##0.00', 'C2:P26');
        this.numberFormat('$#,##0.00', 'O27:P27');
    }
</script>

Limitations

Freeze Panes feature is not compatible with all the features which are available in the spreadsheet and it has limited features support. Here, we have listed out the features which are not compatible with Freeze Panes feature.

  • Show/hide rows and columns with freeze panes.
  • Filtering support with freeze panes.
  • Merging the cells between freeze and unfreeze area.

See Also