iOfficeAI/OfficeCLI · error · ArgumentException
Invalid 'crosses' value: '{value}'. Valid: autoZero, max, mi
Error message
Invalid 'crosses' value: '{value}'. Valid: autoZero, max, min. What it means
The 'crosses' setter for the secondary value axis (value2 role) accepts only three OOXML C.CrossesValues: autoZero, max, min. The value is lowercased and matched; any other string throws. Validation occurs BEFORE the C.Crosses element is mutated, ensuring atomicity on bad input.
Source
Thrown at src/officecli/Core/Chart/ChartHelper.Axis.cs:326
}
else
{
translated["axismax"] = value;
}
break;
case "crosses":
if (normalizedRole == "value2" && targetAxis is OpenXmlCompositeElement crsAx2)
{
// Same-type only — see ChartHelper.Setter.cs case "crosses"
// for the mutual-remove bug rationale.
// Validate BEFORE mutating (atomicity).
var crossVal = value.ToLowerInvariant() switch
{
"max" => C.CrossesValues.Maximum,
"min" => C.CrossesValues.Minimum,
"autozero" => C.CrossesValues.AutoZero,
_ => throw new ArgumentException($"Invalid 'crosses' value: '{value}'. Valid: autoZero, max, min.")
};
crsAx2.RemoveAllChildren<C.Crosses>();
var newCrosses = new C.Crosses { Val = crossVal };
var crsAnchor = crsAx2.GetFirstChild<C.CrossesAt>() as OpenXmlElement
?? crsAx2.GetFirstChild<C.CrossBetween>() as OpenXmlElement;
if (crsAnchor != null) crsAx2.InsertBefore(newCrosses, crsAnchor);
else crsAx2.AppendChild(newCrosses);
directlyHandled.Add(key);
}
else
{
translated["crosses"] = value;
}
break;
case "crossesat":
if (normalizedRole == "value2" && targetAxis is OpenXmlCompositeElement crsAtAx2)
{View on GitHub (pinned to 1ced45e900)
Solutions
- Use autoZero, max, or min: crosses[value2]=max.
- For the default crossing behavior, use autoZero.
- Note: this path only applies to the value2 role — the primary axis crosses setter is in ChartHelper.Setter.cs.
Example fix
// before crosses[value2]=center // after crosses[value2]=max // or crosses[value2]=autozero
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ValidCrossesValues = new(StringComparer.OrdinalIgnoreCase)
{ "autozero", "max", "min" };
static bool IsValidCrossesValue(string value) => ValidCrossesValues.Contains(value); Try / catch
try { axisSetter.Apply("crosses", value); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Invalid 'crosses' value"))
{
Console.Error.WriteLine($"{ex.Message}\nValid: autoZero, max, min.");
} Prevention
- Use only autoZero, max, or min for the crosses property.
- Validate against the allowed set before passing user input.
- Note that this path only applies to the value2 (secondary) axis role.
When it happens
Trigger: Setting crosses[value2] to an unrecognized value like 'middle', 'center', 'top', 'bottom', or 'none'. Only applies to the value2 role with a concrete OpenXmlCompositeElement axis target.
Common situations: Typing 'auto' instead of 'autoZero'. Using a value valid for a different axis property (e.g. 'next' from CrossesValues.Next, which the library intentionally does not expose). Expecting positional terms like 'top' or 'center' that have no OOXML equivalent.
Related errors
- Invalid baseTimeUnit '{value}': expected days, months, or ye
- Invalid legend position '{posSpec}'. Valid: none, top, botto
- Invalid referenceLine value '{parts[0]}'. Expected: number o
- Invalid referenceLine width '{widthStr}'. Expected a number
- Invalid referenceLine width '{widthPt.ToString("G", System.G
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/cc759cc17628492b.
Report an issue: GitHub.