{"record":{"id":"dfdcf661d2348491","repo":"iOfficeAI/OfficeCLI","slug":"invalid-font-size-szval-excel-font-size-must","errorCode":null,"errorMessage":"Invalid font size: '{szVal}'. Excel font size must be <= 409pt.","messagePattern":"Invalid font size: '(.+?)'\\. Excel font size must be <= 409pt\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/ExcelStyleManager.cs","lineNumber":981,"sourceCode":"        else if (fontProps.TryGetValue(\"vertalign\", out var vaVal))\n            vertAlign = vaVal.ToLowerInvariant() is \"superscript\" or \"subscript\" ? vaVal.ToLowerInvariant() : null;\n        else if (baseVertAlign?.Val?.Value == VerticalAlignmentRunValues.Superscript)\n            vertAlign = \"superscript\";\n        else if (baseVertAlign?.Val?.Value == VerticalAlignmentRunValues.Subscript)\n            vertAlign = \"subscript\";\n        else\n            vertAlign = null;\n        double size;\n        if (fontProps.TryGetValue(\"size\", out var szVal))\n        {\n            size = ParseHelpers.ParseFontSize(szVal);\n            // R39-4: Excel UI caps font size at 409pt (ECMA-376 §17.4.18).\n            // Values above silently render as default 11pt or open broken.\n            // The lower bound (>0) is enforced in ParseFontSize; upper\n            // bound is Excel-specific so it lives here, not in the shared\n            // helper (Word/PPT have far higher limits).\n            if (size > 409)\n                throw new ArgumentException(\n                    $\"Invalid font size: '{szVal}'. Excel font size must be <= 409pt.\");\n        }\n        else\n        {\n            size = baseFont.FontSize?.Val?.Value ?? 11;\n        }\n        string name = fontProps.GetValueOrDefault(\"name\",\n            baseFont.FontName?.Val?.Value ?? OfficeDefaultFonts.MinorLatin);\n        // CONSISTENCY(scheme-color): font.color accepts scheme names\n        // (\"accent1\"-\"accent6\", \"lt1\"/\"dk1\", \"hlink\", etc.) per the project conventions.\n        // When matched, store as <color theme=\"N\"/> instead of rgb.\n        string? color;\n        uint? colorTheme = null;\n        if (fontProps.TryGetValue(\"color\", out var cVal))\n        {\n            var schemeIdx = OfficeCli.Handlers.ExcelHandler.ExcelSchemeColorNameToThemeIndex(cVal);\n            if (schemeIdx.HasValue)\n            {","sourceCodeStart":963,"sourceCodeEnd":999,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/ExcelStyleManager.cs#L963-L999","documentation":"Thrown when an Excel font size is greater than 409pt. Excel's UI caps font size at 409pt (ECMA-376 §17.4.18); larger values render silently as the default 11pt or open broken. The lower bound (>0) is enforced in the shared ParseFontSize helper, while this Excel-specific upper bound lives in the Excel style manager.","triggerScenarios":"Calling an Excel style/font API with font size (size=... or sz) parsed to a double > 409. The value is first parsed by ParseHelpers.ParseFontSize (which rejects <=0), then checked here for the upper bound.","commonSituations":"Passing size in the wrong unit (e.g. pixels or a scaled value) that overruns 409; a config/default that multiplies a base size; user input not clamped.","solutions":["Clamp or correct the font size to the 1..409 range before setting it.","Check the unit: Excel font size is in points, not pixels.","If a larger size is genuinely needed, this is an Excel hard limit — redesign the layout instead."],"exampleFix":"// before\nfontProps[\"size\"] = \"600\"; // > 409pt\n// after\nfontProps[\"size\"] = Math.Min(requestedSize, 409).ToString();","handlingStrategy":"validation","validationCode":"static double ClampFontSize(string szVal)\n{\n    var sz = ParseHelpers.ParseFontSize(szVal);\n    return sz > 409 ? 409 : sz;\n}","typeGuard":null,"tryCatchPattern":"try { SetFont(size: requested); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"<= 409pt\"))\n{ SetFont(size: 409); }","preventionTips":["Clamp user/config font sizes to 1..409 before passing.","Confirm the unit is points, not pixels."],"tags":["excel","font","validation","ecma-376"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}