Skip to content
Shiny.NET

Document Editor | Tables

A table inserted from Insert ▸ Tables (or opened in a document) is fully editable: the caret goes into a cell, and everything that works in a paragraph works there — typing, Enter, formatting, lists, find, replace and spelling. The arrow keys walk out of one cell into the next.

While the caret is in a table the contextual Table tab appears, as Word’s Table Layout tab does:

Group Commands
Rows & Columns Insert Above, Insert Below, Insert Left, Insert Right, Delete Rows, Delete Columns, Delete Table
Merge Merge Cells, Split Cells

The caret can be in a cell because a DocumentPosition now indexes the story — every paragraph in reading order, table cells included (WordDocument.Paragraphs) — rather than the top-level blocks.

Tab / Shift+Tab Next / previous cell, selecting its text. Tab in the last cell adds a row. In a list inside a cell, Tab still nests
Rows and columns InsertTableRowAbove/Below, InsertTableColumnLeft/Right, DeleteTableRow/Column, DeleteTable — columns are addressed by grid position, so inserting beside a spanned cell widens it
Merge / split Select from one cell into another and MergeTableCells() merges the rectangle between them (w:gridSpan across, w:vMerge down, contents moved in). SplitTableCell() undoes a merge, or splits a plain cell in two
Backspace at a cell’s start Does nothing, as in Word — nothing joins across a cell boundary

Each structural edit is one undo step that puts the whole table back.

var c = editor.Controller!;
c.InsertTable(3, 4);
c.InsertTableRowAbove(); c.InsertTableRowBelow();
c.InsertTableColumnLeft(); c.InsertTableColumnRight();
c.DeleteTableRow(); c.DeleteTableColumn(); c.DeleteTable();
c.MergeTableCells(); // the selection must run from one cell into another (c.CanMergeTableCells)
c.SplitTableCell();
c.IsInTable; c.CurrentCell;

Inserting a table itself — where it lands and how it is sized — is covered on Shapes, Pictures & Tables.