{"record":{"id":"53fa72effa8b4659","repo":"iOfficeAI/OfficeCLI","slug":"invalid-height-value-value-expected-a-fini-53fa72","errorCode":null,"errorMessage":"Invalid 'height' value: '{value}'. Expected a finite number or unit-qualified value (e.g. 15.75, 40pt, 40px, 1cm, 0.5in).","messagePattern":"Invalid 'height' value: '(.+?)'\\. Expected a finite number or unit-qualified value \\(e\\.g\\. 15\\.75, 40pt, 40px, 1cm, 0\\.5in\\)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs","lineNumber":150,"sourceCode":"        if (double.TryParse(trimmed, System.Globalization.NumberStyles.Float,\n                System.Globalization.CultureInfo.InvariantCulture, out var bare)\n            && !char.IsLetter(trimmed[^1]))\n        {\n            if (double.IsNaN(bare) || double.IsInfinity(bare))\n                throw new ArgumentException($\"Invalid 'height' value: '{value}'. Expected a finite number (row height in points, e.g. 15.75).\");\n            pts = bare;\n        }\n        else\n        {\n            // Unit-qualified: convert via EMU then back to points.\n            try\n            {\n                var emu = OfficeCli.Core.EmuConverter.ParseEmu(trimmed);\n                pts = emu / EmuConverter.EmuPerPointF;\n            }\n            catch (Exception ex)\n            {\n                throw new ArgumentException($\"Invalid 'height' value: '{value}'. Expected a finite number or unit-qualified value (e.g. 15.75, 40pt, 40px, 1cm, 0.5in).\", ex);\n            }\n        }\n        // DEFERRED(xlsx/row-height-validation) RC2: Excel row height is bounded\n        // [0, 409.5] points. Values outside this range are rejected by Excel at\n        // open time (file silently repaired), so validate at Set time.\n        if (pts < 0 || pts > 409.5)\n            throw new ArgumentException($\"Invalid 'height' value: '{value}'. Row height must be between 0 and 409.5 points.\");\n        return pts;\n    }\n\n    // CONSISTENCY(rc-units): Column width is in \"maximum digit width\" char\n    // units (Calibri 11pt ≈ 7px per char). Accepts bare number (char units,\n    // legacy) or unit-qualified px/cm/in/pt — physical sizes converted via\n    // the 7-px-per-char approximation Excel uses internally.\n    internal static double ParseColWidthChars(string value)\n    {\n        if (string.IsNullOrWhiteSpace(value))\n            throw new ArgumentException(\"Column width cannot be empty.\");","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs#L132-L168","documentation":"Thrown by ParseRowHeightPoints when the input is unit-qualified (the last char is a letter) but EmuConverter.ParseEmu rejected it. The inner exception is preserved, so the true cause (unknown unit, non-numeric magnitude, or a font-context unit like 'em') is in ex.InnerException.","triggerScenarios":"Passing height=40ft, height=2em, height=10mn (typo of mm), height=abc pt, or a unit-qualified string whose numeric prefix fails to parse.","commonSituations":"AI assistants reach for CSS units ('em','rem','vh'); typoed suffixes; locale comma decimals in the numeric prefix ('1,5cm'); mixing the helper's accepted set (pt/px/cm/in/mm) with units EmuConverter does not support.","solutions":["Use a supported unit for row height: pt, px, cm, in, mm (e.g. height=20pt, height=40px, height=1cm).","Inspect the inner exception message for the precise reason and correct the unit or numeric prefix accordingly.","Use a dot decimal separator in the numeric prefix."],"exampleFix":"// before\nset /Sheet1/row[5] --prop height=2em\n\n// after (row height has no font context -> convert em to pt yourself, e.g. 2em at 11pt ≈ 22pt)\nset /Sheet1/row[5] --prop height=22pt","handlingStrategy":"try-catch","validationCode":"static readonly Regex RowHeightRe = new(@\"^\\s*-?\\d+(\\.\\d+)?\\s*(pt|px|cm|mm|in)?\\s*$\", RegexOptions.IgnoreCase);\nstatic bool IsValidRowHeight(string v) => !string.IsNullOrWhiteSpace(v) && RowHeightRe.IsMatch(v);","typeGuard":null,"tryCatchPattern":"try { var pts = ExcelHandler.ParseRowHeightPoints(value); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"'height'\"))\n{ /* inspect ex.InnerException for the EmuConverter reason */ }","preventionTips":["Restrict row-height units to pt/px/cm/in/mm; 'em'/'rem' need a font context this API does not have.","Use a dot decimal separator in the numeric prefix.","When unit-qualified parsing fails, read the inner exception for the precise cause."],"tags":["excel","validation","row-height","units"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}