excel

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSheetIndexOutOfRange = errors.New("sheet index out of range")

ErrSheetIndexOutOfRange indicates the configured sheet index exceeds the actual sheet count of the workbook.

Functions

func NewExporter

func NewExporter(adapter tabular.RowAdapter, opts ...ExportOption) tabular.Exporter

NewExporter creates an Excel exporter driven by the provided RowAdapter.

func NewExporterFor

func NewExporterFor[T any](opts ...ExportOption) tabular.Exporter

NewExporterFor creates an Excel exporter bound to struct type T.

func NewImporter

func NewImporter(adapter tabular.RowAdapter, opts ...ImportOption) tabular.Importer

NewImporter creates an Excel importer driven by the provided RowAdapter.

func NewImporterFor

func NewImporterFor[T any](opts ...ImportOption) tabular.Importer

NewImporterFor creates an Excel importer bound to struct type T.

func NewMapExporter added in v0.22.0

func NewMapExporter(
	specs []tabular.ColumnSpec, opts ...ExportOption,
) (tabular.Exporter, error)

NewMapExporter creates an Excel exporter that writes []map[string]any rows using the provided dynamic column specs.

func NewMapImporter added in v0.22.0

func NewMapImporter(
	specs []tabular.ColumnSpec, mapOpts []tabular.MapOption, opts ...ImportOption,
) (tabular.Importer, error)

NewMapImporter creates an Excel importer that parses rows into []map[string]any using the provided dynamic column specs. Pass nil for mapOpts when no MapAdapter options (e.g. row validators) are needed.

func NewTypedExporterFor added in v0.22.0

func NewTypedExporterFor[T any](opts ...ExportOption) tabular.TypedExporter[T]

NewTypedExporterFor creates an Excel exporter bound to struct type T that accepts []T directly, eliminating the need for an any-typed argument.

func NewTypedImporterFor added in v0.22.0

func NewTypedImporterFor[T any](opts ...ImportOption) tabular.TypedImporter[T]

NewTypedImporterFor creates an Excel importer bound to struct type T that returns []T directly, eliminating the need for a type assertion.

Types

type ExportOption

type ExportOption func(*exportConfig)

ExportOption configures the Excel exporter behavior.

func WithSheetName

func WithSheetName(name string) ExportOption

WithSheetName sets the worksheet name (default: "Sheet1").

type ImportOption

type ImportOption func(*importConfig)

ImportOption configures the Excel importer behavior.

func WithImportSheetIndex

func WithImportSheetIndex(index int) ImportOption

WithImportSheetIndex selects the worksheet to import by 0-based index (default: 0). Ignored when WithImportSheetName is set.

func WithImportSheetName

func WithImportSheetName(name string) ImportOption

WithImportSheetName selects the worksheet to import by name. When set, it takes precedence over WithImportSheetIndex.

func WithSkipRows

func WithSkipRows(rows int) ImportOption

WithSkipRows skips the first n rows before reading the header or data. Negative values are clamped to zero.

func WithoutHeader added in v0.22.0

func WithoutHeader() ImportOption

WithoutHeader treats the first non-skipped row as data instead of headers. Columns are mapped to source positions in schema order.

func WithoutTrimSpace added in v0.22.0

func WithoutTrimSpace() ImportOption

WithoutTrimSpace disables leading/trailing whitespace trimming on cell values. Trimming is enabled by default and affects empty-row detection, header matching, and cell value parsing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL