Method DeleteCells
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
documentWordDocumentThe document that holds the cells.
firstTableCellOne corner.
lastTableCellThe opposite corner, in the same table.
shiftCellShiftLeft 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).