# Freeze Panes and Selection

> Freeze heading rows and columns or split a worksheet view with SheetView, select sheets and ranges with EditorUi and read the selection state in JavaScript.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Spreadsheet Editor > Freeze Panes and Selection
- **1130 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/freeze-panes/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/freeze-panes/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/freeze-panes/llms-full.txt

---

Long reports stay readable when their headings stay in view. Freeze the heading rows and columns of a worksheet while the rest of the report scrolls, or split the view into regions that scroll independently. Both are view settings of the worksheet, not cell formatting. Your code also decides when the visible selection follows what it does in the document.

### Freeze or Split the View

The following code freezes rows and columns of the first worksheet, selects a range and shows the alternatives to freezing. `editor` is the [Spreadsheet](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/llms-full.txt) of the browser editor, created as in [JavaScript](https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/javascript/llms-full.txt):

```javascript
const sheet = editor.workbook.sheets.at(0);
sheet.viewport.freeze({ rows: 3, columns: 1 });
editor.ui.selectRange(sheet.range('B4:D8'));
// Use split instead of freeze when separate scroll regions are needed:
sheet.viewport.split({ row: 10, column: 4 });
// Restore one unfrozen viewport:
sheet.viewport.reset();
```

The code works as follows:

- [Workbook.sheets](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbook/sheets-property/llms-full.txt) and [SheetCollection.at](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetcollection/at-method/llms-full.txt) return the first worksheet.
- [Worksheet.viewport](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/viewport-property/llms-full.txt) returns the [SheetView](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetview/llms-full.txt) of the worksheet. Its settings never alter the underlying row heights, column widths or print area.
- [freeze](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetview/freeze-method/llms-full.txt) freezes data rows and columns, given by `rows` and `columns`.
- [EditorUi.selectRange](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/editorui/selectrange-method/llms-full.txt) selects the range `B4:D8`, which [Worksheet.range](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/range-method/llms-full.txt) returns, in the visible interface.
- [split](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetview/split-method/llms-full.txt) creates split panes at the row and column boundaries given by `row` and `column`. Use it instead of `freeze` when you need separate scroll regions.
- [reset](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetview/reset-method/llms-full.txt) restores one unfrozen viewport.

Counts and boundaries are zero-based, as specified by the public methods. The fixed row and column labels of the editor are separate from frozen worksheet data.

Floating charts, shapes, pictures and barcodes scroll with the worksheet content. When you scroll past frozen rows or columns, those frozen cells cover the objects and their selection handles. Page Layout continues to show objects in their printable positions.

Validate the view in narrow containers and at high zoom values: a frozen area should leave usable space for the scrollable cells.

In-cell barcodes and pictures follow their worksheet cells. Pictures in frozen rows or columns stay pinned on that axis; scrolling pictures are clipped behind the frozen cells. A picture in a merged cell crossing a freeze boundary is displayed as aligned fragments in the corresponding panes. Page layout and PDF use the document layout.

### Select Sheets and Ranges From Code

Obtaining `book.sheets.at(1).cell('B2')` does not select that sheet. Call `editor.ui.selectSheet()` or `selectRange()`, the methods [selectSheet](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/editorui/selectsheet-method/llms-full.txt) and `selectRange` of `EditorUi`, only when the visible interface should follow the operation of your application.

Selecting a chart or a drawing works the same way and uses the owning editor and a valid object handle, with [selectChart](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/editorui/selectchart-method/llms-full.txt) or [selectDrawing](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/editorui/selectdrawing-method/llms-full.txt).

Use `editor.ui.selection`, the [selection](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/editorui/selection-property/llms-full.txt) property, to inspect the supported selection state. Do not calculate document addresses from browser pixel coordinates: UI geometry, font metrics, zoom and panes can all change the mapping.

### Print and Save Frozen Worksheets

Frozen and split views are not a replacement for print titles or repeated page headings. Configure the [print settings](https://docs.textcontrol.com/tx-sheet-control/pdf/page-layout/llms-full.txt) separately and inspect the output.

To keep a document, use the supported file persistence, described in [Loading and Saving Workbooks](https://docs.textcontrol.com/tx-sheet-control/document-processing/load-save/llms-full.txt), rather than saving transient DOM elements.

### Next Steps

- [Page Layout and Print Settings](https://docs.textcontrol.com/tx-sheet-control/pdf/page-layout/llms-full.txt): configure how a worksheet prints.
- [SheetView](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/sheetview/llms-full.txt): look up the worksheet view members in the TypeScript reference.
- [Appearance and Localization](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/appearance/llms-full.txt): control the appearance of the editor.
- [Keyboard and Accessibility](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/keyboard/llms-full.txt): navigate and select with the keyboard.

---

## Nearby

- **Previous:** [Keyboard and Accessibility](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/keyboard/llms-full.txt)
- **Next:** [Batch Updates, Undo and Redo](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/undo-redo/llms-full.txt)
