iOfficeAI/OfficeCLI · error · ArgumentException
Move not supported for: {elementRef}. Supported: row[N], col
Error message
Move not supported for: {elementRef}. Supported: row[N], col[L] What it means
Thrown at the end of Move when elementRef (the second path segment) matches neither row[N] nor col[L]. Move supports only whole-row and whole-column relocations; any other element shape (cells, ranges, charts, tables) is unsupported and the method refuses to guess.
Source
Thrown at src/officecli/Handlers/Excel/ExcelHandler.Add.cs:542
}
}
// Sort col entries ascending for OOXML schema validity.
var sortedCols = columns.Elements<Column>()
.OrderBy(c => c.Min?.Value ?? 0).ToList();
columns.RemoveAllChildren<Column>();
foreach (var c in sortedCols) columns.AppendChild(c);
}
// Remap formulas + range-bearing structures via the col shifter.
ApplyColRenumberToSheet(worksheet, sheetName, colMap);
DeleteCalcChainIfPresent();
SaveWorksheet(worksheet);
int newSrcIdx = colMap[srcColIdx];
return $"/{sheetName}/col[{IndexToColumnName(newSrcIdx)}]";
}
throw new ArgumentException($"Move not supported for: {elementRef}. Supported: row[N], col[L]");
}
/// <summary>
/// Build {old → new} row-index map from a snapshot taken before the
/// move + renumber. Rows whose old and new index match are omitted (the
/// shifter treats absent keys as no-op).
/// </summary>
private static Dictionary<int, int> BuildRowRenumberMap(Dictionary<Row, int> oldIdxByRow)
{
var map = new Dictionary<int, int>(oldIdxByRow.Count);
foreach (var (row, oldIdx) in oldIdxByRow)
{
int newIdx = (int)(row.RowIndex?.Value ?? 0u);
if (newIdx != 0 && newIdx != oldIdx)
map[oldIdx] = newIdx;
}
return map;
}View on GitHub (pinned to 1ced45e900)
Solutions
- Restrict Move to row[N] or col[L] element paths.
- To relocate a cell's value, use Set/copy semantics or move the enclosing row/column instead.
- Validate elementRef against ^(row\[\d+\]|col\[[A-Za-z]+\])$ before calling Move.
Example fix
// before
h.Move("/Sheet1/A1", null, InsertPosition.AtIndex(0)); // cell not supported
// after
h.Move("/Sheet1/row[1]", null, InsertPosition.AtIndex(0)); // move the whole row Defensive patterns
Strategy: validation
Validate before calling
var elementRef = sourcePath.TrimStart('/').Split('/', 2)[1];
if (!System.Text.RegularExpressions.Regex.IsMatch(elementRef, @"^(row\[\d+\]|col\[[A-Za-z]+\])$"))
throw new NotSupportedException($"Move only supports row[N] or col[L]; got '{elementRef}'"); Type guard
static bool IsSupportedMoveElement(string path)
{
var segs = path.TrimStart('/').Split('/', 2);
return segs.Length >= 2
&& System.Text.RegularExpressions.Regex.IsMatch(segs[1], @"^(row\[\d+\]|col\[[A-Za-z]+\])$");
} Prevention
- Restrict Move paths to row[N] / col[L]; never cells or ranges.
- Gate Move with a supported-element regex.
- Use Set/copy semantics to relocate cell values, not Move.
When it happens
Trigger: Move("/Sheet1/cell[A1]"), Move("/Sheet1/A1:B2"), or Move("/Sheet1/chart1"); a path whose element segment is a cell reference or an unsupported object.
Common situations: Assuming Move works on cells (it does not; use Set/cut-paste instead); passing a query-selector fragment as a path; copy-paste of a cell range into Move.
Related errors
- Sheet not found: {sheetName}
- Property 'sqref' (or 'range'/'ref') is required for validati
- Workbook has no sheets element
- After anchor not found: {position.After}
- Before anchor not found: {position.Before}
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/f2e0208603fa76aa.
Report an issue: GitHub.