sheet

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sheet puts the sheets of a spreadsheet on pages. A format reads its file into a Workbook: the cells with the text that they show, their styles, the widths of the columns, the heights of the rows, the merged cells and the setup of the page. Source converts the Workbook into HTML and CSS for the layout of D10, as printing does (D24): each sheet in order, each one in a document of its own.

A sheet that is wider than its page is cut into bands of columns. The pages show the rows of the first band, then the rows of the next band, as Excel prints "down, then over", or the first rows of each band, then the next rows, as Excel prints "over, then down". The rows of the print titles repeat at the top of each page, and the columns of the print titles at the left of each band. A band ends at its last row that shows something, as Excel prints no page without ink.

The conditional formats of a sheet change the look of its cells: a style, a color scale, a data bar or an icon. The comments of the cells can follow the cells on pages of their own.

xlsx, msxls, odf and csv share the package. The two formats of Excel, xlsx and msxls, also share the sizes of the papers, the widths of the columns, the heights of the rows and the codes of the headers and the footers of Excel: PaperSize, Digit, ExcelRows and ParseHeaderFooter.

Index

Constants

View Source
const (
	MaxRows = 1 << 20
	MaxCols = 1 << 14
)

MaxRows and MaxCols are the size of a sheet of Excel. A reader drops a cell past them.

View Source
const (
	LetterWidth  = 612
	LetterHeight = 792
	A4Width      = 595.28
	A4Height     = 841.89
)

The sizes of a US Letter and an A4 page, in points.

View Source
const IndentStep = 8.25

IndentStep is the width of a step of the indent of a cell of Excel, in points: 11 pixels. Excel prints the steps of the cells of poi/xls/legal-portrait.xls, in Arial of 10 points, 8.25 points apart on a page of a scale of 37%, so the scale of the page does not apply to the indent. poi/xlsx/landscape-letter-budget.xlsx, in Century Gothic of 9 points, gives about 9 points.

Variables

View Source
var DefaultPage = Page{
	Width: LetterWidth, Height: LetterHeight,
	Top: 54, Bottom: 54, Left: 50.4, Right: 50.4,
	Header: 21.6, Footer: 21.6,
}

DefaultPage is the page of Excel: US Letter, with the margins Normal.

View Source
var DefaultStyle = Style{Font: Font{Family: "Calibri", Size: 11}}

DefaultStyle is the default style of a workbook without styles: Calibri of 11 points, the default font of Excel.

Functions

func ArialTextWidth added in v0.2.0

func ArialTextWidth(s string, size float64) float64

ArialTextWidth returns the width in points of the text s in Arial or Liberation Sans of the size size, as TextWidth does for Calibri. A format that does not lay out its text, such as csv for the widths of its columns, measures text with it.

func CellName

func CellName(row, col int) string

CellName returns the name of the cell of the row and the column, from 0, such as B3.

func PaperSize

func PaperSize(n int) (float64, float64, bool)

PaperSize returns the width and the height in points of the paper of Excel with the number n, in portrait, and true. It returns false for a number that it does not know.

func TextWidth

func TextWidth(s string, size float64) float64

TextWidth returns the width in points of the text s in Calibri of the size size, the default font of Excel, without kerning. A character past the table of Calibri takes 0.5 of the size, a combining mark 0, and a wide character of East Asia the whole size. A format that does not lay out its text measures text with it.

func Tint

func Tint(c color.NRGBA, t float64) color.NRGBA

Tint applies a tint of SpreadsheetML to c: it changes the lightness of c in the HLS space, toward black for a negative t and toward white for a positive one (ECMA-376 Part 1, 18.8.19). t goes from -1 to 1.

func WithPartPages

func WithPartPages(ctx context.Context, n int) context.Context

WithPartPages returns a context in which Source cuts a long sheet into parts of about n pages, and makes no part for a sheet of fewer than 2n pages. A number below 1 makes no part. Without it, a part has about 16 pages. The tests use it to compare the pages of a whole sheet with the pages of its parts.

Types

type Border

type Border struct {
	// Width is the width in points, or 0 for none.
	Width float64
	// Line is "solid", "dashed", "dotted" or "double".
	Line string
	// Color is the color, or transparent for black.
	Color color.NRGBA
}

Border is a side of the border of a cell.

type Cell

