{"record":{"id":"39ccbe4bb756c757","repo":"qax-os/excelize","slug":"invalid-cell-reference-d-d","errorCode":null,"errorMessage":"invalid cell reference [%d, %d]","messagePattern":"invalid cell reference \\[(.+?), (.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":243,"sourceCode":"\treturn fmt.Errorf(\"comment already exist on cell %s\", cell)\n}\n\n// newCellNameToCoordinatesError defined the error message on converts\n// alphanumeric cell name to coordinates.\nfunc newCellNameToCoordinatesError(cell string, err error) error {\n\treturn fmt.Errorf(\"cannot convert cell %q to coordinates: %v\", cell, err)\n}\n\n// newChartTitleError defined the error message on receiving the invalid chart\n// title parameters.\nfunc newChartTitleError(name string) error {\n\treturn fmt.Errorf(\"chart title field %s value must be an integer from 0 to 100\", name)\n}\n\n// newCoordinatesToCellNameError defined the error message on converts [X, Y]\n// coordinates to alpha-numeric cell name.\nfunc newCoordinatesToCellNameError(col, row int) error {\n\treturn fmt.Errorf(\"invalid cell reference [%d, %d]\", col, row)\n}\n\n// newFieldLengthError defined the error message on receiving the field length\n// overflow.\nfunc newFieldLengthError(name string) error {\n\treturn fmt.Errorf(\"field %s must be less than or equal to 255 characters\", name)\n}\n\n// newInvalidAutoFilterColumnError defined the error message on receiving the\n// incorrect index of column.\nfunc newInvalidAutoFilterColumnError(col string) error {\n\treturn fmt.Errorf(\"incorrect index of column %q\", col)\n}\n\n// newInvalidAutoFilterExpError defined the error message on receiving the\n// incorrect number of tokens in criteria expression.\nfunc newInvalidAutoFilterExpError(exp string) error {\n\treturn fmt.Errorf(\"incorrect number of tokens in criteria %q\", exp)","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L225-L261","documentation":"newCoordinatesToCellNameError is returned when converting [col, row] integer coordinates back to an alphanumeric cell name fails because the coordinates are out of Excel's valid range (col/row must be >= 1 and within limits). CoordinatesToCellName checks the bounds and reports the offending pair in the message.","triggerScenarios":"excelize.CoordinatesToCellName(0, 1) (zero or negative indices), or coordinates beyond max column/row limits; also reached indirectly through pivot shared item extraction, sheet search, slicers, and 3D-reference code that compute coordinates.","commonSituations":"Zero-based loops around one-based Excel coordinates (off-by-one); using array indices directly as row/col; data tables whose computed extents overflow the sheet limits.","solutions":["Convert to 1-based before calling: CoordinatesToCellName(col+1, row+1) for zero-based data","Guard with col >= 1 && row >= 1 and check against MaxColumns/MaxRows before conversion","Fix loops or offset math that produced the invalid index"],"exampleFix":"// before\nname, err := excelize.CoordinatesToCellName(col, row) // col,row zero-based\n// after\nname, err := excelize.CoordinatesToCellName(col+1, row+1)","handlingStrategy":"validation","validationCode":"func validCoords(col, row int) bool { return col >= 1 && row >= 1 }","typeGuard":"func safeCellName(col, row int) (string, error) {\n\tif col < 1 || row < 1 { return \"\", fmt.Errorf(\"coords must be >=1\") }\n\treturn excelize.CoordinatesToCellName(col, row)\n}","tryCatchPattern":null,"preventionTips":["Remember Excel coordinates are 1-based; add 1 when converting from zero-based indices","Check col/row >= 1 (and max limits) before CoordinatesToCellName","Use CellNameToCoordinates/CoordinatesToCellName round-trips in tests to catch off-by-one bugs"],"tags":["excelize","coordinates","off-by-one","cell-reference"],"backgroundTag":"invalid-cell-reference","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}