A copy puts two formats on the clipboard at once.
| Format | What it is for |
|---|---|
| TSV (tab-separated text) | Interoperating with Excel, text editors and the rest |
HTML carrying data-rg-* attributes | ReoGrid to ReoGrid (styles, formulas and merges survive) |
The paste side prefers the HTML when it is there and falls back to interpreting the TSV. reogrid-web (the web edition) uses the same scheme, so pasting between the two works.
The file format (reogrid-json) is never used on the clipboard.
From the UI
| Member | What it does |
|---|---|
control.CopySelection() | Copies the selection |
control.CutSelection() | Cuts |
control.PasteClipboard() | Pastes |
Ctrl+C / Ctrl+X / Ctrl+V are wired up by default.
From the API
using unvell.ReoGrid.Core.Clipboard;
// turn the selection into TSV (ready to paste into Excel or a text editor)
string tsv = RangeClipboard.BuildTsv(ws, RangePosition.Parse("A1:C10"));
// read TSV in
ClipboardRangeData data = RangeClipboard.ParseTsv(tsv);
RangePosition pasted = RangeClipboard.Apply(ws, startRow: 20, startCol: 0, data);
These never touch the system clipboard, so they work headless too.
Inspecting what was parsed
Console.WriteLine($"{data.Rows} x {data.Columns}");
// styles and formulas come back too when the HTML was written by ReoGrid
if (data.IsReoGridSource)
Console.WriteLine($"anchor = {data.SourceAnchorRow},{data.SourceAnchorCol}");
ClipboardCellData? cell = data.Cells[0][0];
if (cell != null)
Console.WriteLine($"{cell.Value} fmt={cell.NumberFormat} span={cell.RowSpan}x{cell.ColSpan}");
What ClipboardCellData carries.
| Property | What it is |
|---|---|
Value | The input string (a formula when it starts with =) |
NumberFormat | The number format |
Style | The style |
RichText | Rich text |
CellType | The cell type’s settings |
RowSpan / ColSpan | Merging |
Parsed from TSV, only Value is filled in.
Relative references offset automatically
Copying a cell containing a formula and pasting it elsewhere shifts the relative references to suit the destination. Same as Excel and V4.
C1 holds "=A1*B1"; copy C1 and paste at C5
-> C5 becomes "=A5*B5"
What makes this work is the anchor information in the HTML (SourceAnchorRow /
SourceAnchorCol). Because the source position is recorded, references can be shifted by
exactly the difference to the paste position.
References pinned with $ do not move. A reference that would leave the sheet becomes
#REF!.
Interoperating with Excel
| Direction | What survives |
|---|---|
| Excel → ReoGrid | values, as TSV |
| ReoGrid → Excel | values, as TSV |
| ReoGrid → ReoGrid | styles, formulas and merges too, via HTML |
| reogrid-web → ReoGrid One | via HTML (the same attribute format) |
Undo
Pasting is recorded in the history. A two-step operation such as cut-then-paste undoes as a single step.