type Cell struct {
	Col int
	// Text is the text that the cell shows, such as a number formatted
	// with its format code.
	Text string
	// Runs is the rich text of the cell. If it is set, the cell shows it
	// in the place of Text.
	Runs []Run
	// Style is the index of the style of the cell in Workbook.Styles.
	Style int
	Kind  Kind
	// Value is the number of a cell of KindNumber, which the conditional
	// formats compare.
	Value float64
	// AsText aligns a number of the alignment General to the left, as
	// text. Excel does so for a number whose format is text only, "@".
	AsText bool
	// Color is the color of the section of the format code, such as
	// [Red], or transparent.
	Color color.NRGBA
}

Cell is a cell of a row.

type Col

type Col struct {
	// Min and Max are the first and the last index of the run.
	Min, Max int
	// Width is the width in points, or 0 for the default width.
	Width float64
	// Hidden hides the columns.
	Hidden bool
	// Style is the style of the cells of the columns that the sheet does
	// not hold, or 0.
	Style int
}

Col is a run of columns with the same size and style.

type Comment

type Comment struct {
	Row, Col     int
	Author, Text string
}

Comment is the comment of a cell: its author and its text.

type CondFormat

type CondFormat struct {
	Ranges []Range
	Rules  []CondRule
}

CondFormat is a conditional format: rules over the cells of its ranges.

type CondRule

type CondRule struct {
	// Kind is the test of the rule, with the names of Excel: cellIs,
	// top10, aboveAverage, duplicateValues, uniqueValues, containsText,
	// notContainsText, beginsWith, endsWith, containsBlanks,
	// notContainsBlanks, containsErrors, notContainsErrors, colorScale,
	// dataBar or iconSet.
	Kind string
	// Priority orders the rules of a sheet: the rule with the lowest
	// number wins over the others. StopIfTrue applies no rule after a
	// rule that matches.
	Priority   int
	StopIfTrue bool
	// Operator is the comparison of cellIs: between, notBetween, equal,
	// notEqual, greaterThan, lessThan, greaterThanOrEqual or
	// lessThanOrEqual. Operands are the values that it compares with.
	Operator string
	Operands []Operand
	// Text is the text of containsText, notContainsText, beginsWith and
	// endsWith.
	Text string
	// Rank is the number of the cells of top10, or their percent with
	// Percent. Bottom takes the lowest values.
	Rank            int
	Percent, Bottom bool
	// Below takes the values below the average for aboveAverage, and
	// EqualAverage the average too. StdDev moves the average by a number
	// of standard deviations.
	Below, EqualAverage bool
	StdDev              int
	// Diff is the change of the style of a cell that the rule matches.
	Diff *Diff
	// Scale holds the two or three points of a colorScale.
	Scale []ScalePoint
	// Bar is the bar of a dataBar, and Icons the icons of an iconSet.
	Bar   *DataBar
	Icons *IconSet
}

CondRule is a rule of a conditional format.

type DataBar

type DataBar struct {
	Min, Max Threshold
	Color    color.NRGBA
	// Gradient fades the bar to white, as Excel 2007 draws it.
	Gradient bool
	// HideValue hides the text of the cell.
	HideValue bool
}

DataBar is the bar of a data bar.

type Diff

type Diff struct {
	Color, Fill          color.NRGBA
	Bold, Italic, Strike Toggle
	// Underline is 0 to keep the style, 1 for a single line, 2 for a
	// double line and -1 for none.
	Underline int
	Borders   [4]Border
}

Diff is the change of the style of a cell that a rule makes, the dxf of Excel. A transparent color and a border without a width keep the style.

type Digit

type Digit struct {
	// Pixels is the width of the widest digit on the screen, in pixels at
	// 96 dots per inch, rounded to the nearest pixel. Calibri of 11
	// points (7.43 pixels), Arial of 10 points (7.41 pixels) and Century
	// Gothic of 9 points (6.65 pixels) all have digits of 7 pixels in
	// Excel.
	Pixels float64
	// Print is the advance of a digit that Excel prints, in points: the
	// advance at the size in whole pixels of 600 dots per inch, rounded to
	// a dot.
	Print float64
}

Digit is the width of a digit of the default font of a workbook, the unit of the widths of the columns of Excel.

func DigitOf

func DigitOf(f Font, def float64) Digit

DigitOf returns the digit of the font f. A font without a size has the size def.

func (Digit) Column

func (d Digit) Column(chars float64) float64

