qax-os/excelize · error

ErrCellCharsLength

ErrCellCharsLength

Error message

cell value must be 0-%d characters

What it means

Formatted error ErrCellCharsLength returned by SetCellRichText when the cumulative UTF-16 code-unit count of all rich text runs exceeds TotalCellChars (32767), Excel's per-cell character limit; a generic input-size guard, at fault is the combined length of the RichTextRun texts.

Source

Thrown at errors.go:29

package excelize

import (
	"errors"
	"fmt"
	"strings"
)

var (
	// ErrAddVBAProject defined the error message on add the VBA project in
	// the workbook.
	ErrAddVBAProject = errors.New("unsupported VBA project")
	// ErrAttrValBool defined the error message on marshal and unmarshal
	// boolean type XML attribute.
	ErrAttrValBool = errors.New("unexpected child of attrValBool")
	// ErrCellCharsLength defined the error message for receiving a cell
	// characters length that exceeds the limit.
	ErrCellCharsLength = fmt.Errorf("cell value must be 0-%d characters", TotalCellChars)
	// ErrCellStyles defined the error message on cell styles exceeds the limit.
	ErrCellStyles = fmt.Errorf("the cell styles exceeds the %d limit", MaxCellStyles)
	// ErrChartTitle defined the error message on both formula and rich text for
	// chart title.
	ErrChartTitle = errors.New("cannot set both 'Formula' and 'Paragraph' for chart title")
	// ErrColumnNumber defined the error message on receive an invalid column
	// number.
	ErrColumnNumber = fmt.Errorf("the column number must be greater than or equal to %d and less than or equal to %d", MinColumns, MaxColumns)
	// ErrColumnWidth defined the error message on receive an invalid column
	// width.
	ErrColumnWidth = fmt.Errorf("the width of the column must be less than or equal to %d characters", MaxColumnWidth)
	// ErrCoordinates defined the error message on invalid coordinates tuples
	// length.
	ErrCoordinates = errors.New("coordinates length must be 4")
	// ErrCustomNumFmt defined the error message on receive the empty custom
	// number format.
	ErrCustomNumFmt = errors.New("custom number format can not be empty")
	// ErrDataValidationFormulaLength defined the error message for receiving a

View on GitHub (pinned to f2483381fb)

Solutions

  1. Split the content across multiple cells
  2. Trim or truncate the run texts to fit within TotalCellChars
  3. Use SetCellStr for plain text if rich formatting is not required
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at errors.go:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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