# spreadsheet-editor-freeze-pane

> Spreadsheet editor demonstrating frozen rows and columns while scrolling through worksheet data.

**Framework:** aspnet-mvc  **Component:** Spreadsheet  **Variant:** freeze-pane

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/aspnet-mvc/spreadsheet-editor-freeze-pane.json
```

**Install Package(s)**

```bash
Install-Package Syncfusion.AspNetMvc.Spreadsheet
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/spreadsheet-editor-freeze-pane/SpreadsheetEditor.cshtml

```cshtml
@using Syncfusion.EJ2
@using Syncfusion.EJ2.Spreadsheet

@section ControlsSection{
    <div class="control-section">
        @Html.EJS().Spreadsheet("spreadsheet").OpenUrl("FreezePaneOpen").SaveUrl("FreezePaneSave").Created("createdHandler").Sheets(sheet =>
   {
       sheet.Name("Gross Salary").FrozenRows(2).FrozenColumns(2).SelectedRange("C1").Ranges(ranges =>
       {
           ranges.DataSource((IEnumerable<object>)ViewData["freezePaneData"]).StartCell("A2").Add();
       }).Rows(row =>{
           row.Cells(cell => {
               cell.Index(1).Value("Period").Style(new SpreadsheetCellStyle { FontSize = "12pt", FontWeight = FontWeight.Bold, TextAlign = TextAlign.Center, VerticalAlign = VerticalAlign.Middle }).Add();
               cell.Index(3).Value("Total Gross Salary").Style(new SpreadsheetCellStyle { FontSize = "12pt", FontWeight = FontWeight.Bold, TextAlign = TextAlign.Center, VerticalAlign = VerticalAlign.Middle }).Add();
           }).Add();
           row.Cells(cell =>
           {
               cell.Index(2).Value("Basic Salary").Add();
               cell.Value("Revised Basic Salary").Add();
               cell.Value("DA").Add();
               cell.Value("Revised DA").Add();
               cell.Value("HRA").Add();
               cell.Value("Revised HRA").Add();
               cell.Value("Conveyance Allowance").Add();
               cell.Value("Revised Conveyance Allowance").Add();
               cell.Value("Medical Expenses").Add();
               cell.Value("Revised Medical Expenses").Add();
               cell.Value("Special Allowance").Add();
               cell.Value("Revised Spcial Allowance").Add();
               cell.Value("Total Gross Salary").Add();
               cell.Value("Revised Total Gross Salary").Add();
           }).Add();
           row.Index(26).Cells(cell => {
               cell.Index(13).Value("Total Amount").Style(new SpreadsheetCellStyle { FontSize = "12pt", FontWeight = FontWeight.Bold, TextAlign = TextAlign.Center, VerticalAlign = VerticalAlign.Middle }).Add();
               cell.Formula("=SUM(O4:O26)").Style(new SpreadsheetCellStyle { FontSize = "12pt", FontWeight = FontWeight.Bold, TextAlign = TextAlign.Center, VerticalAlign = VerticalAlign.Middle }).Add();
               cell.Formula("=SUM(P4:P26)").Style(new SpreadsheetCellStyle { FontSize = "12pt", FontWeight = FontWeight.Bold, TextAlign = TextAlign.Center, VerticalAlign = VerticalAlign.Middle }).Add();
           }).Add();
       }).Columns(column => {
           column.Width(80).Add();
           column.Width(80).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(80).Add();
           column.Width(100).Add();
           column.Width(100).Add();
           column.Width(100).Add();
       }).Add();
   }).Render()
    </div>
}

<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>

@*custom code start*@
<style>
    .control-section {
        height: 550px;
    }
    #sb-content .e-spreadsheet .e-tab .e-tab-text {
        display: inherit;
    }
</style>

```

### src/components/spreadsheet-editor-freeze-pane/SpreadsheetEditorController.cs

```cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.EJ2.Spreadsheet;

namespace EJ2MVCSampleBrowser.Controllers.Spreadsheet
{
    public partial class SpreadsheetController : Controller
    {
        public ActionResult FreezePane()
        {
            List<object> data = new List<object>()
            {
                new { Month= "January",  Year= "2019",  BasicSalary= 15100,  RevisedBasicSalary= 15800,  DA= 2000,  RevisedDA= 2200, HRA= 5000,  RevisedHRA= 6500,  ConveyanceAllowance= 1500,  RevisedConveyanceAllowance= 1700, MedicalExpenses= 1250, RevisedMedicalExpenses= 1500, SpecialAllowance= 1000, RevisedSpecialAllowance= 1200, TotalGrossSalary= "=SUM(C3,E3,G3,I3,K3,M3)", RevisedTotalGrossSalary= "=SUM(D3,F3,H3,J3,L3,N3)", },
                new { Month= "February",  Year= "2019",  BasicSalary= 15100,  RevisedBasicSalary= 15800,  DA= 2000,  RevisedDA= 2200, HRA= 5000,  RevisedHRA= 6500,  ConveyanceAllowance= 1500,  RevisedConveyanceAllowance= 1700, MedicalExpenses= 1250, RevisedMedicalExpenses= 1500, SpecialAllowance= 1000, RevisedSpecialAllowance= 1200, TotalGrossSalary= "=SUM(C4,E4,G4,I4,K4,M4)", RevisedTotalGrossSalary= "=SUM(D4,F4,H4,J4,L4,N4)", },
                new { Month= "March",  Year= "2019",  BasicSalary= 15100,  RevisedBasicSalary= 15800,  DA= 2000,  RevisedDA= 2200, HRA= 5000,  RevisedHRA= 6500,  ConveyanceAllowance= 1500,  RevisedConveyanceAllowance= 1700, MedicalExpenses= 1250, RevisedMedicalExpenses= 1500, SpecialAllowance= 1000, RevisedSpecialAllowance= 1200, TotalGrossSalary= "=SUM(C5,E5,G5,I5,K5,M5)", RevisedTotalGrossSalary= "=SUM(D5,F5,H5,J5,L5,N5)", },
           
            };
            ViewData["freezePaneData"] = data;
            return View("~/Views/Home/spreadsheet-editor/freeze-pane/SpreadsheetEditor.cshtml");
        }

        public ActionResult FreezePaneOpen(OpenRequest openRequest)
        {
            return Content(Workbook.Open(openRequest));
        }

        public void FreezePaneSave(SaveSettings saveSettings)
        {
            if (saveSettings != null && saveSettings.JSONData != null)
            {
                Workbook.Save(saveSettings);
            }
        }
    }
}
```
