Documentation
¶
Overview ¶
Package excel provides Excel import and export for the pulse I/O pipeline.
Package excel provides Excel import and export for the pulse I/O pipeline.
Index ¶
- Constants
- type Option
- type Reader
- func (r *Reader) Close() error
- func (r *Reader) ReadHeader() ([]string, error)
- func (r *Reader) ReadOverlays() ([]*types.OverlayLayer, error)
- func (r *Reader) ReadRows(ctx context.Context, fn func(row []string) error) error
- func (r *Reader) Reset() error
- func (r *Reader) SheetNames() ([]string, error)
- type Writer
Constants ¶
const OverlaySheetPrefix = "__overlay_"
OverlaySheetPrefix is the reserved sheet-name prefix every embedded overlay sheet carries. Authors filter overlay sheets with strings.HasPrefix(name, OverlaySheetPrefix). Author-supplied sheets MUST NOT start with this prefix; the prefix is reserved for the engine.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads tabular data from an Excel (.xlsx) file.
func NewReaderFromBytes ¶
NewReaderFromBytes creates an Excel reader from raw bytes.
func (*Reader) ReadHeader ¶
ReadHeader returns the column names from the first row.
func (*Reader) ReadOverlays ¶ added in v0.19.0
func (r *Reader) ReadOverlays() ([]*types.OverlayLayer, error)
ReadOverlays walks every "__overlay_*" sheet on the workbook and reconstructs the embedded []*types.OverlayLayer slice. Returns nil (not error) when the workbook carries no overlay sheets — the contract is "no overlays present" rather than "field missing is an error" (mirrors the Arrow / Parquet ReadOverlays surface).
Round-trip is best-effort per research/export-embedding-shape.md § 5.3 — Excel coerces some numeric edge cases (NaN, Inf, very-small / very-large floats) to text strings on write, so the reader treats each cell as a float64 best-effort and tolerates ±1 ULP on numeric values. The shape (kind / scope / ref / payload shape / per-entry keys / per-cell present flag / summary slots) is preserved exactly.
Sheet emission order is the source of truth for layer slot order (matches Response.Overlays slot order at export time). The reader returns layers in the order it discovers overlay sheets on the workbook.
func (*Reader) SheetNames ¶ added in v0.19.0
SheetNames returns the list of sheet names on the workbook. Overlay sheets ride alongside the host data sheet with the OverlaySheetPrefix reserved namespace ("__overlay_*"); callers introspecting the overlay layout filter by HasPrefix on the prefix constant.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes tabular data to an Excel (.xlsx) file.
func (*Writer) Close ¶
Close flushes and writes the workbook to the target path. When SetOverlays handed the writer a non-empty layer slice the writer appends one "__overlay_<layer_name>" sheet per layer after the host sheet's stream writer is flushed and before WriteToBuffer; see writeOverlaySheets in overlay.go for the layout rules.
func (*Writer) SetOverlays ¶ added in v0.19.0
func (w *Writer) SetOverlays(layers []*types.OverlayLayer)
SetOverlays records the Response.Overlays layers the export pipeline wants the writer to embed in the workbook. Each layer lands on a dedicated sheet named "__overlay_<layer_name>" alongside the host data sheet per research/export-embedding-shape.md § 5 (one sheet per layer; the double-underscore prefix reserves the namespace). nil or empty layers leave the workbook byte-identical to a pre-overlay export (no overlay sheets land). Implements pio.OverlayAwareWriter.
Sheet emission happens at Close() time so the host sheet's stream writer can finish writing before the overlay sheets are appended. Must be called BEFORE Close.
func (*Writer) SetPulseSchema ¶ added in v0.2.0
SetPulseSchema records the source .pulse schema. Implements pio.SchemaAwareWriter so ExportJob can hand the writer typed values for decimal128 columns.
func (*Writer) WriteHeader ¶
WriteHeader writes column names as the first row.