spreadsheet

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 14 Imported by: 0

README

Spreadsheet Manager for Go

Go Reference

Getting Started

package main

import (
	"fmt"

	"github.com/nitingupta009/spreadsheet"
)

func main() {
	// create a new spreadsheet
	spr := spreadsheet.New()

	// fetch the workbook
	wb := spr.Workbook()

	// add a new worksheet
	ws, err := wb.NewWorksheet("My Sheet")
	if err != nil {
		panic(err)
	}

	// open a row writer
	rw := ws.NewRowWriter()

	// add a new row
	row := rw.NewRow()
	cell1 := row.NewCell()
	cell1.SetPlainText("My Cell - 1")
	cell2 := row.NewCell()
	rt := cell2.NewRichText()
	rtr1 := rt.NewRichTextRun()
	rtr1.SetText("My Bold Cell")
	rtr1.SetBold(true)
	rtr2 := rt.NewRichTextRun()
	rtr2.SetText(" - 2")
	if err := rw.WriteRow(row); err != nil {
		panic(err)
	}

	// close the row writer
	if err := rw.Close(); err != nil {
		panic(err)
	}

	// save the spreadsheet
	spr.SetSavePath("my/local/path/file.xlsx")
	if err := spr.SaveAndClose(); err != nil {
		panic(err)
	}

	// open the spreadsheet
	spr, err = spreadsheet.Open("my/local/path/file.xlsx")
	if err != nil {
		panic(err)
	}

	// fetch the workbook
	wb = spr.Workbook()

	// fetch the worksheet
	ws = wb.Worksheet("My Sheet")

	// open a row reader
	rr := ws.NewRowReader()

	// read a row
	row, err = rr.ReadRow()
	if err != nil {
		panic(err)
	}

	// print the cells
	for _, cell := range row.Cells() {
		fmt.Println(cell.String())
	}

	// close the row reader
	if err := rr.Close(); err != nil {
		panic(err)
	}

	// close the spreadsheet
	if err := spr.Close(); err != nil {
		panic(err)
	}
}

Documentation

Overview

Package spreadsheet provides functions to read, create and edit spreadsheets including excel files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alignment

type Alignment string

Alignment represents the text alignment properties of a text run.

const (
	AlignmentNoControl   Alignment = "noControl"
	AlignmentLeft        Alignment = "left"
	AlignmentCenter      Alignment = "center"
	AlignmentDistributed Alignment = "distributed"
)

Alignment can be one of these values.

type Cell

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

Cell represents a single cell in a worksheet.

func (*Cell) GetBoolValue

func (cell *Cell) GetBoolValue() (bool, bool)

GetBoolValue returns the cell value if it's a bool.

func (*Cell) GetFloatValue

func (cell *Cell) GetFloatValue() (float64, bool)

GetFloatValue returns the cell value if it's a float.

func (*Cell) GetIntValue

func (cell *Cell) GetIntValue() (int, bool)

GetIntValue returns the cell value if it's an integer.

func (*Cell) GetTextValue

func (cell *Cell) GetTextValue() (string, bool)

GetTextValue returns the cell value if it's a string.

func (*Cell) NewRichText

func (cell *Cell) NewRichText() *RichText

NewRichText sets the cell contents to a new styled text and returns it.

func (*Cell) Ref

func (cell *Cell) Ref() *CellRef

Ref returns the cell reference.

func (*Cell) RichText

func (cell *Cell) RichText() *RichText

RichText returns the styled cell text.

func (*Cell) SetBoolValue

func (cell *Cell) SetBoolValue(value bool)

SetBoolValue sets the cell to the given bool value.

func (*Cell) SetFloatValue

func (cell *Cell) SetFloatValue(value float64)

SetFloatValue sets the cell to the given float64 value.

func (*Cell) SetIntValue

func (cell *Cell) SetIntValue(value int)

SetIntValue sets the cell to the given int value.

func (*Cell) SetPlainText

func (cell *Cell) SetPlainText(str string)

