Documentation
¶
Overview ¶
Package export is part of the go-fastreport library, a pure Go port of FastReport .NET.
Index ¶
- func ByteToHex(b byte) string
- func ExcelCellRef(col, row int) string
- func ExcelColName(col int) string
- func FloatToString(value float64, digits int) string
- func FormatFloat(v float64, decimals int, stripZeros bool) string
- func GetColorFromFill(fill style.Fill) color.RGBA
- func GetPageHeight(page ReportPageDims) float32
- func GetPageWidth(page ReportPageDims) float32
- func GetRFCDate(datetime time.Time) string
- func HTMLColor(c color.RGBA) string
- func HTMLColorToRGB(s string) (r, g, b uint8, ok bool)
- func HTMLString(s string) string
- func HtmlURL(value string) string
- func InchesToPixels(in float32) float32
- func MMToPixels(mm float32) float32
- func ParsePageNumbers(s string, totalPages int) ([]int, error)
- func PixelsToInches(px float32) float32
- func PixelsToMM(px float32) float32
- func PixelsToPoints(px float32) float32
- func PointsToPixels(pt float32) float32
- func QuotedPrintable(values []byte) string
- func RGBToHTMLColor(r, g, b uint8) string
- func ReverseString(str string) string
- func Round(v float64, places int) float64
- func XMLString(s string) string
- type ExportBase
- func (e *ExportBase) AddGeneratedFile(path string)
- func (e *ExportBase) CreateTempFile() (*os.File, error)
- func (e *ExportBase) DeleteTempFiles()
- func (e *ExportBase) Deserialize(r report.Reader)
- func (e *ExportBase) Export(pages *preview.PreparedPages, w io.Writer, exp Exporter) error
- func (e *ExportBase) ExportAndZip(pages *preview.PreparedPages, fileName string, exp Exporter, w io.Writer) error
- func (e *ExportBase) ExportToFile(pages *preview.PreparedPages, path string, exp Exporter) error
- func (e *ExportBase) GeneratedFiles() []string
- func (e *ExportBase) Pages() []int
- func (e *ExportBase) Serialize(w report.Writer)
- type ExportFormat
- type Exporter
- type ExportsOptions
- type NoopExporter
- type PageRange
- type ReportPageDims
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteToHex ¶
ByteToHex converts a single byte to a two-character uppercase hex string. Matches C# ExportUtils.ByteToHex.
func ExcelCellRef ¶
ExcelCellRef returns an Excel cell reference like "A1" for the given zero-based column and 1-based row.
func ExcelColName ¶
ExcelColName converts a zero-based column index to an Excel column letter(s). 0→"A", 25→"Z", 26→"AA", etc.
func FloatToString ¶
FloatToString rounds value to digits decimal places and formats it with a dot decimal separator (invariant culture), matching C# ExportUtils.FloatToString.
func FormatFloat ¶
FormatFloat formats v with the given number of decimal places, stripping trailing zeros when stripZeros is true.
func GetColorFromFill ¶
GetColorFromFill extracts a representative colour from fill. Matches C# ExportUtils.GetColorFromFill.
func GetPageHeight ¶
func GetPageHeight(page ReportPageDims) float32
GetPageHeight returns the printable height of page in millimetres. When IsUnlimitedHeight() is true the page has no fixed height; PaperHeight holds the accumulated content height set by the engine. Matches C# ExportUtils.GetPageHeight.
func GetPageWidth ¶
func GetPageWidth(page ReportPageDims) float32
GetPageWidth returns the printable width of page in millimetres. Matches C# ExportUtils.GetPageWidth (UnlimitedWidth is not exposed in the Go port).
func GetRFCDate ¶
GetRFCDate formats datetime as an RFC 2822 / HTTP date string, replacing the "GMT" suffix with the local UTC offset when non-zero. Matches C# ExportUtils.GetRFCDate.
func HTMLColor ¶
HTMLColor returns a CSS colour string for c. When alpha < 255 it returns an rgba() value; otherwise rgb(). Matches C# ExportUtils.HTMLColor.
func HTMLColorToRGB ¶
HTMLColorToRGB parses a CSS hex colour string (#RGB or #RRGGBB) and returns the r, g, b components. Returns (0,0,0) and false on parse error.
func HTMLString ¶
HTMLString escapes s for safe inclusion in HTML text content. It replaces &, <, >, " and non-breaking space (0xa0).
func HtmlURL ¶
HtmlURL percent-encodes characters in value that are not safe in HTML URLs. Matches C# ExportUtils.HtmlURL (non-DOTNET_4 branch).
func InchesToPixels ¶
InchesToPixels converts inches to pixels (96 dpi).
func MMToPixels ¶
MMToPixels converts millimetres to pixels (at 96 dpi).
func ParsePageNumbers ¶
ParsePageNumbers parses a page range string like "1,3-5,12" and returns the corresponding zero-based page indices (sorted, de-duplicated). totalPages is the total number of pages (used to resolve trailing "-" ranges). An empty string returns (nil, nil) — the caller should treat this as "all pages".
func PixelsToInches ¶
PixelsToInches converts pixels (96 dpi) to inches.
func PixelsToMM ¶
PixelsToMM converts pixels (at 96 dpi) to millimetres.
func PixelsToPoints ¶
PixelsToPoints converts pixels (96 dpi) to PostScript points (72 dpi).
func PointsToPixels ¶
PointsToPixels converts PostScript points to pixels (96 dpi).
func QuotedPrintable ¶
QuotedPrintable encodes values using Quoted-Printable (RFC 2045). Lines are soft-wrapped at 73 characters with "=\r\n". Matches C# ExportUtils.QuotedPrintable.
func RGBToHTMLColor ¶
RGBToHTMLColor returns a CSS hex colour string like "#RRGGBB".
func ReverseString ¶
ReverseString returns str with its characters in reverse order. Matches C# ExportUtils.ReverseString.
Types ¶
type ExportBase ¶
type ExportBase struct {
// PageRange controls which pages are included.
PageRange PageRange
// PageNumbers is a comma/range string like "1,3-5,12".
// Used when PageRange == PageRangeCustom. Empty means all pages.
PageNumbers string
// CurPage is the 1-based page number to export when PageRange == PageRangeCurrent.
CurPage int
// Zoom is a scaling factor applied to the exported content (default 1.0).
// Matches C# ExportBase.Zoom.
Zoom float32
// OnProgress is an optional callback invoked once per page during export.
// It receives the current 1-based page number and the total page count.
// This is the Go equivalent of C# ReportSettings.OnProgress (called from
// ExportBase.Export for each page when ShowProgress is true).
// C# ref: FastReport.Base/Export/ExportBase.cs, Export() method.
OnProgress func(page, total int)
// HasMultipleFiles indicates that this exporter produces multiple output files
// (e.g. one per page). Mirrors C# ExportBase.HasMultipleFiles (line 149).
HasMultipleFiles bool
// ShiftNonExportable indicates that non-exportable bands should shift
// subsequent bands up. Mirrors C# ExportBase.ShiftNonExportable (line 159).
ShiftNonExportable bool
// contains filtered or unexported fields
}
ExportBase is the base for all export filters. Concrete exporters embed ExportBase and override the hook methods.
Usage:
type MyExport struct { export.ExportBase }
func (m *MyExport) ExportBand(band *preview.PreparedBand) { ... }
func (m *MyExport) Export(pages *preview.PreparedPages, w io.Writer) error {
return m.ExportBase.Export(pages, w, m)
}
func NewExportBase ¶
func NewExportBase() ExportBase
NewExportBase creates an ExportBase with sensible defaults.
func (*ExportBase) AddGeneratedFile ¶
func (e *ExportBase) AddGeneratedFile(path string)
AddGeneratedFile appends path to the generated files list.
func (*ExportBase) CreateTempFile ¶
func (e *ExportBase) CreateTempFile() (*os.File, error)
CreateTempFile creates a new temporary file in the OS temp directory under a "TempExport" subdirectory. The file is tracked and deleted by DeleteTempFiles. Matches C# ExportBase.CreateTempFile.
func (*ExportBase) DeleteTempFiles ¶
func (e *ExportBase) DeleteTempFiles()
DeleteTempFiles closes and removes all temporary files created via CreateTempFile. Matches C# ExportBase.DeleteTempFiles.
func (*ExportBase) Deserialize ¶
func (e *ExportBase) Deserialize(r report.Reader)
Deserialize reads ExportBase settings from r. Mirrors C# ExportBase.Deserialize (ExportBase.cs).
func (*ExportBase) Export ¶
func (e *ExportBase) Export(pages *preview.PreparedPages, w io.Writer, exp Exporter) error
Export drives the export lifecycle. pages is the PreparedPages produced by the report engine. w is the output writer (available to the concrete exporter via its own field). exp is the concrete exporter — typically the struct that embeds ExportBase.
func (*ExportBase) ExportAndZip ¶
func (e *ExportBase) ExportAndZip(pages *preview.PreparedPages, fileName string, exp Exporter, w io.Writer) error
ExportAndZip exports pages to a temporary file, packages the file into a ZIP archive, and writes the archive to w. fileName is used as the entry name inside the ZIP (e.g. "report.html").
This mirrors the C# ExportBase.ExportAndZip(Report, Stream) pattern:
- Create a temp directory.
- Export to a file inside the temp dir using ExportToFile.
- Zip the file into a ZIP archive.
- Write the archive to w.
- Clean up the temp dir.
C# reference: ExportBase.cs ExportAndZip lines 598-614.
func (*ExportBase) ExportToFile ¶
func (e *ExportBase) ExportToFile(pages *preview.PreparedPages, path string, exp Exporter) error
ExportToFile exports pages using exp, writing the output to the given file path. The file is created (or truncated) before calling Export, and closed on return. This mirrors the C# ExportBase.Export(Report, string fileName) convenience overload.
C# reference: ExportBase.cs Export(Report, string fileName) lines 577-585.
func (*ExportBase) GeneratedFiles ¶
func (e *ExportBase) GeneratedFiles() []string
GeneratedFiles returns the list of output file paths produced by this export. Matches C# ExportBase.GeneratedFiles.
func (*ExportBase) Pages ¶
func (e *ExportBase) Pages() []int
Pages returns the resolved zero-based page indices (populated after Export).
func (*ExportBase) Serialize ¶
func (e *ExportBase) Serialize(w report.Writer)
Serialize writes non-default ExportBase settings to w. Mirrors C# ExportBase.Serialize (ExportBase.cs line 378).
type ExportFormat ¶
type ExportFormat string
ExportFormat identifies a known output format by name (case-insensitive). Examples: "PDF", "HTML", "Image".
const ( ExportFormatPDF ExportFormat = "PDF" ExportFormatHTML ExportFormat = "HTML" ExportFormatImage ExportFormat = "Image" )
type Exporter ¶
type Exporter interface {
// Start is called once before any pages are exported.
Start() error
// ExportPageBegin is called at the start of each page.
ExportPageBegin(page *preview.PreparedPage) error
// ExportBand is called for each band on the page.
ExportBand(band *preview.PreparedBand) error
// ExportPageEnd is called at the end of each page.
ExportPageEnd(page *preview.PreparedPage) error
// Finish is called once after all pages are exported.
Finish() error
}
Exporter is the interface that concrete export filters implement. ExportBase.Export calls these hooks in order for each page/band.
type ExportsOptions ¶
type ExportsOptions struct {
// AllowedExports lists the export formats the user is allowed to choose.
// An empty slice means all formats are allowed.
AllowedExports []ExportFormat
// HideExports lists export formats that should be hidden from the UI even
// if they are technically available.
HideExports []ExportFormat
// DefaultFormat is the pre-selected format when the user opens the export dialog.
DefaultFormat ExportFormat
// ShowProgress controls whether a progress indicator is shown during export.
ShowProgress bool
// OpenAfterExport controls whether the exported file is opened automatically.
OpenAfterExport bool
}
ExportsOptions holds report-level export configuration. It is the Go equivalent of FastReport.Utils.ExportsOptions.
AllowedExports and HideExports control which formats appear in the UI; DefaultFormat selects the pre-selected format in a dialog. These fields are advisory for host applications that present an export UI — the programmatic export API does not enforce them.
func NewExportsOptions ¶
func NewExportsOptions() *ExportsOptions
NewExportsOptions returns ExportsOptions with sensible defaults.
func (*ExportsOptions) Deserialize ¶
func (o *ExportsOptions) Deserialize(r report.Reader)
Deserialize reads ExportsOptions properties.
func (*ExportsOptions) IsAllowed ¶
func (o *ExportsOptions) IsAllowed(format ExportFormat) bool
IsAllowed returns true if format is in the AllowedExports list (or the list is empty).
func (*ExportsOptions) IsHidden ¶
func (o *ExportsOptions) IsHidden(format ExportFormat) bool
IsHidden returns true if format is in the HideExports list.
func (*ExportsOptions) Serialize ¶
func (o *ExportsOptions) Serialize(w report.Writer)
Serialize writes ExportsOptions properties that differ from defaults.
type NoopExporter ¶
type NoopExporter struct{}
NoopExporter is an Exporter with empty hook implementations. Embed it in concrete exporters to avoid implementing unused hooks.
func (NoopExporter) ExportBand ¶
func (NoopExporter) ExportBand(*preview.PreparedBand) error
func (NoopExporter) ExportPageBegin ¶
func (NoopExporter) ExportPageBegin(*preview.PreparedPage) error
func (NoopExporter) ExportPageEnd ¶
func (NoopExporter) ExportPageEnd(*preview.PreparedPage) error
func (NoopExporter) Finish ¶
func (NoopExporter) Finish() error
func (NoopExporter) Start ¶
func (NoopExporter) Start() error
type ReportPageDims ¶
type ReportPageDims interface {
GetPaperWidth() float32
GetPaperHeight() float32
IsUnlimitedHeight() bool
}
ReportPageDims is a minimal interface that both *reportpkg.ReportPage and any test stub must satisfy. It avoids an import cycle between export and reportpkg.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package csv implements a CSV export filter for go-fastreport.
|
Package csv implements a CSV export filter for go-fastreport. |
|
Package html is part of the go-fastreport library, a pure Go port of FastReport .NET.
|
Package html is part of the go-fastreport library, a pure Go port of FastReport .NET. |
|
Package image provides PNG image export for go-fastreport.
|
Package image provides PNG image export for go-fastreport. |
|
Package pdf is part of the go-fastreport library, a pure Go port of FastReport .NET.
|
Package pdf is part of the go-fastreport library, a pure Go port of FastReport .NET. |
|
core
Package core is part of the go-fastreport library, a pure Go port of FastReport .NET.
|
Package core is part of the go-fastreport library, a pure Go port of FastReport .NET. |
|
Package rtf implements an RTF export filter for go-fastreport.
|
Package rtf implements an RTF export filter for go-fastreport. |
|
Package svg implements an SVG export filter for go-fastreport.
|
Package svg implements an SVG export filter for go-fastreport. |
|
Package xlsx implements an Excel XLSX export filter for go-fastreport.
|
Package xlsx implements an Excel XLSX export filter for go-fastreport. |