iOfficeAI/OfficeCLI · error · ArgumentException

Unknown icon set name: '{name}'. Valid names: 3Arrows, 3Arro

Error message

Unknown icon set name: '{name}'. Valid names: 3Arrows, 3ArrowsGray, 3Flags, 3TrafficLights1, 3TrafficLights2, 3Signs, 3Symbols, 3Symbols2, 4Arrows, 4ArrowsGray, 4Rating, 4RedToBlack, 4TrafficLights, 5Arrows, 5ArrowsGray, 5Rating, 5Quarters

What it means

ParseIconSetValues lowercases the icon-set name and switches over the OOXML IconSetValues set; an unmatched name throws. The valid list mirrors the enum (3/4/5-prefixed names). GetIconCount infers the bucket count from the leading digit, so a typo both fails here and would miscount if it slipped through. Called from Add icon-set conditional format (Add.Cf.cs:383) and Set iconset (Set.Tables.cs:880). Matching is case-insensitive.

Source

Thrown at src/officecli/Handlers/Excel/ExcelHandler.Helpers.ConditionalFormat.cs:181

        {
            "3arrows" => IconSetValues.ThreeArrows,
            "3arrowsgray" => IconSetValues.ThreeArrowsGray,
            "3flags" => IconSetValues.ThreeFlags,
            "3trafficlights1" => IconSetValues.ThreeTrafficLights1,
            "3trafficlights2" => IconSetValues.ThreeTrafficLights2,
            "3signs" => IconSetValues.ThreeSigns,
            "3symbols" => IconSetValues.ThreeSymbols,
            "3symbols2" => IconSetValues.ThreeSymbols2,
            "4arrows" => IconSetValues.FourArrows,
            "4arrowsgray" => IconSetValues.FourArrowsGray,
            "4rating" => IconSetValues.FourRating,
            "4redtoblack" => IconSetValues.FourRedToBlack,
            "4trafficlights" => IconSetValues.FourTrafficLights,
            "5arrows" => IconSetValues.FiveArrows,
            "5arrowsgray" => IconSetValues.FiveArrowsGray,
            "5rating" => IconSetValues.FiveRating,
            "5quarters" => IconSetValues.FiveQuarters,
            _ => throw new ArgumentException($"Unknown icon set name: '{name}'. Valid names: 3Arrows, 3ArrowsGray, 3Flags, 3TrafficLights1, 3TrafficLights2, 3Signs, 3Symbols, 3Symbols2, 4Arrows, 4ArrowsGray, 4Rating, 4RedToBlack, 4TrafficLights, 5Arrows, 5ArrowsGray, 5Rating, 5Quarters")
        };
    }

    private static int GetIconCount(string name)
    {
        var lower = name.ToLowerInvariant();
        if (lower.StartsWith("5")) return 5;
        if (lower.StartsWith("4")) return 4;
        return 3;
    }

    /// <summary>
    /// Build a <x:font> child for a dxf (differentialFormat) from font.* sub-props.
    /// Supports bold, italic, underline (single/double), strike, size, name, color.
    /// Returns null if no font sub-props were supplied.
    /// </summary>
    internal static Font? BuildFormulaCfFont(Dictionary<string, string> properties)
    {

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Use an exact name from the valid list (case-insensitive, e.g. '3TrafficLights1').
  2. Omit iconset to accept the default '3TrafficLights1'.
  3. Round-trip via Get on an existing rule to see the canonical name string.
  4. Validate against a whitelist before calling Add/Set.

Example fix

// before
props["iconset"] = "3trafficlight1";  // typo -> throw

// after
props["iconset"] = "3TrafficLights1";
// or simply omit for the default
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<string> ValidIconSets = new(StringComparer.OrdinalIgnoreCase)
{ "3Arrows","3ArrowsGray","3Flags","3TrafficLights1","3TrafficLights2","3Signs",
  "3Symbols","3Symbols2","4Arrows","4ArrowsGray","4Rating","4RedToBlack",
  "4TrafficLights","5Arrows","5ArrowsGray","5Rating","5Quarters" };

if (!ValidIconSets.Contains(name))
    throw new ArgumentException($"Unknown icon set '{name}'. Valid: {string.Join(", ", ValidIconSets)}");

Type guard

static bool IsValidIconSet(string name) =>
    (new[] { "3Arrows","3ArrowsGray","3Flags","3TrafficLights1","3TrafficLights2","3Signs",
      "3Symbols","3Symbols2","4Arrows","4ArrowsGray","4Rating","4RedToBlack",
      "4TrafficLights","5Arrows","5ArrowsGray","5Rating","5Quarters" })
    .Contains(name, StringComparer.OrdinalIgnoreCase);

Prevention

When it happens

Trigger: iconset=3trafficlight1 (typo, missing 's'); iconset=trafficlights; iconset=3Emojis (a name from a newer Excel not in the enum); iconset=three-arrows.

Common situations: Hand-typed name with wrong casing/spacing; locale formatting; icon set introduced in a newer Excel version than the OpenXML SDK enum covers.

Related errors


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