SetPlainText sets the cell to the given string value.

func (*Cell) String

func (cell *Cell) String() string

String returns the cell value in plain text.

func (*Cell) Type

func (cell *Cell) Type() CellType

Type returns the underlying type of the cell.

type CellRange

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

CellRange represents a range of cells in a worksheet.

func NewCellRange

func NewCellRange(first, last *CellRef) *CellRange

NewCellRange builds a cell range marked by the given first and last cell references.

func NewCellRangeFromString

func NewCellRangeFromString(str string) *CellRange

NewCellRangeFromString parses the given string and returns the cell range.

func (*CellRange) FirstRef

func (cellRange *CellRange) FirstRef() *CellRef

FirstRef returns the reference of the first cell in the range.

func (*CellRange) LastRef

func (cellRange *CellRange) LastRef() *CellRef

LastRef returns the reference of the last cell in the range.

func (*CellRange) String

func (cellRange *CellRange) String() string

String returns the text representation of the cell range.

type CellRef

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

CellRef represents the reference or address of a cell.

func NewCellRef

func NewCellRef(rowNum, colNum int, isAbsRow, isAbsCol bool) *CellRef

NewCellRef builds the cell reference for the given row and column values.

func NewCellRefFromString

func NewCellRefFromString(str string) *CellRef

NewCellRefFromString parses the given string and returns the cell reference.

func (*CellRef) ColNum

func (cellRef *CellRef) ColNum() int

ColNum returns the column number of the cell reference.

func (*CellRef) IsAbsCol

func (cellRef *CellRef) IsAbsCol() bool

IsAbsCol returns whether the column number of the cell reference is absolute.

func (*CellRef) IsAbsRow

func (cellRef *CellRef) IsAbsRow() bool

IsAbsRow returns whether the row number of the cell reference is absolute.

func (*CellRef) RowNum

func (cellRef *CellRef) RowNum() int

RowNum returns the row number of the cell reference.

func (*CellRef) String

func (cellRef *CellRef) String() string

String returns the text representation of the cell reference.

type CellType

type CellType string

CellType represents the underlying type of a cell.

const (
	CellTypeBool       CellType = "b"
	CellTypeNumber     CellType = "n"
	CellTypeError      CellType = "e"
	CellTypeSharedStr  CellType = "s"
	CellTypeFormulaStr CellType = "str"
	CellTypeInlineStr  CellType = "inlineStr"
)

Type of a cell can be one of these values.

type CharType

type CharType string

CharType represents the character types in Japanese text.

const (
	CharTypeHalfWidthKatakana CharType = "halfwidthKatakana"
	CharTypeFullWidthKatakana CharType = "fullwidthKatakana"
	CharTypeHiragana          CharType = "Hiragana"
	CharTypeNoConversion      CharType = "noConversion"
)

CharType can be one of these values.

type Color

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

Color represents the text color properties of a text run.

func (*Color) Auto

func (color *Color) Auto() (bool, bool)

Auto returns whether the color is set to auto, if set.

func (*Color) Index

func (color *Color) Index() (uint, bool)

Index returns the index of the color, if set.

func (*Color) RGB

func (color *Color) RGB() (uint16, bool)

RGB returns the rgb property of the color, if set.

func (*Color) SetAuto

func (color *Color) SetAuto(auto, remove bool)

SetAuto sets or removes the auto property of the color.

func (*Color) SetIndex

func (color *Color) SetIndex(index uint, remove bool)

SetIndex sets or removes the color index.

func (*Color) SetRGB

func (color *Color) SetRGB(value uint16, remove bool)

Set RGB sets or removes the rgb property of the color.

func (*Color) SetTheme

func (color *Color) SetTheme(value uint, remove bool)

SetTheme sets or removes the color theme.

func (*Color) SetTint

func (color *Color) SetTint(value float64)

SetTint sets the color tint.

func (*Color) Theme

func (color *Color) Theme() (uint, bool)

Theme returns the color theme, if set.

