xlsx

package
v0.0.0-...-5bb0c7b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package implements creation of XLSX simple spreadsheet files https://github.com/psmithuk/xlsx

Index

Constants

This section is empty.

Variables

View Source
var (
	TemplateContentTypes          *template.Template
	TemplateRelationships         *template.Template
	TemplateWorkbook              *template.Template
	TemplateWorkbookRelationships *template.Template
	TemplateStyles                *template.Template
	TemplateStringLookups         *template.Template
	TemplateSheetStart            *template.Template
	TemplateApp                   *template.Template
	TemplateCore                  *template.Template
)

Templates for the various XML content in XLST files

Functions

func CellIndex

func CellIndex(x, y uint64) (string, uint64)

Given zero-based array indices output the Excel cell reference. For example (0,0) => "A1"; (2,2) => "C3"; (26,45) => "AA46"

func OADate

func OADate(d time.Time) string

Convert time to the OLE Automation format.

Types

type Cell

type Cell struct {
	Type  CellType
	Value string
}

XLSX Spreadsheet Cell

type CellType

type CellType uint
const (
	CellTypeNumber CellType = iota
	CellTypeString
	CellTypeDatetime
	CellTypeInlineString
)

Basic spreadsheet cell types

type Column

type Column struct {
	Name  string
	Width uint64
}

XLSX Spreadsheet Column

type DocumentInfo

type DocumentInfo struct {
	CreatedBy  string
	ModifiedBy string
	CreatedAt  time.Time
	ModifiedAt time.Time
}

XLSX Spreadsheet Document Properties

type Row

type Row struct {
	Cells []Cell
}

XLSX Spreadsheet Row

type Sheet

type Sheet struct {
	ID    string
	Title string

	DocumentInfo DocumentInfo
	// contains filtered or unexported fields
}

XLSX Spreadsheet

func NewSheet

func NewSheet() Sheet

Create a sheet with no dimensions

func NewSheetWithColumns

func NewSheetWithColumns(c []Column) Sheet

Create a sheet with dimensions derived from the given columns

func (*Sheet) AppendRow

func (s *Sheet) AppendRow(r Row) error

Append a row to the sheet

func (*Sheet) NewRow

func (s *Sheet) NewRow() Row

Create a new row with a length caculated by the sheets known column count

func (*Sheet) SaveToFile

func (s *Sheet) SaveToFile(filename string) error

Create filename and save the XLSX file

func (*Sheet) SaveToWriter

func (s *Sheet) SaveToWriter(w io.Writer) error

Save the XLSX file to the given writer

func (*Sheet) SharedStrings

func (s *Sheet) SharedStrings() []string

Get the Shared Strings in the order they were added to the map

type SheetWriter

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

Handles the writing of a sheet

func (*SheetWriter) Close

func (sw *SheetWriter) Close() error

Closes the SheetWriter

func (*SheetWriter) WriteHeader

func (sw *SheetWriter) WriteHeader(s *Sheet) error

Writes the header of a sheet

func (*SheetWriter) WriteRows

func (sw *SheetWriter) WriteRows(rows []Row) error

Write the given rows to this SheetWriter

type WorkbookWriter

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

Handles the writing of an XLSX workbook

func NewWorkbookWriter

func NewWorkbookWriter(w io.Writer) *WorkbookWriter

NewWorkbookWriter creates a new WorkbookWriter, which SheetWriters will operate on. It must be closed when all Sheets have been written.

func (*WorkbookWriter) Close

func (ww *WorkbookWriter) Close() error

Closes the WorkbookWriter

func (*WorkbookWriter) NewSheetWriter

func (ww *WorkbookWriter) NewSheetWriter(s *Sheet) (*SheetWriter, error)

NewSheetWriter creates a new SheetWriter in this workbook using the given sheet. It returns a SheetWriter to which rows can be written. All rows must be written to the SheetWriter before the next call to NewSheetWriter, as this will automatically close the previous SheetWriter.

func (*WorkbookWriter) WriteHeader

func (ww *WorkbookWriter) WriteHeader(s *Sheet) error

Write the header files of the workbook

Jump to

Keyboard shortcuts

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