export

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 7 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 export writes tabular data as CSV (RFC 4180, guarded against formula injection) or XLSX.

Index

Constants

View Source
const (
	CSV  = "csv"
	XLSX = "xlsx"
)

Format names the supported export formats.

View Source
const XLSXSupported = true

XLSXSupported reports whether this build can write Excel files (64-bit builds only: the Excel library doesn't compile for 32-bit CPUs).

Variables

This section is empty.

Functions

func CellText

func CellText(v any) string

CellText renders a cell as CSV text: ISO 8601 UTC timestamps, plain numbers.

func GuardCell

func GuardCell(s string) string

GuardCell prefixes cells that a spreadsheet would read as a formula with an apostrophe, so exported data can't run anything when opened (CSV/formula injection).

func WriteCSV

func WriteCSV(w io.Writer, t Table, withBOM bool) error

WriteCSV writes the table as RFC 4180 CSV in UTF-8, with a header row. withBOM prepends a BOM.

func WriteXLSX

func WriteXLSX(w io.Writer, t Table) error

WriteXLSX writes the table as one sheet: bold frozen header, autofilter, typed cells (dates as dates, numbers as numbers) and hyperlinks. Rows go through the streaming writer so a very large export stays in bounded memory.

Types

type Link struct {
	URL  string
	Text string
}

Link is a hyperlink cell.

type Table

type Table struct {
	Sheet   string
	Headers []string
	Rows    [][]any
}

Table is what gets exported. Cells are string, int, int64, float64, bool, time.Time, Link or nil.

Jump to

Keyboard shortcuts

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