xlsx

package
v0.0.0-...-08943ef Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package xlsx provides a pure-Go reader and writer for Office Open XML spreadsheet files (.xlsx, .xlsm, .xltx, .xltm).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File holds the internal structure for XLSX files.

func NewFile

func NewFile() *File

NewFile creates a new XLSX file structure with one default sheet.

func OpenFile

func OpenFile(filename string) (*File, error)

OpenFile opens an existing XLSX file from a path.

func OpenReader

func OpenReader(reader io.Reader) (*File, error)

OpenReader opens an existing XLSX file from an io.Reader.

func (*File) AddPicture

func (x *File) AddPicture(_, _, _ string, _ *xmltypes.GraphicOptions) error

AddPicture embeds a picture into a sheet.

func (*File) AutoFilter

func (x *File) AutoFilter(_, _, _ string) error

AutoFilter sets auto filter for the given range.

func (*File) Close

func (x *File) Close() error

Close frees up resources for the XLSX file.

func (*File) DeleteSheet

func (x *File) DeleteSheet(name string) error

DeleteSheet deletes the sheet with the given name.

func (*File) DuplicateSheet

func (x *File) DuplicateSheet(from, _ int) error

DuplicateSheet duplicates the sheet at the given index.

func (*File) FreezePane

func (x *File) FreezePane(_, _ string, _, _ int) error

FreezePane creates a freeze pane at the given row/col position.

func (*File) GetCellFormula

func (x *File) GetCellFormula(sheet, axis string) (string, error)

GetCellFormula returns the formula stored in a cell.

func (*File) GetCellValue

func (x *File) GetCellValue(sheet, axis string) (string, error)

GetCellValue retrieves the value of a cell in an XLSX file.

func (*File) GetCols

func (x *File) GetCols(sheet string) ([][]string, error)

GetCols returns all columns in a XLSX worksheet.

func (*File) GetRows

func (x *File) GetRows(sheet string) ([][]string, error)

GetRows returns all the rows in a XLSX worksheet.

func (*File) GetSheetIndex

func (x *File) GetSheetIndex(name string) (int, error)

GetSheetIndex returns the index of the sheet with the given name.

func (*File) GetSheetList

func (x *File) GetSheetList() ([]string, error)

GetSheetList returns the list of sheet names.

func (*File) GetSheetName

func (x *File) GetSheetName(index int) (string, error)

GetSheetName returns the name of the sheet at the given index.

func (*File) GetWorkBookStructure

func (x *File) GetWorkBookStructure() *xmltypes.WorkBookEntity

GetWorkBookStructure returns the exposed workbook structure for compatibility.

func (*File) InsertCols

func (x *File) InsertCols(sheet, col string, n int) error

InsertCols inserts n columns at the given column position.

func (*File) InsertRows

func (x *File) InsertRows(sheet string, row int) error

InsertRows inserts n empty rows after the given 1-based row position.

func (*File) MergeCell

func (x *File) MergeCell(sheet, hCell, vCell string) error

MergeCell merges a range of cells in the given sheet.

func (*File) NewSheet

func (x *File) NewSheet(name string) (int, error)

NewSheet creates a new sheet. Returns 0-based index.

func (*File) NewStreamWriter

func (x *File) NewStreamWriter(sheet string) (*StreamWriter, error)

NewStreamWriter returns a streaming writer for large datasets.

func (*File) NewStyle

func (x *File) NewStyle(_ *xmltypes.StyleConfig) (int, error)

NewStyle creates a new style and returns its index.

func (*File) ProtectSheet

func (x *File) ProtectSheet(_ string, _ *xmltypes.SheetProtection) error

ProtectSheet applies password protection to a sheet.

func (*File) RemoveCol

func (x *File) RemoveCol(sheet, col string) error

RemoveCol removes the given column from a sheet.

func (*File) RemoveRow

func (x *File) RemoveRow(sheet string, row int) error

RemoveRow removes the 1-based row from the worksheet.

func (*File) Rows

func (x *File) Rows(sheet string) (*Rows, error)

Rows returns a stream reader for iterating over rows in a XLSX worksheet.

func (*File) Save

func (x *File) Save(filename string) error

Save writes the XLSX file to the given path.

func (*File) SetCellFormula

func (x *File) SetCellFormula(sheet, axis, formula string) error

SetCellFormula sets the formula of a cell.

func (*File) SetCellStyle

func (x *File) SetCellStyle(sheet, hCell, _ string, styleID int) error

SetCellStyle sets the style index for a cell.

func (*File) SetCellValue

func (x *File) SetCellValue(sheet, axis string, value any) error

SetCellValue sets the value of a cell in an XLSX file.

func (*File) SetDocProps

func (x *File) SetDocProps(_ *xmltypes.DocProps) error

SetDocProps sets document properties (no-op placeholder).

func (*File) SetSheetName

func (x *File) SetSheetName(oldName, newName string) error

SetSheetName renames a worksheet.

func (*File) UnmergeCell

func (x *File) UnmergeCell(sheet, hCell string) error

UnmergeCell removes a merge from a range of cells.

func (*File) UnprotectSheet

func (x *File) UnprotectSheet(_, _ string) error

UnprotectSheet removes protection from a sheet.

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

Rows defines the stream reader for the rows in a XLSX worksheet.

func (*Rows) Columns

func (r *Rows) Columns() ([]string, error)

Columns returns the cell values in the current row.

func (*Rows) Next

func (r *Rows) Next() bool

Next advances to the next row.

type StreamWriter

type StreamWriter struct {
	// contains filtered or unexported fields
}

StreamWriter defines the stream writer for the rows in a XLSX worksheet.

func (*StreamWriter) Flush

func (sw *StreamWriter) Flush() error

Flush finalizes any pending writes (no-op for in-memory writer).

func (*StreamWriter) SetRow

func (sw *StreamWriter) SetRow(axis string, values []any) error

SetRow writes a row of values starting at the given cell address.

Jump to

Keyboard shortcuts

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