xlsx

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplateToCells

func ApplyTemplateToCells(f *zip.File, templateValues any, fileContent []byte) ([]byte, error)

ApplyTemplateToCells applies the templateValues to the given file content and returns the modified content.

func GetCountFromXml

func GetCountFromXml(data []byte) (uint, error)

GetCountFromXml counts <c t="s"> cells in a sheetN.xml

func GetReferencedSharedStringsByIndexAndCleanup

func GetReferencedSharedStringsByIndexAndCleanup(fileContent []byte) ([]byte, map[int]string, map[int]int, error)

TODO: switch to xml parsing

func GetUniqueCountFromXML

func GetUniqueCountFromXML(data []byte) (int, error)

GetUniqueCountFromXML counts the number of <si> tags in sharedStrings.xml

func RecountSharedStringsCountAndUniqueCountAttributes

func RecountSharedStringsCountAndUniqueCountAttributes(sharedStringsContent []byte, count uint) ([]byte, error)

RecountSharedStringsCountAndUniqueCountAttributes updates the count and uniqueCount attributes in sharedStrings.xml with previously obtained count and recalculated uniqueCount

func ToNumberCell

func ToNumberCell(v any) (interface{}, error)

func UpdateSheet

func UpdateSheet(fileContent []byte, numberCellsValues map[int]string, sharedStringsNewIndexes map[int]int) ([]byte, error)

TODO: switch to xml parsing

Types

type Cell

type Cell struct {
	T string `xml:"t,attr"` // type attribute (e.g. "s" for shared string)
}

Cell represents a <c> element in sheetN.xml

type R

type R struct {
	T string `xml:"t"`
}

R represents a <r> rich text run inside <si>

type Row

type Row struct {
	Cells []Cell `xml:"c"`
}

Row represents a <row> element

type SI

type SI struct {
	T string `xml:"t"`
	R []R    `xml:"r"` // optional rich text runs
}

SI represents a <si> entry (string item)

type SharedStrings

type SharedStrings struct {
	XMLName     xml.Name `xml:"sst"`
	Count       int      `xml:"count,attr"`
	UniqueCount int      `xml:"uniqueCount,attr"`
	SI          []SI     `xml:"si"`
}

SharedStrings is the root <sst>

type Worksheet

type Worksheet struct {
	Rows []Row `xml:"sheetData>row"`
}

Worksheet represents the <worksheet> root

Jump to

Keyboard shortcuts

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