ole

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: 9 Imported by: 0

Documentation

Overview

Package ole implements a pure-Go reader for OLE2 Compound Document files. OLE2 (also known as Compound Document File Format) is used by legacy Excel .xls files.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("ole: invalid OLE2 signature")

ErrInvalidSignature is returned when the OLE signature bytes are not correct.

View Source
var ErrStreamNotFound = errors.New("ole: stream not found")

ErrStreamNotFound is returned when the requested named stream is not found.

Functions

func EncodeBIFF8

func EncodeBIFF8(data *XlsData) []byte

EncodeBIFF8 encodes XlsData as a BIFF8 byte stream.

func NewBytesReaderAt

func NewBytesReaderAt(b []byte) io.ReaderAt

NewBytesReaderAt creates an io.ReaderAt backed by a byte slice.

func ParseCellRef

func ParseCellRef(addr string) (int, int)

ParseCellRef parses a cell reference like "A1" into 0-based row and col.

func SaveXlsFile

func SaveXlsFile(data *XlsData, filename string) error

SaveXlsFile writes XlsData to disk as a minimal XLS (BIFF8) file.

func WriteOLE

func WriteOLE(w io.Writer, streamName string, data []byte) error

WriteOLE writes data as an OLE2 compound document with the given stream name.

Types

type Reader

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

Reader reads an OLE2 compound document.

func NewReader

func NewReader(r io.ReaderAt) (*Reader, error)

NewReader creates a new OLE2 Reader from an io.ReaderAt.

func (*Reader) ReadStream

func (r *Reader) ReadStream(name string) ([]byte, error)

ReadStream reads the full bytes of a named stream.

type XlsData

type XlsData struct {
	Sheets []XlsSheet
	SST    []string // Shared String Table
}

XlsData represents the decoded structure of an XLS file.

func LoadXlsFile

func LoadXlsFile(filename string) (*XlsData, error)

LoadXlsFile loads and decodes an XLS file from disk.

func LoadXlsReader

func LoadXlsReader(reader io.Reader) (*XlsData, error)

LoadXlsReader loads and decodes an XLS file from an io.Reader.

func NewXlsData

func NewXlsData() *XlsData

NewXlsData creates a new empty XlsData structure.

func ParseBIFF

func ParseBIFF(olr *Reader) (*XlsData, error)

ParseBIFF parses the BIFF8 Workbook stream from the OLE container.

type XlsSheet

type XlsSheet struct {
	Name  string
	Cells map[string]string // "A1" -> value
}

XlsSheet holds data for one worksheet.

Jump to

Keyboard shortcuts

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