組み込みワークシートアクション

このページでは、ReoGridで利用可能なすべての組み込みアクションクラスを一覧にしています。アクションはワークシート操作の元に戻す/やり直しサポートを提供します。

名前空間

using unvell.ReoGrid.Actions;

アクションの使用方法

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

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

カスタムアクションの作成と実行の監視の詳細については、アクションフレームワークを参照してください。

組み込みUIによってトリガーされるアクション

ユーザー操作アクション説明
セルの編集完了SetCellDataAction新しいセルの値を保存
Deleteキーで選択をクリアRemoveRangeDataAction選択範囲のデータを削除
ReoGridリッチコンテンツの貼り付けSetPartialGridActionスタイル、罫線、結合を含むデータを貼り付け
プレーンテキストの貼り付けSetRangeDataActionタブ区切りテキストを2D配列として貼り付け
選択範囲を新しい位置にドラッグMoveRangeAction選択範囲を移動
Ctrl + 選択範囲をドラッグCopyRangeAction選択範囲をコピー
フィルハンドルをドラッグAutoFillSerialAction選択範囲からデータを自動入力
行ヘッダーの区切りをドラッグSetRowsHeightAction新しい行の高さを記録
列ヘッダーの区切りをドラッグSetColumnsWidthAction新しい列の幅を記録
列の区切りをダブルクリックAutoFitColumnsWidthAction列の幅を内容に合わせて自動調整
スタイルブラシのコピーSetRangeStyleAction / SetRangeDataFormatActionスタイルと書式を適用

すべてのアクションクラス

セルデータアクション

アクションコンストラクタ説明
SetCellDataAction(string address, object data)単一セルのデータを設定
(CellPosition pos, object data)
(int row, int col, object data)
SetRangeDataAction(RangePosition range, object[,] data)2D配列から範囲のデータを設定
RemoveRangeDataAction(RangePosition range)範囲からデータを削除
SetPartialGridAction(RangePosition range, PartialGrid data, PartialGridCopyFlag flags)パーシャルグリッドを設定(データ + スタイル + 罫線)

範囲の移動/コピーアクション

アクションコンストラクタ説明
MoveRangeAction(RangePosition fromRange, CellPosition toPosition)範囲を新しい位置に移動
CopyRangeAction(RangePosition fromRange, CellPosition toPosition)範囲を新しい位置にコピー
AutoFillSerialAction(RangePosition sourceRange, RangePosition targetRange)ソース範囲からターゲット範囲に自動入力

行と列のアクション

アクションコンストラクタ説明
InsertRowsAction(int row, int count)指定した行の前に行を挿入
RemoveRowsAction(int row, int count)指定した行から行を削除
InsertColumnsAction(int column, int count)指定した列の前に列を挿入
RemoveColumnsAction(int column, int count)指定した列から列を削除
SetRowsHeightAction(int row, int count, ushort height)行の範囲の高さを設定
SetColumnsWidthAction(int col, int count, ushort width)列の範囲の幅を設定
AutoFitColumnsWidthAction(int col, int count, int padding = 0)列の幅を内容に合わせて自動調整

表示/非表示アクション

アクションコンストラクタ説明
HideRowsAction(int row, int count)行を非表示
UnhideRowsAction(int row, int count)非表示の行を表示
HideColumnsAction(int col, int count)列を非表示
UnhideColumnsAction(int col, int count)非表示の列を表示

結合アクション

アクションコンストラクタ説明
MergeRangeAction(RangePosition range)範囲を1つのセルに結合
UnmergeRangeAction(RangePosition range)結合された範囲を解除

スタイルと書式アクション

アクションコンストラクタ説明
SetRangeStyleAction(RangePosition range, WorksheetRangeStyle style)範囲にスタイルを適用
(string address, WorksheetRangeStyle style)
(int row, int col, int rows, int cols, WorksheetRangeStyle style)
RemoveRangeStyleAction(RangePosition range, PlainStyleFlag flag)範囲から特定のスタイルを削除
SetRangeBorderAction(RangePosition range, BorderPositions pos, RangeBorderStyle style)範囲に罫線を設定
RemoveRangeBorderAction(RangePosition range, BorderPositions pos)範囲から罫線を削除
SetRangeDataFormatAction(RangePosition range, CellDataFormatFlag format, object args)範囲のデータ書式を設定
StepRangeFontSizeAction(RangePosition range, bool enlarge)フォントサイズを拡大または縮小

アウトラインアクション

アクションコンストラクタ説明
AddOutlineAction(RowOrColumn rowOrColumn, int start, int count)行/列のアウトラインを追加
RemoveOutlineAction(RowOrColumn rowOrColumn, int start, int count)行/列のアウトラインを削除
ClearOutlineAction(RowOrColumn rowOrColumn)すべてのアウトラインをクリア
CollapseOutlineAction(RowOrColumn rowOrColumn, int start, int count)アウトラインを折りたたむ
ExpandOutlineAction(RowOrColumn rowOrColumn, int start, int count)アウトラインを展開

フィルターアクション

アクションコンストラクタ説明
CreateAutoFilterAction(RangePosition range)列の自動フィルターを作成

ワークブックアクション

アクションコンストラクタ説明
InsertWorksheetAction(int index, Worksheet worksheet)指定したインデックスにワークシートを挿入
RemoveWorksheetAction(int index, Worksheet worksheet)指定したインデックスのワークシートを削除

アクショングループ

アクションコンストラクタ説明
WorksheetActionGroup()複数のアクションを1つの元に戻すアイテムとしてグループ化
WorksheetReusableActionGroup(RangePosition range)範囲に対する繰り返し可能なアクショングループ

使用例

セルデータの設定

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

2D配列の貼り付け

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

行の挿入

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

スタイルの適用

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

罫線の適用

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

アクションのグループ化

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

範囲の移動

sheet.DoAction(new MoveRangeAction(
    sheet.SelectionRange,
    new CellPosition(10, 2)));

関連トピック


ページの内容は役に立ちましたか?