Column returns the width that Excel prints for a column of chars characters with their padding, in points (ECMA-376 Part 1, 18.3.1.13). Excel rounds the width to pixels of the screen, and prints the pixels in digits of the printer. For example, a column of the default width of 9.140625 characters of Calibri of 11 points is 64 pixels on the screen, 48 points, and Excel prints it 51.6 points wide.

func (Digit) DefaultColumn

func (d Digit) DefaultColumn(base float64) float64

DefaultColumn returns the width that Excel prints for a column of the default width, from the base width of base digits without the padding (ECMA-376 Part 1, 18.3.1.81): the pixels of the digits and of the padding of 5 pixels, rounded up to a multiple of 8 pixels.

type ExcelRows

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

ExcelRows gives the heights of the rows that Excel prints, for the default font of a workbook. Excel keeps the height of a row in pixels of the screen, and prints a row of h pixels as trunc(h × P / S) dots of 600 dots per inch (Sheet.RowDots). A picture across the rows takes h × P / S dots for each row, without the rounding. S is the default height of a row on the screen, in pixels, and P is the default height of a row on the printer, in dots, both for the default font. P is tmHeight + tmExternalLeading + 8 of the font at round(size × 600 / 72) pixels per em, as GDI gives them.

Excel 2024 prints the default height of Calibri of 11 points, 20 pixels, as 121 dots, 14.52 points, so a row of 15 points prints at 0.968 of its height. With Century Gothic of 9 points, S is 19 and P is 99, and the scale is 0.834.

Excel also fits a row to its cells, unless a person sets its height. The height of a line of text on the screen is S of its font, so a row of two lines of the default font prints as 2 × P dots.

func NewExcelRows

func NewExcelRows(db *svg.FontDatabase, def Font) *ExcelRows

NewExcelRows returns the heights of the rows of a workbook whose default font is def. A size of 0 is 11 points. It measures a font that measuredRows does not hold with the face of db that the layout draws it with, or estimates it when db is nil.

func (*ExcelRows) Default

func (e *ExcelRows) Default() float64

Default returns the height that Excel prints for a row of the default height, in points: P.

func (*ExcelRows) Fit

func (e *ExcelRows) Fit(sh *Sheet, styles []Style)

Fit sets the height of each row of sh whose Fit is set to the height of its cells, as Excel fits it when it opens the file: the highest cell, in lines of the screen height of its font. An empty cell takes one line. A row of a small font is lower than the default height. A row without cells keeps its height, and so does a row whose height is close to the estimate (fitSlack). Fit leaves out a merged cell of more than one row, and takes one line of a merged cell of one row. styles are the styles of the workbook.

func (*ExcelRows) Line added in v0.3.0

func (e *ExcelRows) Line(f Font) float64

Line returns the height that Excel prints for a line of a text that wraps in the font f, in points: S of the font, at the scale of the rows. A size of 0 is the size of the default font. Excel prints a line of Calibri of 11 points 14.52 points high, 1.32 times the size of the font.

func (*ExcelRows) Printed

func (e *ExcelRows) Printed(ht float64) float64

Printed returns the height that Excel prints for a row of ht points on the screen, in points, before Sheet.RowDots rounds it down to a dot.

func (*ExcelRows) Scale

func (e *ExcelRows) Scale() float64

Scale returns the ratio of the height that Excel prints to the height on the screen, for the lines of text in a row (Sheet.RowScale).

type Field

type Field struct {
	Kind FieldKind
	Text string
}

Field is a piece of a header or a footer: text, or a field that the page fills.

type FieldKind

type FieldKind uint8

FieldKind is the kind of a field of a header or a footer.

const (
	FieldText FieldKind = iota
	FieldPage
	FieldPages
	FieldSheet
	FieldTitle
)

The kinds of the fields. The page and the date of the printing are not known, so a date and a time are left out.

type Font

type Font struct {
	// Family is the name of the family, such as "Calibri".
	Family string
	// Generic is the generic family that follows Family: "serif",
	// "sans-serif" or "monospace". It is "sans-serif" when empty.
	Generic string
	// Size is the size in points, or 0 for the size of the default style.
	Size                 float64
	Bold, Italic, Strike bool
	// Underline is 0 for none, 1 for a single line and 2 for a double
	// line.
	Underline int
	// Color is the color of the text, or transparent for black.
	Color color.NRGBA
	// VertAlign is 0, or 1 for superscript and 2 for subscript.
	VertAlign int
}

Font is a font of a cell.