func (*Color) Tint

func (color *Color) Tint() float64

Tint returns the color tint.

type CoreProperties

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

CoreProperties represents the core properties of the spreadsheet.

func (*CoreProperties) Category

func (cp *CoreProperties) Category() string

Category returns the spreadsheet category.

func (*CoreProperties) ContentStatus

func (cp *CoreProperties) ContentStatus() string

ContentStatus returns the content status of the spreadsheet.

func (*CoreProperties) ContentType

func (cp *CoreProperties) ContentType() string

ContentType returns the content type of the spreadsheet.

func (*CoreProperties) CreatedAt

func (cp *CoreProperties) CreatedAt() (int64, bool)

CreatedAt returns the timestamp at which the spreadsheet was created, if set.

func (*CoreProperties) Creator

func (cp *CoreProperties) Creator() string

Creator returns the creator of the spreadsheet.

func (*CoreProperties) Description

func (cp *CoreProperties) Description() string

Description returns the spreadsheet description.

func (*CoreProperties) Identifier

func (cp *CoreProperties) Identifier() string

Identifier returns the spreadsheet identifier.

func (*CoreProperties) Keywords

func (cp *CoreProperties) Keywords() string

Keywords returns the spreadsheet keywords usually separated by comma.

func (*CoreProperties) Language

func (cp *CoreProperties) Language() string

Language returns the spreadsheet language.

func (*CoreProperties) LastModifiedBy

func (cp *CoreProperties) LastModifiedBy() string

LastModifiedBy returns the user who last modified the spreadsheet.

func (*CoreProperties) LastPrintedAt

func (cp *CoreProperties) LastPrintedAt() (int64, bool)

LastPrintedAt returns the timestamp at which the spreadsheet was last printed, if set.

func (*CoreProperties) ModifiedAt

func (cp *CoreProperties) ModifiedAt() (int64, bool)

ModifiedAt returns the timestamp at which the spreadsheet was last modified, if set.

func (*CoreProperties) Revision

func (cp *CoreProperties) Revision() int

Revision returns the spreadsheet revision.

func (*CoreProperties) SetCategory

func (cp *CoreProperties) SetCategory(str string)

SetCategory sets the spreadsheet category.

func (*CoreProperties) SetContentStatus

func (cp *CoreProperties) SetContentStatus(str string)

SetContentStatus sets the content status of the spreadsheet.

func (*CoreProperties) SetContentType

func (cp *CoreProperties) SetContentType(str string)

SetContentType sets the content type of the spreadsheet.

func (*CoreProperties) SetCreatedAt

func (cp *CoreProperties) SetCreatedAt(sec int64, remove bool)

SetCreatedAt sets or removes the timestamp at which the spreadsheet was created.

func (*CoreProperties) SetCreator

func (cp *CoreProperties) SetCreator(str string)

SetCreator sets the creator of the spreadsheet.

func (*CoreProperties) SetDescription

func (cp *CoreProperties) SetDescription(str string)

SetDescription sets the spreadsheet description.

func (*CoreProperties) SetIdentifier

func (cp *CoreProperties) SetIdentifier(str string)

SetIndentifier sets the spreadsheet identifier.

func (*CoreProperties) SetKeywords

func (cp *CoreProperties) SetKeywords(str string)

SetKeywords sets the spreadsheet keywords usually separated by comma.

func (*CoreProperties) SetLanguage

func (cp *CoreProperties) SetLanguage(str string)

SetLanguage sets the spreadsheet language.

func (*CoreProperties) SetLastModifiedBy

func (cp *CoreProperties) SetLastModifiedBy(str string)

SetLastModifiedBy sets the user who last modified the spreadsheet.

func (*CoreProperties) SetLastPrintedAt

func (cp *CoreProperties) SetLastPrintedAt(sec int64, remove bool)

SetLastPrintedAt sets or removes the timestamp at which the spreadsheet was last printed.

func (*CoreProperties) SetModifiedAt

