iOfficeAI/OfficeCLI · error · ArgumentException
Invalid data value '{trimmed}' in series '{seriesName}'. Exp
Error message
Invalid data value '{trimmed}' in series '{seriesName}'. Expected comma-separated finite numbers (e.g. '1,2,3'). What it means
Thrown by ParseSeriesValues (ChartHelper.cs:511) when a token in a comma-separated series value list fails double.TryParse (invariant culture) or is NaN/Infinity. This guard is shared by the Add path (literal series values) and the dotted seriesN.values path, so both reject non-finite/unparseable tokens consistently. OOXML c:v requires a finite double, so this prevents invalid text from reaching the XML.
Source
Thrown at src/officecli/Core/Chart/ChartHelper.cs:511
properties[dottedKey] = nameVal;
// Remove the flat key so SetChartProperties' dispatch loop
// doesn't also iterate it — the legacy `series{N}=` branch
// does int.TryParse on the suffix ("2Name") and reports it
// as unsupported. TryGetValue above already marked the
// original input consumed for handler-as-truth tracking.
properties.Remove(flatKey);
}
}
}
private static double[] ParseSeriesValues(string valStr, string seriesName)
{
return valStr.Split(',').Select(v =>
{
var trimmed = v.Trim();
if (!double.TryParse(trimmed, System.Globalization.CultureInfo.InvariantCulture, out var num)
|| double.IsNaN(num) || double.IsInfinity(num))
throw new ArgumentException($"Invalid data value '{trimmed}' in series '{seriesName}'. Expected comma-separated finite numbers (e.g. '1,2,3').");
return num;
}).ToArray();
}
internal static string[]? ParseCategories(Dictionary<string, string> properties)
{
if (!properties.TryGetValue("categories", out var catStr)) return null;
// If the value is a cell range reference, don't treat as literal categories
if (IsRangeReference(catStr)) return null;
return catStr.Split(',').Select(c => c.Trim()).ToArray();
}
// BUG-DUMP-R36-3: series indices (0-based) whose dump carried per-point
// <c:dPt> styling (and/or a verbatim series <c:spPr>) but NO series-level
// fill key (series{N}.color / .gradient / .spPr). For these the source had
// no series-level <c:spPr>; the chart builder must therefore NOT inject the
// Office accent1 default — doing so plants a spurious solidFill that a
// partial-dPt series would visibly show. Mirrors the spec "only emit aView on GitHub (pinned to 1ced45e900)
Solutions
- Pass finite numbers with a dot decimal separator: Sales:10,20.5,30.
- Filter NaN/Infinity before serializing the list.
- Use a cell-range reference (series1.values=Sheet1!B2:B4) for workbook-backed data instead of literal numbers.
Example fix
// before series1=Sales:10,abc,30 // after series1=Sales:10,20,30
Defensive patterns
Strategy: validation
Validate before calling
static double[] ValidateSeriesValues(string valStr)
{
return valStr.Split(',').Select(v =>
{
var t = v.Trim();
if (!double.TryParse(t, System.Globalization.CultureInfo.InvariantCulture, out var n) || double.IsNaN(n) || double.IsInfinity(n))
throw new ArgumentException($"invalid value '{t}'");
return n;
}).ToArray();
} Type guard
static bool IsFiniteSeriesValues(string valStr) =>
valStr.Split(',').All(v => double.TryParse(v.Trim(), System.Globalization.CultureInfo.InvariantCulture, out var n) && !double.IsNaN(n) && !double.IsInfinity(n)); Try / catch
try { /* add chart series1=Name:... */ }
catch (ArgumentException ex) when (ex.Message.Contains("Invalid data value"))
{ /* sanitize list: filter NaN/Infinity, fix locale, or switch to cell ref */ } Prevention
- Serialize numbers with invariant culture (dot decimal separator).
- Filter NaN/Infinity before building the comma-separated list.
- Prefer cell-range references over literal lists for workbook-backed data.
When it happens
Trigger: Setting series1=Sales:10,abc,30, data=Q1:1,NaN,3, or a series value list containing a locale-formatted number like '1,5' (which invariant culture reads as two tokens).
Common situations: Forwarding NaN/Infinity from computation; locale decimal separators (European comma) colliding with the comma delimiter; named ranges or text leaking into a literal value list (use a cell reference instead).
Related errors
- Series '{name}' has no data values. Expected format: 'Name:1
- dataRange resolved to 0 series columns: a single-column rang
- Chart requires a 'data' property. Use: data="Series1:1,2,3;S
- series must be added to a chart parent: /SheetName/chart[N]
- Sheet not found: {sheetName}
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/571b72fe52a02f93.
Report an issue: GitHub.