type HeaderFooter

type HeaderFooter struct {
	Left, Center, Right []Field
	// Font is the font of the text, or nil for the font of the default
	// style.
	Font *Font
}

HeaderFooter is a header or a footer: the text of its three parts.

func ParseHeaderFooter

func ParseHeaderFooter(s string) HeaderFooter

ParseHeaderFooter parses the text of a header or a footer of Excel, with its codes, such as "&LPage &P of &N&R&A" (ECMA-376 Part 1, 18.3.1.46). It reads the sections &L, &C and &R, the page &P, the pages &N, the sheet &A and the file &F. It leaves out the date &D, the time &T, the path &Z and the picture &G, and the codes of the fonts, except the first font and the first size, which become the font of the whole header.

func (HeaderFooter) Empty

func (hf HeaderFooter) Empty() bool

Empty reports whether the header or the footer shows nothing.

type IconSet

type IconSet struct {
	// Name is the name of the set of Excel, such as 3Arrows or
	// 4TrafficLights.
	Name string
	// Thresholds are the thresholds of the icons, the first one for the
	// lowest icon.
	Thresholds []Threshold
	// Reverse puts the icons in the other order, and HideValue hides the
	// text of the cell.
	Reverse, HideValue bool
}

IconSet is the icons of an icon set.

type Image

type Image struct {
	// Row and Col are the cell of the top left corner.
	Row, Col int
	// DX and DY are the offset of the corner in the cell, in points.
	DX, DY float64
	// Width and Height are the size, in points.
	Width, Height float64
	// Path is the path of the image in Workbook.Files, or "".
	Path string
	// Object is the name of the picture in Workbook.Objects, or "".
	Object string
	// Label is the text of a frame that stands for a picture that the
	// package cannot show, such as a chart, when Path and Object are
	// empty.
	Label string
}

Image is an image or a chart on a sheet, anchored at a cell.

type Kind

type Kind uint8

Kind is the kind of the value of a cell. The alignment General aligns a number to the right, a boolean and an error to the center, and text to the left.

const (
	KindText Kind = iota
	KindNumber
	KindBool
	KindError
)

The kinds of the values.

type Measure added in v0.3.0

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

Measure measures text in Arial or Liberation Sans as ArialTextWidth does, and measures a character past U+017F with the advance of a face of a font database: the face of the family when it draws the character, or else the face that Covering finds, which the layout draws it with too. A character that no face draws takes the width that ArialTextWidth gives it. A Measure is not safe for concurrent use.

func NewMeasure added in v0.3.0

func NewMeasure(db *svg.FontDatabase, first int, family string) *Measure

NewMeasure returns a Measure for the family of db, whose first faces come from the font files of a program (fontdb.Load). A nil db gives the widths of ArialTextWidth.

func (*Measure) ArialTextWidth added in v0.3.0

func (m *Measure) ArialTextWidth(s string, size float64) float64

ArialTextWidth returns the width in points of the text s of the size size.

func (*Measure) PixelTextWidth added in v0.5.0

func (m *Measure) PixelTextWidth(s string, ppem, pixel float64) float64

PixelTextWidth returns the width in points of the text s as LibreOffice measures the text of a cell on the screen: each character is a whole number of pixels wide in a font of ppem pixels to the em, and a pixel is pixel points wide.

type Operand

type Operand struct {
	Number float64
	Text   string
	IsText bool
}

Operand is a value of a rule: a number, or a text.

type Options

type Options struct {
	// Limits bound the work. A zero field takes its default.
	Limits ivy.Limits
	// Logger receives the log, or nil.
	Logger *slog.Logger
	// Paper is the paper of the empty page of a workbook without sheets,
	// the paper of ivy.Config. The zero Paper keeps DefaultPage (D32).
	Paper ivy.Paper
}

Options are the options of Source.

type Page

