TX Sheet Control

Rows and Columns

Topic

Row heights, column widths, inserted and deleted rows and hidden columns are all changed through the rows and columns collections of a worksheet. Both collections are bound to their worksheet, so you change the structure and size of a sheet without relying on the selected sheet.

Each size you set names its unit: points, CSS pixels or characters.

Use the Format Menu

Choose Home → Cells → Format to open the grouped worksheet commands. Cell Size contains Row Height, Column Width and their AutoFit commands. The size dialogs use CSS pixels. Visibility → Hide & Unhide acts on the selected rows or columns; select the surrounding visible rows or columns to reveal a hidden run.

Organize Sheets provides Rename Sheet, Move or Copy Sheet and Tab Color. The move dialog places the active sheet before a chosen worksheet or at the end, with an option to create a copy. Protection provides Protect Sheet, Lock Cell and Format Cells. Lock Cell changes the selected cells' locked state; sheet protection determines whether that state prevents editing.

Default Width, Hide Sheet and Unhide Sheet are shown disabled because workbook-wide default column sizing and worksheet visibility are not supported by the current model.

Size, Insert and Hide Rows and Columns

The following code sizes a row and two columns of the first worksheet, inserts and removes two rows and then hides and shows two columns. editor is the Spreadsheet of the browser editor:

const sheet = editor.workbook.sheets.at(0);
sheet.rows.get(1).setHeight({ points: 24 });
sheet.columns.get('A').setWidth({ pixels: 180 });
sheet.columns.at(1).setWidth({ characters: 16 });
sheet.rows.insert(4, 2); // Insert two rows before visible row 5.
sheet.rows.remove(4, 2);
sheet.columns.setHidden(3, 2, true); // Hide columns D and E.
sheet.columns.setHidden(3, 2, false);

The code works as follows:

  • Worksheet.rows and Worksheet.columns return the rows and the columns of the worksheet, each as a DimensionCollection.
  • get() uses visible labels: one-based row numbers or column letters, such as row 1 and column 'A'. at() and the structural indices are zero-based, so at(1) is column B. Both return a Dimension.
  • setHeight sets the height of row 1 to 24 points. setWidth sets column A to 180 CSS pixels and column B to 16 characters.
  • insert inserts two rows before the zero-based index 4, and remove deletes the two rows at that index again.
  • setHidden hides two columns from the zero-based index 3 with true and shows them again with false.

Choose the Units of a Size

DimensionAccepted units
Row heightPoints or CSS pixels
Column widthCharacters or CSS pixels

Choose the units explicitly. Character widths depend on the font metrics of the document. Do not treat them as a constant pixel conversion.

size reports the effective CSS-pixel size of a row or column. reset() removes the explicit dimension override.

Fit Rows and Columns to Their Content

In an editor, editor.ui.autoFitRows() and autoFitColumns() measure the current selection after the required fonts are available. For a deliberate subset, pass supported inclusive zero-based bounds as the first and last arguments.

AutoFit is a layout operation, not a promise that a long unbreakable value fits a narrow viewport.

What Structure Changes Affect

Insert and delete operations update supported references and document objects. They can reject invalid bounds, worksheet limits or protected edits.

  • Test realistic templates. Check merged cells, table calculated columns, names, drawing anchors and dependent formulas in realistic templates.
  • Reacquire handles. Reacquire handles whose addresses should change after structural edits: a range handle retains its stored address.

Hide Rows and Columns

Hiding keeps the data and the stored sizes. It is distinct from AutoFilter and from deleting rows.

Warning

Hidden Data. Hidden data may still be present in downloadable files and must not be used as an authorization mechanism.

Next Steps

  • Cells and Ranges: write values, text and formulas into the cells of the rows and columns.
  • Font Handling: deploy the fonts whose metrics decide character widths, wrapping and row heights.
  • DimensionCollection: look up every member of the rows and columns collections in the TypeScript reference.