xls

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 xls provides a pure-Go reader and writer for legacy Excel .xls files (BIFF5/BIFF8 format) via OLE2 compound document parsing.

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 XLS files.

func NewFile

func NewFile() *File

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

func OpenFile

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

OpenFile opens an existing XLS file from a path.

func OpenReader

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

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

func (*File) AddPicture

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

AddPicture adds a picture to a worksheet (no-op for XLS write).

func (*File) AutoFilter

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

AutoFilter sets auto filter for the range (no-op for XLS write).

func (*File) Close

func (x *File) Close() error

Close frees up resources for the XLS 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 a sheet from one index to another.

func (*File) FreezePane

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

FreezePane sets a freeze pane (no-op for XLS write).

func (*File) GetCellFormula

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

GetCellFormula gets the formula of a cell (XLS does not support formula storage; returns empty).

func (*File) GetCellValue

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

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

func (*File) GetCols

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

GetCols returns all columns in a worksheet.

func (*File) GetRows

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

GetRows returns all the rows in a XLS 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 in the XLS file.

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 columns at the given 1-based position.

func (*File) InsertRows

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

InsertRows inserts empty rows after the given 1-based position in a XLS file.

func (*File) MergeCell

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

MergeCell merges cells in a range (no-op for XLS write; read-only).

func (*File) NewSheet

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

NewSheet creates a new sheet in the XLS file.

func (*File) NewStreamWriter

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

NewStreamWriter returns a stream writer for a XLS worksheet.

func (*File) NewStyle

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

NewStyle creates a new style (returns 0 for XLS).

func (*File) ProtectSheet

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

ProtectSheet protects a worksheet (no-op for XLS write).

func (*File) RemoveCol

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

RemoveCol removes the given column.

func (*File) RemoveRow

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

RemoveRow removes the row at the given 1-based index in a XLS file.

func (*File) Rows

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

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

func (*File) Save

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

Save writes the XLS file to the given path.

func (*File) SetCellFormula

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

SetCellFormula sets the formula of a cell in an XLS file (stored as value string).

func (*File) SetCellStyle

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

SetCellStyle sets the style for a cell (no-op for XLS).

func (*File) SetCellValue

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

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

func (*File) SetDocProps

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

SetDocProps sets the document properties for an XLS file (no-op for XLS).

func (*File) SetSheetName

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

SetSheetName sets the name of a worksheet in an XLS file.

func (*File) UnmergeCell

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

UnmergeCell un-merges a range (no-op for XLS).

func (*File) UnprotectSheet

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

UnprotectSheet removes protection from a worksheet (no-op for XLS).

type Rows

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

Rows defines the stream reader for the rows in a XLS 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 XLS worksheet.

func (*StreamWriter) Flush

func (sw *StreamWriter) Flush() error

Flush finalizes any pending writes.

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