What is go-fastreport?
go-fastreport ports FastReport .NET Open Source's reporting model to Go: bands, objects, an expression language, and FRX serialization, plus data binding and export. The usual workflow is to design a report visually in FastReport .NET, save it as an .frx file, then load and run that same template from a Go program — no .NET runtime required at run time.
It is pure Go with no CGo dependencies, so it cross-compiles and runs anywhere Go does. The engine has been smoke tested against 50+ real FastReport .frx sample files.
- Open source
- MIT licensed
- Pure Go
- No CGo
- Go 1.23+
- Free
Features
Band-based layout engine
ReportTitle, PageHeader, PageFooter, DataBand, GroupHeader, GroupFooter, ChildBand, OverlayBand, and more — 13 band types in total.
Four data sources
JSON, XML, CSV, and SQL via database/sql, plus custom in-memory adapters that satisfy the same interface.
Expression evaluator
Bracket-expression syntax [DataSource.Field] with built-in functions like IIF and Format.
FRX serialization
Read and write FastReport XML (.frx) report definitions, including real FastReport sample files.
HTML, PDF, PNG export
Every exporter supports page-range selection, so you can export a subset of a prepared report.
CrossView, barcodes, and more
A pivot-table object (crossview), and barcode rendering for QR, Code128, Code39, EAN, DataMatrix, Aztec, and PDF417.
Quick start
Requires Go 1.23+.
go get github.com/andrewloable/go-fastreport
The common workflow: design a report in FastReport .NET, save it as an .frx file, then load it at runtime and bind a JSON data source.
r := reportpkg.NewReport()
r.Load("report.frx")
// Register parameters and a JSON data source keyed by alias.
// The engine resolves DataBand.DataSource="employees" to this
// source automatically, matching how FastReport .NET wires data.
ds := jsondata.New("employees")
ds.SetJSON(employeeJSON)
ds.Init()
dict := r.Dictionary()
dict.AddParameter(&data.Parameter{Name: "ReportTitle", Value: "Employee Directory"})
dict.AddDataSource(ds)
e := engine.New(r)
e.Run(engine.DefaultRunOptions())
exp := html.NewExporter()
exp.Title = r.Info.Name
exp.Export(e.PreparedPages(), os.Stdout)
A complete, runnable version lives in examples/frx_json. Other examples cover building a report entirely in code and using each data source standalone.
View go-fastreport on GitHubData sources
All four data source types embed data.BaseDataSource and satisfy band.DataSource directly — no adapter wrapper needed. Register one in the report Dictionary for FRX workflows, or assign it straight to a DataBand when building a report in code.
JSON
ds := jsondata.New("customers")
ds.SetJSON(`[{"Name":"Alice","Age":30},{"Name":"Bob","Age":25}]`)
ds.Init()
XML
ds := xmldata.New("orders")
ds.SetXML(`<Orders><Item Product="Apple" Qty="5"/></Orders>`)
ds.Init()
CSV
ds := csvdata.New("sales")
ds.SetFilePath("sales.csv")
ds.HasHeader = true
ds.Init()
SQL
db, _ := sql.Open("postgres", "...")
ds := sqlds.New("employees", db,
"SELECT id, name FROM employees WHERE active = $1", true)
ds.Init()
Export
HTML, PDF, and PNG exporters share the same shape — construct, set options, call Export with the prepared pages and a writer.
// HTML
exp := html.NewExporter()
exp.Title = "My Report"
exp.EmbedCSS = true
exp.Export(preparedPages, &buf)
// PDF (structural)
exp := pdf.NewExporter()
exp.Export(preparedPages, outputWriter)
// PNG, 2x scale for high-DPI
exp := image.NewExporter()
exp.Scale = 2.0
exp.Export(preparedPages, outputWriter)
// Page range on any exporter
exp.PageRange = export.PageRangeCustom
exp.PageNumbers = "1,3-5"
Package overview
| Package | Purpose |
|---|---|
| reportpkg | Report, ReportPage — the top-level report definition |
| band | All 13 band types: DataBand, GroupHeaderBand, PageHeaderBand, etc. |
| object | TextObject, SubreportObject, PictureObject, etc. |
| engine | Report execution engine (ReportEngine.Run) |
| expr | Expression parser and evaluator for [bracket] expressions |
| data / json / xml / csv / sql | DataSource interface, BaseDataSource, and the four adapters |
| export/html, pdf, image | HTML, PDF (structural), and PNG image export |
| crossview | Pivot table (CrossView) object |
| barcode | Barcode rendering — QR, Code128, EAN, and more |
| serial | FRX XML serialization (Writer / Reader) |
| preview | PreparedPages — rendered page output |
| style | Border, Fill, Style, font helpers |
| units | Unit conversion (mm, cm, inches ↔ pixels) |
| format | Number and date formatting |
| functions | Built-in expression functions (IIF, Format, etc.) |
Band types
| Band | When printed |
|---|---|
| ReportTitleBand | Once at report start |
| ReportSummaryBand | Once at report end |
| PageHeaderBand | Top of each page |
| PageFooterBand | Bottom of each page |
| ColumnHeaderBand | Top of each column (multi-column layout) |
| ColumnFooterBand | Bottom of each column |
| DataHeaderBand | Before first data row |
| DataBand | Once per data source row |
| DataFooterBand | After last data row |
| GroupHeaderBand | At group value change |
| GroupFooterBand | At group end |
| ChildBand | After its parent band |
| OverlayBand | On top of page content |
Status & roadmap
This is an active port of FastReport .NET Open Source. Functional today:
- Core engine: data iteration, band rendering, page breaks, multi-column layouts, groups
- Data binding: JSON, XML, CSV, SQL, and custom in-memory data sources
- Dictionary-based DataSource resolution, matching the FastReport .NET model
- FRX serialization: read and write
.frxfiles, including real FastReport sample files - Export: HTML, PDF (structural), PNG image
- Aggregate totals: Sum, Count, Average, Min, Max with per-group reset
- CanGrow / CanShrink dynamic band height, and
[bracket]expression evaluation - Conditional formatting: HighlightCondition evaluation (Fill, TextColor, Font, Visible), first-match-wins
- Master-detail relation traversal at engine runtime, filtering child data sources per parent row
- FRX gzip compression: transparent read and write of compressed
.frxfiles - HTML export of images and vector shapes (Shape, Line, PolyLine, Polygon, CheckBox)
See porting-plan.md for the detailed, dated roadmap of what's landed.
Frequently asked questions
What is go-fastreport?
A free, open-source, pure Go reporting library that ports the core functionality of FastReport .NET Open Source to Go: a band-based report engine, data source adapters for JSON, XML, CSV, and SQL, and export to HTML, PDF, and PNG.
Does it require CGo or a commercial license?
No. It is pure Go with no CGo dependencies, so it cross-compiles and runs on any platform Go supports. It is MIT licensed and free to use.
Can it load existing FastReport .NET .frx files?
Yes. go-fastreport reads and writes the FastReport FRX XML format and has been smoke tested against 50+ real FastReport sample files. Design in FastReport .NET, save as .frx, then load and run it from Go.
What data sources and export formats are supported?
JSON, XML, CSV, SQL (via database/sql), and custom in-memory adapters for data; HTML, PDF (structural), and PNG for export, each with page-range selection.
Is it production ready?
The core engine, all four data sources, FRX serialization, HTML/PDF/PNG export, conditional formatting, master-detail relation traversal, FRX gzip compression, and HTML export of images and vector shapes are all functional and tested.