func (cp *CoreProperties) SetModifiedAt(sec int64, remove bool)

SetModifiedAt sets or removes the timestamp at which the spreadsheet was last modified.

func (*CoreProperties) SetRevision

func (cp *CoreProperties) SetRevision(value int)

SetRevision sets the spreadsheet revision.

func (*CoreProperties) SetSubject

func (cp *CoreProperties) SetSubject(str string)

SetSubject sets the spreadsheet subject.

func (*CoreProperties) SetTitle

func (cp *CoreProperties) SetTitle(str string)

SetTitle sets the spreadsheet title.

func (*CoreProperties) SetVersion

func (cp *CoreProperties) SetVersion(value float64)

SetVersion sets the spreadsheet version.

func (*CoreProperties) Subject

func (cp *CoreProperties) Subject() string

Subject returns the spreadsheet subject.

func (*CoreProperties) Title

func (cp *CoreProperties) Title() string

Title returns the spreadsheet title.

func (*CoreProperties) Version

func (cp *CoreProperties) Version() float64

Version returns the spreadsheet version.

type FontScheme

type FontScheme string

FontScheme represents the font schemes of a text run.

const (
	FontSchemeNone  FontScheme = "none"
	FontSchemeMajor FontScheme = "major"
	FontSchemeMinor FontScheme = "minor"
)

FontScheme can be one of these values.

type PhoneticPr

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

PhoneticPr represents the shared properties of phonetic runs in a rich text.

func (*PhoneticPr) Alignment

func (phpr *PhoneticPr) Alignment() Alignment

Alignment returns the alignment applied to the phonetic properties.

func (*PhoneticPr) CharType

func (phpr *PhoneticPr) CharType() CharType

CharType returns the character type applied to the phonetic properties.

func (*PhoneticPr) FontId

func (phpr *PhoneticPr) FontId() uint

FontId returns the font id applied to the phonetic properties.

func (*PhoneticPr) SetAlignment

func (phpr *PhoneticPr) SetAlignment(value Alignment)

SetAlignment sets the given alignment property to phonetic properties.

func (*PhoneticPr) SetCharType

func (phpr *PhoneticPr) SetCharType(value CharType)

SetCharType sets the given character type to the phonetic properties.

func (*PhoneticPr) SetFontId

func (phpr *PhoneticPr) SetFontId(value uint)

SetFontId sets the font id to the phonetic properties.

type PhoneticRun

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

PhoneticRun represents the alphabetical hints displayed on top of complex symbols to aid reading especially in east asian languages.

func (*PhoneticRun) End

func (phr *PhoneticRun) End() uint

End returns the index of the byte at which the phonetic run ends.

func (*PhoneticRun) Start

func (phr *PhoneticRun) Start() uint

Start returns the index of the byte at which the phonetic run starts.

func (*PhoneticRun) Text

func (phr *PhoneticRun) Text() string

Text returns the plain text value of the phonetic run.

type RichText

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

RichText represents the styled text in a cell.

func (*RichText) NewPhoneticPr

func (rt *RichText) NewPhoneticPr() *PhoneticPr

NewPhoneticPr sets the phonetic properties to a new value and returns it.

func (*RichText) NewPhoneticRun

func (rt *RichText) NewPhoneticRun(start, end uint, str string) *PhoneticRun

NewPhoneticRun appends a new phonetic run to the rich text and returns it.

func (*RichText) NewRichTextRun

func (rt *RichText) NewRichTextRun() *RichTextRun

NewRichTextRun appends a new text run to the rich text and returns it.

func (*RichText) PhoneticPr

func (rt *RichText) PhoneticPr() *PhoneticPr

PhoneticPr returns the phonetic properties of the rich text.

func (*RichText) PhoneticRuns

func (rt *RichText) PhoneticRuns() []*PhoneticRun

PhoneticRuns returns the phonetic runs in the rich text.

func (*RichText) RemovePhoneticPr

func (rt *RichText) RemovePhoneticPr()

