iOfficeAI/OfficeCLI · error · ArgumentException

Invalid 'tickLabelSkip' value: '{value}'. Must be an integer

Error message

Invalid 'tickLabelSkip' value: '{value}'. Must be an integer 1..65535 (OOXML ST_Skip).

What it means

The tickLabelSkip setter applies to category axes only (normalizedRole == 'category'). The value is parsed as an integer via SafeParseInt, then range-checked against OOXML ST_Skip: must be 1..65535. A value outside this range is invalid in the schema and would produce a corrupt file. The element is then created as C.TickLabelSkip.

Source

Thrown at src/officecli/Core/Chart/ChartHelper.Axis.cs:615

                    if (normalizedRole != "category") { directlyHandled.Add(key); break; }
                    if (targetAxis is OpenXmlCompositeElement axLo)
                    {
                        axLo.RemoveAllChildren<C.LabelOffset>();
                        axLo.AppendChild(new C.LabelOffset { Val = (ushort)ParseHelpers.SafeParseInt(value, "labelOffset") });
                    }
                    directlyHandled.Add(key);
                    break;
                }

                case "ticklabelskip":
                case "tickskip":
                {
                    if (normalizedRole != "category") { directlyHandled.Add(key); break; }
                    if (targetAxis is OpenXmlCompositeElement axTls)
                    {
                        var tlsVal = ParseHelpers.SafeParseInt(value, "tickLabelSkip");
                        if (tlsVal < 1 || tlsVal > 65535)
                            throw new ArgumentException($"Invalid 'tickLabelSkip' value: '{value}'. Must be an integer 1..65535 (OOXML ST_Skip).");
                        axTls.RemoveAllChildren<C.TickLabelSkip>();
                        axTls.AppendChild(new C.TickLabelSkip { Val = tlsVal });
                    }
                    directlyHandled.Add(key);
                    break;
                }

                case "crossbetween":
                {
                    // Schema: crossBetween only valid on value/value2; on category/series ignore.
                    if (normalizedRole is not ("value" or "value2")) { directlyHandled.Add(key); break; }
                    if (targetAxis is OpenXmlCompositeElement axCb)
                    {
                        axCb.RemoveAllChildren<C.CrossBetween>();
                        var cbVal = value.ToLowerInvariant() switch
                        {
                            "midcat" or "midpoint" => C.CrossBetweenValues.MidpointCategory,
                            _ => C.CrossBetweenValues.Between

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Use an integer in 1..65535: ticklabelskip=2 (show every 2nd label).
  2. Use 1 to show every category label (no skipping).
  3. Note: this only works on category axes — for value axes, it is silently ignored.

Example fix

// before
ticklabelskip=0
// after
ticklabelskip=2
// show every other category label
Defensive patterns

Strategy: validation

Validate before calling

static bool IsValidTickLabelSkip(string value)
{
    if (!int.TryParse(value, out var tlsVal)) return false;
    return tlsVal >= 1 && tlsVal <= 65535;
}

Try / catch

try { axisSetter.Apply("ticklabelskip", value); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Invalid 'tickLabelSkip'"))
{
    Console.Error.WriteLine($"{ex.Message}\nMust be an integer 1..65535.");
}

Prevention

When it happens

Trigger: Setting ticklabelskip or tickskip (alias) to a non-integer or out-of-range value: ticklabelskip=0, ticklabelskip=-1, ticklabelskip=70000, or ticklabelskip=abc. Only fires for the 'category' axis role.

Common situations: Using 0 (which would mean 'skip all labels' — not valid; use 1 for 'show all'). Using a very large value that exceeds the 16-bit unsigned range. Using a non-integer value. Applying to a value axis (silently ignored, does not throw).

Related errors


AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13). Data as JSON: /api/errors/c17e6a7d98001140. Report an issue: GitHub.