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

  1. Convert to 1-based before calling: CoordinatesToCellName(col+1, row+1) for zero-based data
  2. Guard with col >= 1 && row >= 1 and check against MaxColumns/MaxRows before conversion
  3. 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

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


AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02). Data as JSON: /api/errors/39ccbe4bb756c757. Report an issue: GitHub.