type Page struct {
	// Width and Height are the size of the paper in portrait.
	Width, Height float64
	// Landscape turns the paper.
	Landscape bool
	// Top, Right, Bottom and Left are the margins.
	Top, Right, Bottom, Left float64
	// Header and Footer are the distances of the header from the top of
	// the paper and of the footer from its bottom.
	Header, Footer float64
	// Scale is the scale of the cells, such as 0.5, or 0 for 1. Excel
	// takes a scale from 10% to 400%.
	Scale float64
	// Fit sets the scale so that the cells fit on FitWidth pages across
	// and FitHeight pages down. A count of 0 sets no bound.
	Fit                 bool
	FitWidth, FitHeight int
	// CenterH centers the cells on the page across, and CenterV centers
	// them down the page.
	CenterH, CenterV bool
	// ScaleHeaderFooter scales the text of the header and the footer with
	// the cells, as Excel does unless a sheet asks otherwise.
	ScaleHeaderFooter bool
	// HeaderArea and FooterArea are the heights of the areas of the header
	// and the footer between the margins and the cells, as OpenDocument
	// has them. With ScaleHeaderFooter, the scale of the cells scales
	// them too, as LibreOffice does.
	HeaderArea, FooterArea float64
	// OverThenDown prints the pages in the order over, then down: the
	// first rows of each band of columns, then the next rows. Without it,
	// the pages go down, then over: all the rows of the first band, then
	// of the next band.
	OverThenDown bool
	// CommentsAtEnd prints the comments of the cells on pages after the
	// cells.
	CommentsAtEnd bool
}

Page is the setup of the page of a sheet. The sizes are in points.

func (*Page) SetPaper

func (p *Page) SetPaper(paper ivy.Paper)

SetPaper sets the paper of the page to paper, the paper of a program for a sheet whose file gives none, in the orientation of paper. The margins stay. A zero paper keeps the page (D32). A side of the paper stays from 1 inch to 200 inches.

type Range

type Range struct {
	Row0, Col0, Row1, Col1 int
}

Range is a rectangle of cells, from the cell (Row0, Col0) to the cell (Row1, Col1), inclusive.

type Row

type Row struct {
	Index int
	// Height is the height in points, or 0 for the default height. The
	// layout makes a row taller when its text needs it.
	Height float64
	// Hidden hides the row.
	Hidden bool
	// Fit asks ExcelRows.Fit to fit the height of the row to its cells.
	Fit bool
	// Style is the style of the cells of the row that the sheet does not
	// hold, or 0.
	Style int
	// Cells are the cells of the row, sorted by Col, each column once.
	Cells []Cell
}

Row is a row of a sheet.

type Run

type Run struct {
	Text string
	// Font is the font of the run, or nil for the font of the cell.
	Font *Font
}

Run is a run of rich text.

type ScalePoint

type ScalePoint struct {
	Threshold
	Color color.NRGBA
}

ScalePoint is a point of a color scale.

type Sheet

type Sheet struct {
	// Name is the name of the sheet, as its tab shows it.
	Name string
	// DefaultColWidth and DefaultRowHeight are the sizes of a column and of
	// a row without a size of their own, in points.
	DefaultColWidth, DefaultRowHeight float64
	// Cols holds the columns with a size or a style of their own, sorted
	// by Min, without overlaps.
	Cols []Col
	// Rows holds the rows with a cell, a size or a style, sorted by Index,
	// each index once.
	Rows []Row
	// Merges are the merged cells.
	Merges []Range
	// Page is the setup of the page.
	Page Page
	// Gridlines draws the light lines between the cells.
	Gridlines bool
	// PrintAreas are the ranges to print. Without one, the page shows the
	// cells that hold data or a visible style.
	PrintAreas []Range
	// TitleRows and TitleCols are the print titles, or nil.
	TitleRows, TitleCols *Span
	// RowBreaks and ColBreaks are the manual page breaks: the index of a
	// row or a column that starts a new page.
	RowBreaks, ColBreaks []int
	// Header and Footer are the header and the footer of the pages.
	Header, Footer HeaderFooter
	// Images are the images and the charts of the sheet.
	Images []Image
	// Note is a line that the page shows after the cells, such as the
	// note that a reader stopped at a limit.
	Note string
	// FixedRows keeps the height of each row, as Excel prints it: a line of
	// text that is higher than its row crosses the edges of the row. Without
	// it, the row grows to hold the line.
	FixedRows bool
	// RowScale is the ratio of the height of a line of text that Excel
	// prints to its height on the screen, for the lines of a row whose
	// height FixedRows keeps (ExcelRows.Scale). 0 takes 0.968, the scale
	// of Calibri of 11 points.
	RowScale float64
	// Lines gives the height of a line of a text that wraps, as Excel
	// prints it, in a sheet whose FixedRows is set (ExcelRows.Line).
	// Without it, a line takes the normal height of its font.
	Lines *ExcelRows
	// RowDots rounds the height of each row down to a dot of 600 dots per
	// inch, as Excel prints the grid of the cells. A picture across the
	// rows takes their heights without the rounding.
	RowDots bool
	// CondFormats are the conditional formats of the cells.
	CondFormats []CondFormat
	// Comments are the comments of the cells, which the pages show after
	// the cells when Page.CommentsAtEnd is set, as Excel prints them.
	Comments []Comment
}

