qax-os/excelize · error
invalid cell reference [%d, %d]
Error message
invalid cell reference [%d, %d]
What it means
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.
Source
Thrown at errors.go:243
return fmt.Errorf("comment already exist on cell %s", cell)
}
// newCellNameToCoordinatesError defined the error message on converts
// alphanumeric cell name to coordinates.
func newCellNameToCoordinatesError(cell string, err error) error {
return fmt.Errorf("cannot convert cell %q to coordinates: %v", cell, err)
}
// newChartTitleError defined the error message on receiving the invalid chart
// title parameters.
func newChartTitleError(name string) error {
return fmt.Errorf("chart title field %s value must be an integer from 0 to 100", name)
}
// newCoordinatesToCellNameError defined the error message on converts [X, Y]
// coordinates to alpha-numeric cell name.
func newCoordinatesToCellNameError(col, row int) error {
return fmt.Errorf("invalid cell reference [%d, %d]", col, row)
}
// newFieldLengthError defined the error message on receiving the field length
// overflow.
func newFieldLengthError(name string) error {
return fmt.Errorf("field %s must be less than or equal to 255 characters", name)
}
// newInvalidAutoFilterColumnError defined the error message on receiving the
// incorrect index of column.
func newInvalidAutoFilterColumnError(col string) error {
return fmt.Errorf("incorrect index of column %q", col)
}
// newInvalidAutoFilterExpError defined the error message on receiving the
// incorrect number of tokens in criteria expression.
func newInvalidAutoFilterExpError(exp string) error {
return fmt.Errorf("incorrect number of tokens in criteria %q", exp)View on GitHub (pinned to f2483381fb)
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
Example fix
// before name, err := excelize.CoordinatesToCellName(col, row) // col,row zero-based // after name, err := excelize.CoordinatesToCellName(col+1, row+1)
Defensive patterns
Strategy: validation
Validate before calling
func validCoords(col, row int) bool { return col >= 1 && row >= 1 } Type guard
func safeCellName(col, row int) (string, error) {
if col < 1 || row < 1 { return "", fmt.Errorf("coords must be >=1") }
return excelize.CoordinatesToCellName(col, row)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- cannot convert cell %q to coordinates: %v
- coordinates length must be 4
- data validation range exceeds limit
- the same name already exists on the scope
- no defined name on the scope
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/39ccbe4bb756c757.
Report an issue: GitHub.