Skip to main content

TdxSpreadSheetTableView.InsertCells(string,TdxSpreadSheetCellsModification,TdxSpreadSheetTableViewMergedCellsConflictResolution) Method

Inserts an empty cell range into the worksheet.

Declaration

procedure InsertCells(const AArea: string; AModification: TdxSpreadSheetCellsModification; AMergedCellsConflictResolution: TdxSpreadSheetTableViewMergedCellsConflictResolution = mccrShowConfirmation); overload;

Parameters

Name Type
AArea string
AModification TdxSpreadSheetCellsModification
AMergedCellsConflictResolution TdxSpreadSheetTableViewMergedCellsConflictResolution

Remarks

This procedure inserts a cell range matching the current selection. Adjacent uninitialized cells and cell objects are shifted right and down by the selected area‘s width and height, respectively. If there are no selected (focused) cells within the Table View worksheet, the InsertCells procedure raises the EdxSpreadSheetError exception.

The second overloaded variant inserts a cell range whose area is passed as the AArea parameter. The AModification parameter specifies the direction in which the surrounding cells are shifted to make room for the inserted cells. The AMergedCellsConflictResolution parameter specifies the behavior of the InsertCells procedure if the inserted cell range intersects the merged cell area. By default, the Spreadsheet control handles such a conflict by displaying the confirmation dialog window (in the same manner as Excel does):

The following code example inserts the B2:B3 range of uninitialized cells. Neighboring cells are shifted to the right. The Table View worksheet appearance before and after the code execution is shown below.

var
  ATableView: TdxSpreadSheetTableView;
//...
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  ATableView.InsertCells(Rect(1, 1, 1, 2), cmShiftCellsHorizontally);

If the specified (or selected) cell range intersects the array formula result area, the InsertCells procedure raises the EdxSpreadSheetCannotChangePartOfArrayError exception.

Invoking the InsertCells methods has no effect if the CanInsert function returns False.

Note

Since the InsertCells procedures cannot create cell objects, you may also need to invoke the CreateCell function in order to work with the inserted cells.

See Also