Share My Creation [B4X] Report Engine

1793779438048.png

Repot - B4X Report Engine​

Version: 1.7.0
GitHub: https://github.com/pyhoon/Repot

Announcement:
Repot — a reporting engine for B4X (B4J + B4A), now at v1.7.0

One versioned JSON template → every output: paginated PDF, HTML, editable DOCX / XLSX / ODT / ODS, and CSV / JSON / XML data exports — from the same definition and the same data.
  • Banded layout engine: report/page headers, groups, subtotals, page numbering, multi-page
  • B4J PDF: vector output, embedded TrueType fonts, right-to-left text with Arabic shaping, mixed-script documents (Japanese, Chinese Simplified & Traditional, Korean, Arabic, Hebrew — all regression-tested)
  • B4A: vector PDF through the Printing library, system print dialog, save-to-location via SAF, PDF introspection
  • Office formats are hand-written zip+XML writers — zero third-party dependencies
  • Deterministic by design: no ambient clock or locale; identical input → identical output
  • Verified, not claimed: 578 checks (B4J) + 353 checks (B4A on emulator), 0 errors — tools/ci.ps1 -RunEmulator is the gate
MIT, no paid tier, no feature gating. Everything ships in one .b4xlib. Check /examples and tutorial on GitHub.

Welcome to star, fork and contribute.
 

Attachments

Last edited:
Will you be able to have a web version for web based apps?
I just used up my free OpenCode message to answer this question. 😁
Following is answered by the agent:

Short answer:
yes for server-generated reports — the engine already runs headless inside a B4J server — but it's not a browser-side/JS renderer.



What works today

The core has no UI or JavaFX dependency, so it runs inside a jServer handler. There's a runnable example in examples/server: a request comes in, the handler binds data, builds, and exports — the same .repot template that produces PDF on desktop.

- HTML export produces a complete standalone document (doctype, inline CSS, @media print page rules), so a browser renders it directly — no assets to serve alongside it.
- Deterministic: no ambient clock or locale, so identical input produces identical output. That's what makes server-side caching sane.
- Any format from one build: HTML, PDF, DOCX, XLSX, ODT, ODS, CSV/JSON/XML.

A minimal handler looks like this (jServer API verified):
Code: Copy
Sub Handle (req As ServletRequest, resp As ServletResponse)
    Dim Report As Repot
    Report.Initialize
    Report.LoadTemplate(File.DirApp, "invoice.repot")
    ' ... bind parameters and data from the request / database ...

    If Report.Build.Success = False Then
        resp.Status = 500
        resp.Write("Report build failed")
        Return
    End If

    Dim ex As ReportHtmlExporter
    ex.Initialize(Report.Diagnostics)
    resp.ContentType = "text/html; charset=utf-8"
    resp.Write(ex.ToHtml(Report.Result.RenderDocument))
End Sub

For a PDF response, export to File.DirTemp, set ContentType = "application/pdf" and Content-Disposition, then copy the file to resp.OutputStream (the exporters write to a path; a stream/in-memory export is a small addition I can make if it matters).

What it is not

- Not responsive HTML. The HTML exporter is fixed-layout: absolutely positioned spans in points, one div per page. It looks exactly like the PDF and prints page-for-page from the browser — great for invoices, statements, reports. It is not a semantic, mobile-reflowing page. A "flow" mode (responsive HTML) was designed but never implemented.
- No client-side rendering. Template evaluation, layout and pagination happen in B4X on the server. There's no JS runtime that renders .repot in the browser, and no hosted service.

So the question back to you: is your web app showing documents (invoice/statement/report the user prints or downloads) or responsive pages (a report list that reflows on a phone)? The first works today. The second needs the flow exporter, which is a different layout engine — happy to gauge interest, since "web reports" is the reason it was on the roadmap.
 
Cool. Please check for client side version. Here is an example, https://www.stimulsoft.com/en/products/reports-js

Most apps I create do not use a VPS. With back-ends like FireStore/FireBase/PocketBase/SupeBase/IndexedDB, this will prove valuable.

Thanks in advance.
Once the library is released, you can fork the repo and use it as a reference to build your JavaScript library.
 
I've been silently wishing to have our own report engine for a long time now. I have an app blocked on crystal reports and .net 4.8 because I can't change the engine.
 
I've been silently wishing to have our own report engine for a long time now. I have an app blocked on crystal reports and .net 4.8 because I can't change the engine.
To be clear, it's a vibe coded project. It will work as advertised on the basic functions but don't put high expectations on it. It will be open source so anyone is invited to improve it.
 
Back
Top