csv

package
v0.0.0-...-83b8ea0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package csv implements a CSV export filter for go-fastreport. It extracts tabular text data from prepared pages, grouping objects by their Y coordinate (row) and sorting each row left-to-right by X. One CSV row is written per band row; non-text objects are skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

type Exporter struct {
	export.ExportBase

	// Separator is the CSV field delimiter (default ',').
	Separator rune
	// Quote is the CSV quoting character (default '"').
	Quote rune
	// HeaderRow controls whether a header row with band and object names
	// is emitted before data rows (default true).
	HeaderRow bool
	// contains filtered or unexported fields
}

Exporter produces CSV output from a PreparedPages collection.

Each band row in the prepared pages becomes one CSV row. Objects within a band are grouped by their Y coordinate and then sorted left-to-right by X coordinate to produce column order. Only text-bearing objects (ObjectTypeText, ObjectTypeHtml, ObjectTypeRTF, ObjectTypeCheckBox) are emitted; all other object types are skipped.

func NewExporter

func NewExporter() *Exporter

NewExporter creates an Exporter with sensible defaults.

func (*Exporter) Export

func (e *Exporter) Export(pages *preview.PreparedPages, w io.Writer) error

Export writes the PreparedPages as CSV to w.

func (*Exporter) ExportBand

func (e *Exporter) ExportBand(b *preview.PreparedBand) error

ExportBand converts a single band into one or more CSV rows.

Strategy:

  1. Collect all text objects from the band.
  2. Group them by Y coordinate (with a small epsilon tolerance so objects that differ by less than 1 pixel are treated as the same row).
  3. Within each Y-group sort by X (left-to-right).
  4. Emit one CSV row per Y-group.

func (*Exporter) ExportPageBegin

func (e *Exporter) ExportPageBegin(_ *preview.PreparedPage) error

ExportPageBegin is a no-op for CSV (pages are transparent to the format).

func (*Exporter) ExportPageEnd

func (e *Exporter) ExportPageEnd(_ *preview.PreparedPage) error

ExportPageEnd is a no-op for CSV.

func (*Exporter) FileExtension

func (e *Exporter) FileExtension() string

FileExtension returns the recommended file extension.

func (*Exporter) Finish

func (e *Exporter) Finish() error

Finish flushes the CSV writer. When HeaderRow is true, it first writes the header then all accumulated rows.

func (*Exporter) Name

func (e *Exporter) Name() string

Name returns the human-readable name of this export format.

func (*Exporter) Start

func (e *Exporter) Start() error

Start initialises the csv.Writer and clears accumulated state.

Jump to

Keyboard shortcuts

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