RemovePhoneticPr removes the phonetic properties from the rich text.

func (*RichText) RemovePhoneticRuns

func (rt *RichText) RemovePhoneticRuns()

RemovePhoneticRuns removes all phonetic runs from the rich text.

func (*RichText) RemoveRichTextRuns

func (rt *RichText) RemoveRichTextRuns()

RemoveRichTextRuns removes all text runs and sets the rich text to blank.

func (*RichText) RichTextRuns

func (rt *RichText) RichTextRuns() []*RichTextRun

RichTextRuns returns the text runs with unique styles for the rich text.

func (*RichText) SetPlainText

func (rt *RichText) SetPlainText(str string)

SetPlainText sets the given string to the rich text and strips all styles.

func (*RichText) Text

func (rt *RichText) Text() string

Text returns the plain text value of the rich text.

type RichTextRun

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

RichTextRun represents a portion of text sharing the same style in rich text.

func (*RichTextRun) Bold

func (rtr *RichTextRun) Bold() bool

Bold returns whether bold is applied on the text run.

func (*RichTextRun) Charset

func (rtr *RichTextRun) Charset() (uint8, bool)

Charset returns the character set index of the text run, if set.

func (*RichTextRun) Color

func (rtr *RichTextRun) Color() *Color

Color returns the color applied to the text run.

func (*RichTextRun) Condense

func (rtr *RichTextRun) Condense() bool

Condense returns whether condense is applied to the text run.

func (*RichTextRun) Extend

func (rtr *RichTextRun) Extend() bool

Extend returns whether extend is applied to the text run.

func (*RichTextRun) FontFamily

func (rtr *RichTextRun) FontFamily() (uint8, bool)

FontFamily returns the font family of the text run, if set.

func (*RichTextRun) FontName

func (rtr *RichTextRun) FontName() string

FontName returns the name of the text run font.

func (*RichTextRun) FontScheme

func (rtr *RichTextRun) FontScheme() FontScheme

FontScheme returns the font scheme of the text run.

func (*RichTextRun) FontSize

func (rtr *RichTextRun) FontSize() float64

FontSize returns the font size of the text run.

func (*RichTextRun) Italic

func (rtr *RichTextRun) Italic() bool

Italic returns whether italic is applied on the text run.

func (*RichTextRun) NewColor

func (rtr *RichTextRun) NewColor() *Color

NewColor sets a new color to the text run and returns it.

func (*RichTextRun) Outline

func (rtr *RichTextRun) Outline() bool

Outline returns whether outline is applies to the text run.

func (*RichTextRun) RemoveColor

func (rtr *RichTextRun) RemoveColor()

RemoveColor removes the color of the text run.

func (*RichTextRun) SetBold

func (rtr *RichTextRun) SetBold(value bool)

SetBold sets the bold property of the text run.

func (*RichTextRun) SetCharset

func (rtr *RichTextRun) SetCharset(value uint8, remove bool)

SetCharset sets or removes the character set of the text run.

func (*RichTextRun) SetCondense

func (rtr *RichTextRun) SetCondense(value bool)

SetCondense sets the condense property of the text run.

func (*RichTextRun) SetExtend

func (rtr *RichTextRun) SetExtend(value bool)

SetExtend sets the extend property of the text run.

func (*RichTextRun) SetFontFamily

func (rtr *RichTextRun) SetFontFamily(value uint8, remove bool)

SetFontFamily sets or removes the font family of the text run.

func (*RichTextRun) SetFontName

func (rtr *RichTextRun) SetFontName(fontName string)

SetFontName sets the text run font.

func (*RichTextRun) SetFontScheme

func (rtr *RichTextRun) SetFontScheme(value FontScheme)

SetFontScheme sets the font scheme of text run.

func (*RichTextRun) SetFontSize

func (rtr *RichTextRun) SetFontSize(value float64)

SetFontSize sets the font size of the text run.

func (*RichTextRun) SetItalic

func (rtr *RichTextRun) SetItalic(value bool)

