{"record":{"id":"b98785b6903e175d","repo":"iOfficeAI/OfficeCLI","slug":"table-name-name-looks-like-a-cell-reference-e","errorCode":null,"errorMessage":"Table name '{name}' looks like a cell reference; Excel refuses to open files with such table names. Choose a name like '{name}_'.","messagePattern":"Table name '(.+?)' looks like a cell reference; Excel refuses to open files with such table names\\. Choose a name like '(.+?)_'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.TableStyle.cs","lineNumber":64,"sourceCode":"            if (System.Text.RegularExpressions.Regex.IsMatch(name, @\"^[Tt][Bb][Ll]\\d+$\"))\n                throw new ArgumentException(\n                    $\"Table name '{name}' matches Excel's internal Tbl{{N}} naming pattern and is rejected by Mac Excel. Use 'Table{{N}}' (default) or a descriptive name like 'SalesData'.\");\n            // Excel enforces defined-name grammar on table names: identifier\n            // chars only (no spaces), must not parse as an A1/R1C1 cell\n            // reference. Violations pass schema validation but real Excel\n            // refuses the whole file (0x800A03EC) — reject up front, same\n            // rule set as the namedrange validator.\n            // \"Letter\" is any Unicode letter (\\p{L}) — Excel accepts CJK/\n            // Cyrillic table names (same identifier grammar as defined\n            // names, whose validator was widened the same way).\n            if (!System.Text.RegularExpressions.Regex.IsMatch(name, @\"^[\\p{L}_\\\\][\\p{L}\\p{N}._\\\\]*$\"))\n                throw new ArgumentException(\n                    $\"Table name '{name}' is not a valid Excel name: use letters, digits, '.' or '_' only, starting with a letter or '_' (no spaces). Excel refuses to open files with other table names.\");\n            if (LooksLikeCellReference(name)\n                || System.Text.RegularExpressions.Regex.IsMatch(name, @\"^[Rr]\\d+[Cc]\\d+$\")\n                || name.Equals(\"R\", StringComparison.OrdinalIgnoreCase)\n                || name.Equals(\"C\", StringComparison.OrdinalIgnoreCase))\n                throw new ArgumentException(\n                    $\"Table name '{name}' looks like a cell reference; Excel refuses to open files with such table names. Choose a name like '{name}_'.\");\n            return name;\n        }\n        var looksLikeRef = LooksLikeCellReference(name)\n            || System.Text.RegularExpressions.Regex.IsMatch(name, @\"^[0-9]+$\");\n        return looksLikeRef ? name + \"_\" : name;\n    }\n\n    // T6 — built-in Excel table style names. Unknown names are rejected at\n    // Add time rather than silently passed through to Excel.\n    private static readonly HashSet<string> _builtInTableStyles = BuildBuiltInTableStyles();\n    private static HashSet<string> BuildBuiltInTableStyles()\n    {\n        var set = new HashSet<string>(StringComparer.Ordinal);\n        foreach (var tier in new[] { \"Light\", \"Medium\", \"Dark\" })\n            for (int i = 1; i <= 28; i++)\n                set.Add($\"TableStyle{tier}{i}\");\n        // Pivot styles — users may apply a pivot style to a plain table.","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.TableStyle.cs#L46-L82","documentation":"Thrown by the table-name validator (userProvided=true) when the name looks like an A1 or R1C1 cell reference (e.g. 'A1', 'R2C3'), or equals 'R'/'C' (single-letter reserved column refs). Excel refuses to open files with such table names (0x800A03EC).","triggerScenarios":"Calling an add-table API with name='A1', name='C5', name='R2C3', name='R', or name='C'. LooksLikeCellReference plus the R1C1 pattern and single-letter R/C all trigger.","commonSituations":"Generating table names from short codes that happen to be cell refs; user input that matches A1 shape; copying Excel's own short identifiers.","solutions":["Append a non-numeric suffix: 'A1' → 'A1Data' or 'A1_'.","Avoid single-letter 'R' or 'C' as names.","Use the validationCode guard before submitting."],"exampleFix":"// before\nstring name = \"A1\"; // looks like cell A1\n// after\nstring name = \"A1_Data\";\n// or pick a descriptive name:\nstring name = \"Region1Table\";","handlingStrategy":"validation","validationCode":"// Reject names that look like cell references\nstatic bool LooksLikeRef(string name)\n    => name.Equals(\"R\", StringComparison.OrdinalIgnoreCase)\n       || name.Equals(\"C\", StringComparison.OrdinalIgnoreCase)\n       || System.Text.RegularExpressions.Regex.IsMatch(name ?? \"\", @\"^[Rr]\\d+[Cc]\\d+$\")\n       /* LooksLikeCellReference handles A1-style internally */;","typeGuard":"null","tryCatchPattern":"try { /* add table */ }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"looks like a cell reference\"))\n{ name = name + \"_\"; /* the message itself suggests this suffix */ }","preventionTips":["Avoid A1-shaped and R1C1-shaped names for tables.","'R' and 'C' alone are reserved.","When in doubt, append a non-numeric suffix."],"tags":["tables","excel","naming","cell-reference"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}