Table of Contents

Method DeleteCells

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

DeleteCells(WordDocument, TableCell, TableCell, CellShift)

Deletes the rectangle of cells two cells bound, as Word's Delete Cells does (WQ-0118, tools/Probe-WordDeleteCells.ps1). Shift left: each row loses its cells of the rectangle, the cells after them move left and the row ends with w:gridAfter (and w:wAfter, the width of the grid columns it leaves). Shift up: the rows stay; in each column of the rectangle the text of the cells below moves up by the rectangle's height and the bottom cells are left empty.

public static DocumentEdit DeleteCells(this WordDocument document, TableCell first, TableCell last, CellShift shift)

Parameters

document WordDocument

The document that holds the cells.

first TableCell

One corner.

last TableCell

The opposite corner, in the same table.

shift CellShift

Left or up.

Returns

DocumentEdit

The edit; After is the start of the cell now where the first deleted one was (or, shifting left at a row's end, the cell before it).

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The cells are not in one table of document, do not bound a rectangle of whole cells, or the shift is not defined.

InvalidOperationException

A cell to move spans columns or is vertically merged (shift up), or a row would lose every cell (shift left).