SetItalic set the italic property of the text run.

func (*RichTextRun) SetOutline

func (rtr *RichTextRun) SetOutline(value bool)

Outline sets the outline property of the text run.

func (*RichTextRun) SetShadow

func (rtr *RichTextRun) SetShadow(value bool)

SetShadow sets the shadow property of the text run.

func (*RichTextRun) SetStrike

func (rtr *RichTextRun) SetStrike(value bool)

SetStrike sets the strike property of the text run.

func (*RichTextRun) SetText

func (rtr *RichTextRun) SetText(str string)

SetText sets the text value of the text run.

func (*RichTextRun) SetUnderline

func (rtr *RichTextRun) SetUnderline(value Underline)

SetUnderline sets the underline property of the text run.

func (*RichTextRun) SetVerticalAlign

func (rtr *RichTextRun) SetVerticalAlign(value VerticalAlign)

SetVerticalAlign sets the vertical alignment property of the text run.

func (*RichTextRun) Shadow

func (rtr *RichTextRun) Shadow() bool

Shadow returns whether shadow is applied to the text run.

func (*RichTextRun) Strike

func (rtr *RichTextRun) Strike() bool

Strike returns whether strike is applied to the text run.

func (*RichTextRun) Text

func (rtr *RichTextRun) Text() string

Text returns the text value of the text run.

func (*RichTextRun) Underline

func (rtr *RichTextRun) Underline() Underline

Underline returns the underline applied to the text run.

func (*RichTextRun) VerticalAlign

func (rtr *RichTextRun) VerticalAlign() VerticalAlign

VerticalAlign returns the vertical alignment applied to the text run.

type Row

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

Row represents a single row in a worksheet.

func (*Row) Cells

func (row *Row) Cells() []*Cell

Cells return the cells of the row.

func (*Row) NewCell

func (row *Row) NewCell() *Cell

NewCell appends a new cell to the row and returns it.

func (*Row) Number

func (row *Row) Number() int

Number returns the row number in the worksheet.

type RowReader

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

RowReader provides ReadRow method to read the worksheet rows one by one.

func (*RowReader) Close

func (rr *RowReader) Close() error

Close closes the worksheet that was opened for reading.

func (*RowReader) ReadRow

func (rr *RowReader) ReadRow() (*Row, error)

ReadRow reads a single row from the worksheet. First call returns the first row of the worksheet and any subsequent calls return the following rows in order.

type RowWriter

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

RowWriter provides WriteRow method to write the worksheet rows one by one. Any existing rows in the worksheet are removed.

func (*RowWriter) Close

func (rw *RowWriter) Close() error

Close finishes the writing process and closes the worksheet.

func (*RowWriter) NewRow

func (rw *RowWriter) NewRow() *Row

NewRow returns an empty row that can be modified before writing by WriteRow.

func (*RowWriter) WriteRow

func (rw *RowWriter) WriteRow(row *Row) error

WriteRow writes the given row to the worksheet. First call writes the first row of the worksheet and any subsequent calls write the following rows in order.

type Spreadsheet

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

Spreadsheet represents an opened spreadsheet file. It provides methods to manage the workbook and core properties of the spreadsheet.

func New

func New() *Spreadsheet

New opens a new spreadsheet file and returns it. The file should be closed after use to clean up any temporary data generated to manage modifications.

The file can be saved to disk and closed by calling the SaveAndClose method. The path to which the file is saved must be set by calling SetSavePath method before SaveAndClose is called.

The file can be closed without saving to disk by calling Close method.

func Open

func Open(filePath string) (*Spreadsheet, error)

Open opens an existing spreadsheet at the given path and returns it. The file should be closed after use to clean up any temporary data generated to manage modifications.

The file can be saved to disk and closed by calling SaveAndClose method. By default, the file is saved its current path but the path can be changed by calling SetSavePath method before SaveAndClose is called.

The file can be closed without saving to disk by Close method.

func (*Spreadsheet) Close

func (spr *Spreadsheet) Close() error