Sheet is one sheet. The indexes of the rows and the columns count from 0.

func (*Sheet) ColWidth

func (sh *Sheet) ColWidth(i int) float64

ColWidth returns the width of the column i in points, or 0 if it is hidden. The columns must be sorted, as Sort sorts them.

func (*Sheet) RowHeight

func (sh *Sheet) RowHeight(i int) float64

RowHeight returns the height of the row i in points, or 0 if it is hidden, without the rounding of RowDots: the height that a picture across the row takes. The rows must be sorted, as Sort sorts them.

func (*Sheet) Sort

func (sh *Sheet) Sort()

Sort sorts the rows of the sheet, the cells of each row and the columns, and merges the rows and the cells with the same index, the later one first. A reader that reads them out of order calls it.

type Span

type Span struct {
	First, Last int
}

Span is a run of rows or columns, from First to Last, inclusive.

type Style

type Style struct {
	Font Font
	// Fill is the color of the background, or transparent.
	Fill color.NRGBA
	// Borders are the borders: top, right, bottom and left.
	Borders [4]Border
	// HAlign is the horizontal alignment: "" for General, "left",
	// "center", "right", "justify", "fill", "distributed" or
	// "centerContinuous".
	HAlign string
	// VAlign is the vertical alignment: "" or "bottom", "top", "center",
	// "justify" or "distributed".
	VAlign string
	// Wrap breaks the text into lines.
	Wrap bool
	// Indent is the indent of the text in points (IndentStep). The scale
	// of the page does not apply to it, as Excel prints it.
	Indent float64
	// Rotation is the angle of the text in degrees, counterclockwise, from
	// -90 to 90, or 255 for letters stacked from top to bottom.
	Rotation int
	// Shrink makes the text smaller to fit the cell.
	Shrink bool
}

Style is the style of a cell.

type Threshold

type Threshold struct {
	Kind  string
	Value float64
	GTE   bool
}

Threshold is a value of a color scale, a data bar or an icon set: Kind is min, max, num, percent or percentile, with Value. GTE takes a value equal to the threshold, for an icon set.

type Toggle

type Toggle int8

Toggle is the change of a flag of a style: Keep, On or Off.

const (
	Keep Toggle = iota
	On
	Off
)

The changes of a flag.

type Workbook

type Workbook struct {
	// Sheets are the sheets to print, in order. A reader leaves out the
	// hidden sheets.
	Sheets []*Sheet
	// Styles are the styles of the cells. Styles[0] is the default style,
	// whose font is the font of the whole workbook. A workbook without
	// styles takes DefaultStyle.
	Styles []Style
	// Title is the title of the workbook, for the header and the footer.
	Title string
	// Files are the files that the images of the sheets name, such as
	// "media/image1.png", with their content.
	Files map[string][]byte
	// Objects are the pictures that the format draws itself, such as the
	// charts, by name. An image whose Object is set shows one.
	Objects map[string]layout.Object
	// Excel is set for a workbook of Excel. Its sheets print as Excel
	// prints them: a sheet without a print area from its cell A1, and the
	// text of a footer a little above the footer margin.
	Excel bool
	// FromA1 prints a sheet without a print area from its cell A1, as
	// LibreOffice prints it, without the other changes of Excel. Without it
	// or Excel, such a sheet prints its used range.
	FromA1 bool
}

Workbook is a spreadsheet: its sheets and the styles that their cells share.

func (*Workbook) Source

func (wb *Workbook) Source(ctx context.Context, opts Options) (layout.Source, error)

Source converts the workbook into the source of the layout: one HTML document for each sheet that prints something, in order. A workbook that prints nothing gives one empty page.

A sheet shows at most Limits.MaxObjects / 4 cells and rows in all, with the bands of its columns. At the limit, the sheet stops, its last line says so, and the log has a warning. The sheets after it still show.

A sheet of 32 pages or more is also cut into parts of about 16 pages, which the book lays out on their own (D55). The Splitter of the source gives the parts, and its FS gives their documents.

Jump to

Keyboard shortcuts

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