This page lists all built-in action classes available in ReoGrid. Actions provide undo/redo support for worksheet operations.

Namespace

using unvell.ReoGrid.Actions;

Using Actions

// Perform an action
sheet.DoAction(new SetCellDataAction("B2", "Hello"));

// Undo / Redo
grid.Undo();
grid.Redo();

See Action Framework for details on creating custom actions and monitoring execution.

Actions Triggered by Built-in UI

User OperationActionDescription
Finish editing a cellSetCellDataActionStores the new cell value
Press Delete to clear selectionRemoveRangeDataActionRemoves data in the selection
Paste ReoGrid rich contentSetPartialGridActionPastes data with styles, borders, merges
Paste plain textSetRangeDataActionPastes tab-separated text as 2D array
Drag selection to new locationMoveRangeActionMoves the selected range
Ctrl + drag selectionCopyRangeActionCopies the selected range
Drag fill handleAutoFillSerialActionAuto-fills data from the selection
Drag row header separatorSetRowsHeightActionRecords the new row height
Drag column header separatorSetColumnsWidthActionRecords the new column width
Double-click column separatorAutoFitColumnsWidthActionAuto-fits column width to content
Style brush copySetRangeStyleAction / SetRangeDataFormatActionApplies style and format

All Action Classes

Cell Data Actions

ActionConstructorDescription
SetCellDataAction(string address, object data)Set data of a single cell
(CellPosition pos, object data)
(int row, int col, object data)
SetRangeDataAction(RangePosition range, object[,] data)Set data for a range from a 2D array
RemoveRangeDataAction(RangePosition range)Remove data from a range
SetPartialGridAction(RangePosition range, PartialGrid data, PartialGridCopyFlag flags)Set a partial grid (data + styles + borders)

Range Move/Copy Actions

ActionConstructorDescription
MoveRangeAction(RangePosition fromRange, CellPosition toPosition)Move a range to a new position
CopyRangeAction(RangePosition fromRange, CellPosition toPosition)Copy a range to a new position
AutoFillSerialAction(RangePosition sourceRange, RangePosition targetRange)Auto-fill from source to target range

Row and Column Actions

ActionConstructorDescription
InsertRowsAction(int row, int count)Insert rows before the specified row
RemoveRowsAction(int row, int count)Remove rows starting at the specified row
InsertColumnsAction(int column, int count)Insert columns before the specified column
RemoveColumnsAction(int column, int count)Remove columns starting at the specified column
SetRowsHeightAction(int row, int count, ushort height)Set height for a range of rows
SetColumnsWidthAction(int col, int count, ushort width)Set width for a range of columns
AutoFitColumnsWidthAction(int col, int count, int padding = 0)Auto-fit column width to content

Visibility Actions

ActionConstructorDescription
HideRowsAction(int row, int count)Hide rows
UnhideRowsAction(int row, int count)Show hidden rows
HideColumnsAction(int col, int count)Hide columns
UnhideColumnsAction(int col, int count)Show hidden columns

Merge Actions

ActionConstructorDescription
MergeRangeAction(RangePosition range)Merge a range into a single cell
UnmergeRangeAction(RangePosition range)Unmerge a merged range

Style and Format Actions

ActionConstructorDescription
SetRangeStyleAction(RangePosition range, WorksheetRangeStyle style)Apply styles to a range
(string address, WorksheetRangeStyle style)
(int row, int col, int rows, int cols, WorksheetRangeStyle style)
RemoveRangeStyleAction(RangePosition range, PlainStyleFlag flag)Remove specific styles from a range
SetRangeBorderAction(RangePosition range, BorderPositions pos, RangeBorderStyle style)Set borders on a range
RemoveRangeBorderAction(RangePosition range, BorderPositions pos)Remove borders from a range
SetRangeDataFormatAction(RangePosition range, CellDataFormatFlag format, object args)Set data format for a range
StepRangeFontSizeAction(RangePosition range, bool enlarge)Increase or decrease font size

Outline Actions

ActionConstructorDescription
AddOutlineAction(RowOrColumn rowOrColumn, int start, int count)Add a row/column outline
RemoveOutlineAction(RowOrColumn rowOrColumn, int start, int count)Remove a row/column outline
ClearOutlineAction(RowOrColumn rowOrColumn)Clear all outlines
CollapseOutlineAction(RowOrColumn rowOrColumn, int start, int count)Collapse an outline
ExpandOutlineAction(RowOrColumn rowOrColumn, int start, int count)Expand an outline

Filter Actions

ActionConstructorDescription
CreateAutoFilterAction(RangePosition range)Create a column auto-filter

Workbook Actions

ActionConstructorDescription
InsertWorksheetAction(int index, Worksheet worksheet)Insert a worksheet at the specified index
RemoveWorksheetAction(int index, Worksheet worksheet)Remove a worksheet at the specified index

Action Groups

ActionConstructorDescription
WorksheetActionGroup()Group multiple actions as one undo item
WorksheetReusableActionGroup(RangePosition range)Repeatable action group for a range

Examples

Set Cell Data

sheet.DoAction(new SetCellDataAction("B2", "Hello"));

Paste a 2D Array

var data = new object[,] { { 1, 2 }, { 3, 4 } };
sheet.DoAction(new SetRangeDataAction(new RangePosition("C3:D4"), data));

Insert Rows

sheet.DoAction(new InsertRowsAction(5, 2));  // Insert 2 rows before row 5

Apply Styles

sheet.DoAction(new SetRangeStyleAction("A1:C3", new WorksheetRangeStyle
{
    Flag = PlainStyleFlag.BackColor | PlainStyleFlag.Bold,
    BackColor = Color.LightYellow,
    Bold = true,
}));

Apply Borders

sheet.DoAction(new SetRangeBorderAction(
    sheet.SelectionRange,
    BorderPositions.Outside,
    new RangeBorderStyle { Color = Colors.Black, Style = BorderLineStyle.Solid }));

Group Actions

var group = new WorksheetActionGroup();
group.Actions.Add(new SetCellDataAction(0, 0, "Key"));
group.Actions.Add(new SetCellDataAction(0, 1, "Value"));
group.Actions.Add(new SetCellDataAction(0, 2, "Description"));
grid.DoAction(sheet, group);  // One undo item

Move Range

sheet.DoAction(new MoveRangeAction(
    sheet.SelectionRange,
    new CellPosition(10, 2)));
Was this article helpful?