{"record":{"id":"8e742d85a4867b96","repo":"iOfficeAI/OfficeCLI","slug":"source-range-has-no-data-8e742d","errorCode":null,"errorMessage":"Source range has no data","messagePattern":"Source range has no data","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/PivotTableHelper.cs","lineNumber":958,"sourceCode":"        // CONSISTENCY(thread-static-pivot-opts): same pattern — grand totals\n        // options reach item builders, geometry, and every renderer via\n        // ActiveRowGrandTotals/ActiveColGrandTotals.\n        using var _gtScope = PushGrandTotalsOptions(properties);\n        // CONSISTENCY(thread-static-pivot-opts): same pattern for subtotals.\n        using var _subScope = PushSubtotalsOptions(properties);\n        // CONSISTENCY(thread-static-pivot-opts): same pattern for layout mode.\n        using var _layoutScope = PushLayoutMode(properties);\n        // CONSISTENCY(thread-static-pivot-opts): same pattern for repeatItemLabels.\n        using var _repeatScope = PushRepeatItemLabels(properties);\n        // CONSISTENCY(thread-static-pivot-opts): same pattern for insertBlankRow.\n        using var _blankRowScope = PushInsertBlankRow(properties);\n        // CONSISTENCY(thread-static-pivot-opts): same pattern for grandTotalCaption.\n        using var _captionScope = PushGrandTotalCaption(properties);\n\n        // 1. Read source data to build cache\n        var (headers, columnData, columnStyleIds) = ReadSourceData(sourceSheet, sourceRef);\n        if (headers.Length == 0)\n            throw new ArgumentException(\"Source range has no data\");\n        // CONSISTENCY(empty-pivot-source): a header row with zero data rows\n        // (e.g. A1:D1) silently produces an empty pivot whose cache has no\n        // records — Excel opens it but renders nothing. Reject it with the\n        // same family of ArgumentException as the no-headers case so callers\n        // get a single, predictable error path. Bt#8 / fuzzer baseline.\n        if (columnData.Count == 0 || columnData[0].Length == 0)\n            throw new ArgumentException(\"Source range has no data rows\");\n\n        // 1b. Date auto-grouping preprocessing. Scans rows/cols/filters props\n        // for `fieldName:grouping` syntax (e.g. `rows='日期:month,城市'`) and\n        // creates a new virtual column per grouped field containing the\n        // bucketed labels. The raw field spec is rewritten to reference the\n        // new virtual column so ParseFieldList below sees a clean name.\n        //\n        // Supported groupings:\n        //   :year    → \"2024\"\n        //   :quarter → \"2024-Q1\"\n        //   :month   → \"2024-01\"","sourceCodeStart":940,"sourceCodeEnd":976,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/PivotTableHelper.cs#L940-L976","documentation":"Thrown by CreatePivotTable (the Add path) after ReadSourceData(sourceSheet, sourceRef) returns an empty headers array. The source range specified at pivot creation produced no header row — the top row of the range is entirely empty or the range resolves to nothing. This is the same check as error 343 but on the creation path rather than the refresh path.","triggerScenarios":"Calling Add pivot source=Sheet1!A1:D10 where row 1 (the header row) is completely blank. Or a malformed range reference that ReadSourceData cannot interpret, yielding zero headers.","commonSituations":"Pointing the source at the wrong area of a sheet; headers are on a different row than the range's top; data was cleared; off-by-one in the range coordinates.","solutions":["Ensure the range's first row contains at least one non-empty cell as the header.","Verify the range top-left cell is the first header column.","Check the range syntax matches the expected format (e.g. A1:D10).","If data moved, point the source at the new location."],"exampleFix":"// before — headers are on row 2, range starts at row 1\nAdd pivot source=Sheet1!A1:D10 name='P'\n// after\nAdd pivot source=Sheet1!A2:D10 name='P'","handlingStrategy":"validation","validationCode":"// Before Add pivot, confirm the range has headers\nvar (testHeaders, _, _) = ReadSourceData(sourceSheet, sourceRef);\nif (testHeaders.Length == 0)\n    throw new ArgumentException($\"Source range {sourceRef} has no header data.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the range's first row contains populated header cells.","Confirm the top-left cell of the range is the first header.","Check range coordinates for off-by-one errors."],"tags":["pivot","excel","source-range","empty-data","create"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}