workbook

package
v0.92.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

workbook

Renders a canvas dashboard as an Excel workbook.

The input is a CanvasWorkbookExportRequest (see proto/rill/runtime/v1/workbook.proto), which the browser builds from the data it already displays for a canvas: the dashboard sheets with their blocks (native charts, PNG snapshots, KPI values, table previews, text), and the data sheets the charts and tables are bound to. The package validates the request against size caps, lays the blocks out on a uniform cell grid that mirrors the canvas geometry, writes each data sheet as a typed Excel table, and binds every native chart to the cells of its data sheet with excelize. Data sheets are written with excelize's stream writer, so their rows go to a temporary file instead of the in-memory sheet model; the total number of cells a request may hold is capped (MaxCells).

Write is the only entry point. It returns a ValidationError for requests that can't be rendered (unknown references, caps exceeded, bad images), which callers map to a client error; see runtime/server/workbook.go.

Documentation

Overview

Package workbook renders a canvas dashboard, described by a CanvasWorkbookExportRequest, as an Excel workbook.

Index

Constants

View Source
const (
	MaxSheets          = 200
	MaxRowsPerSheet    = 100_000
	MaxColumnsPerSheet = 200
	// Cells across all data sheets: the request is parsed into memory before the sheets are streamed out.
	MaxCells      = 1_000_000
	MaxImageBytes = 32 << 20
)

Caps on the size of a request. The browser builds a request from data it already holds under its own claims, so the caps protect the runtime from oversized workbooks rather than from untrusted content.

Variables

This section is empty.

Functions

func IsValidationError

func IsValidationError(err error) bool

IsValidationError reports whether err is a ValidationError.

func Write

Write validates req and writes it to w as an .xlsx file.

Types

type ValidationError

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

ValidationError is returned when a request can't be rendered as a workbook. Handlers should map it to a client error.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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