iOfficeAI/OfficeCLI · error · ArgumentException
Row height cannot be empty.
Error message
Row height cannot be empty.
What it means
Thrown by ParseRowHeightPoints when the 'height' value passed to a row property is null, empty, or whitespace. The helper is the single entry point that normalizes row-height input (bare points or unit-qualified) into the points value OOXML stores.
Source
Thrown at src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs:128
"dk2" or "tx2" or "dark2" or "text2" => 3u,
"accent1" => 4u,
"accent2" => 5u,
"accent3" => 6u,
"accent4" => 7u,
"accent5" => 8u,
"accent6" => 9u,
"hlink" or "hyperlink" => 10u,
"folhlink" or "followedhyperlink" => 11u,
_ => null
};
// CONSISTENCY(rc-units): Row height is in points in OOXML; this helper
// accepts bare numbers (treated as points, backward compat) as well as
// unit-qualified "40pt", "40px", "1cm", "0.5in" and returns points.
internal static double ParseRowHeightPoints(string value)
{
if (string.IsNullOrWhiteSpace(value))
throw new ArgumentException("Row height cannot be empty.");
var trimmed = value.Trim();
double pts;
// Bare number → points (legacy behavior)
if (double.TryParse(trimmed, System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture, out var bare)
&& !char.IsLetter(trimmed[^1]))
{
if (double.IsNaN(bare) || double.IsInfinity(bare))
throw new ArgumentException($"Invalid 'height' value: '{value}'. Expected a finite number (row height in points, e.g. 15.75).");
pts = bare;
}
else
{
// Unit-qualified: convert via EMU then back to points.
try
{
var emu = OfficeCli.Core.EmuConverter.ParseEmu(trimmed);
pts = emu / EmuConverter.EmuPerPointF;View on GitHub (pinned to 1ced45e900)
Solutions
- Provide an explicit height value: a bare number (points) or a unit-qualified string (40pt, 40px, 1cm, 0.5in).
- Skip setting height entirely if no value is intended rather than passing an empty string.
- In calling code, guard with string.IsNullOrWhiteSpace(value) before invoking the Set path.
Example fix
// before set /Sheet1/row[5] --prop height= // after set /Sheet1/row[5] --prop height=15.75 // or unit-qualified set /Sheet1/row[5] --prop height=20pt
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(heightValue))
throw new ArgumentException("Provide a row height (bare points or e.g. 20pt)."); Prevention
- Skip the height prop entirely when no value is intended instead of passing an empty string.
- In dynamic prop builders, omit keys whose source field is null or whitespace.
When it happens
Trigger: Invoking set /Sheet/row[N] --prop height= with an empty value, or passing null/"" programmatically to a code path that calls ParseRowHeightPoints (the row Set handler, batch emitters, or import helpers).
Common situations: An agent or script that builds the prop string dynamically leaving height blank when a source field is missing; templating code that interpolates an undefined variable; CI runs that pass --prop height=$HEIGHT with HEIGHT unset.
Related errors
- Invalid 'height' value: '{value}'. Expected a finite number
- Property 'sqref' (or 'range'/'ref') is required for validati
- Expected a non-negative cell index or a unit-qualified offse
- Expected an integer cell count or a unit-qualified size (e.g
- Expected an integer cell index or a unit-qualified offset (e
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/16b3ae8db1dbcf54.
Report an issue: GitHub.