{"record":{"id":"dee5f7d0fd9ee25d","repo":"iOfficeAI/OfficeCLI","slug":"column-width-cannot-be-empty","errorCode":null,"errorMessage":"Column width cannot be empty.","messagePattern":"Column width cannot be empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs","lineNumber":168,"sourceCode":"                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.\");\n        var trimmed = value.Trim();\n        double chars;\n        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 'width' value: '{value}'. Expected a finite number (column width in char units, e.g. 8.43).\");\n            chars = bare;\n        }\n        else\n        {\n            try\n            {\n                var emu = OfficeCli.Core.EmuConverter.ParseEmu(trimmed);\n                // 9525 EMU = 1 px; 7 px ≈ 1 char unit (Calibri 11pt MDW baseline)\n                var px = emu / EmuConverter.EmuPerPxF;\n                chars = px / 7.0;","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs#L150-L186","documentation":"Thrown by ParseColWidthChars when the 'width' value for a column is null, empty, or whitespace. The helper normalizes column-width input (bare character units or unit-qualified) into the char-unit value OOXML stores.","triggerScenarios":"Invoking set /Sheet/col[X] --prop width= with an empty value, or passing null/\"\" programmatically to a path that calls ParseColWidthChars.","commonSituations":"Dynamically built prop strings with a missing source field; templating that interpolates an undefined variable; CI runs with --prop width=$WIDTH and WIDTH unset.","solutions":["Provide an explicit width value: a bare number (character units, e.g. 8.43) or unit-qualified (20px, 2cm, 1in, 60pt).","Skip setting width if no value is intended rather than passing an empty string.","Guard with string.IsNullOrWhiteSpace in calling code before invoking the Set path."],"exampleFix":"// before\nset /Sheet1/col[B] --prop width=\n\n// after\nset /Sheet1/col[B] --prop width=12","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(widthValue))\n    throw new ArgumentException(\"Provide a column width (bare char units or e.g. 20px).\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the width prop when no value is intended.","In dynamic prop builders, skip keys whose source field is null or whitespace."],"tags":["excel","validation","column-width","units"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}