Close closes the spreadsheet file and cleans up any temporary data generated to manage modifications. Any unsaved modifications are permanently lost.

func (*Spreadsheet) CoreProperties

func (spr *Spreadsheet) CoreProperties() *CoreProperties

CoreProperties returns the core properties of the spreadsheet.

func (*Spreadsheet) SaveAndClose

func (spr *Spreadsheet) SaveAndClose() error

SaveAndClose saves the spreadsheet file to disk and closes it. It also cleans up any temporary data generated to manage modifications.

func (*Spreadsheet) SavePath

func (spr *Spreadsheet) SavePath() string

SavePath returns the path of the spreadsheet file where it is expected to be saved by the SaveAndClose method.

func (*Spreadsheet) SetSavePath

func (spr *Spreadsheet) SetSavePath(savePath string)

SetSavePath sets or modifies the path to which a spreadsheet file is saved by SaveAndClose method.

func (*Spreadsheet) Workbook

func (spr *Spreadsheet) Workbook() *Workbook

Workbook returns the workbook of the spreadsheet.

func (*Spreadsheet) WriteTo

func (spr *Spreadsheet) WriteTo(w io.Writer) error

WriteTo provides a way to write spreadsheet file to a given writer without closing the spreadsheet file.

type Underline

type Underline string

Underline represents the underline properties of a text run.

const (
	UnderlineSingle           Underline = "single"
	UnderlineDouble           Underline = "double"
	UnderlineSingleAccounting Underline = "singleAccounting"
	UnderlineDoubleAccounting Underline = "doubleAccounting"
	UnderlineNone             Underline = "none"
)

Underline can be one of these values.

type VerticalAlign

type VerticalAlign string

VericalAlign represents the vertical alignment properties of a text run.

const (
	VerticalAlignBaseline    VerticalAlign = "baseline"
	VerticalAlignSuperScript VerticalAlign = "superscript"
	VerticalAlignSubScript   VerticalAlign = "subscript"
)

VerticalAlign can be one of these values.

type Workbook

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

Workbook represents the spreadsheet workbook. It provides methods to manage the worksheets of the spreadsheet.

func (*Workbook) NewWorksheet

func (wb *Workbook) NewWorksheet(name string) (*Worksheet, error)

NewWorksheet adds a new worksheet of the given name to workbook and returns it.

func (*Workbook) Worksheet

func (wb *Workbook) Worksheet(name string) *Worksheet

Worksheet returns the worksheet of the given name.

func (*Workbook) WorksheetNames

func (wb *Workbook) WorksheetNames() []string

WorksheetNames returns a slice of names for all worksheets in the workbook.

type Worksheet

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

Worksheet represents a single worksheet in the workbook.

func (*Worksheet) Name

func (ws *Worksheet) Name() string

Name returns the name of the worksheet.

func (*Worksheet) NewRowReader

func (ws *Worksheet) NewRowReader() *RowReader

NewRowReader opens the worksheet for reading and returns a row reader to read the rows. The worksheet should be closed by calling Close method after use.

func (*Worksheet) NewRowWriter

func (ws *Worksheet) NewRowWriter() *RowWriter

NewRowWriter opens the worksheet for writing and returns a row writer to write rows. Close method muse be called after use to finish the writing process and close the worksheet.

func (*Worksheet) SetState

func (ws *Worksheet) SetState(state WorksheetState)

SetState sets the worksheet to the given state.

func (*Worksheet) State

func (ws *Worksheet) State() WorksheetState

State returns the state of the worksheet.

type WorksheetState

type WorksheetState string

WorksheetState represents the visibility state of the worksheet.

const (
	WorksheetStateVisible    WorksheetState = "visible"
	WorksheetStateHidden     WorksheetState = "hidden"
	WorksheetStateVeryHidden WorksheetState = "veryHidden"
)

WorksheetState can be one these values.

Directories

Path Synopsis
internal
xml
tools

Jump to

Keyboard shortcuts

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