Method

report.export

Run a report and render it through a style sheet as one self-contained HTML document.

Runs a report as report.run does and renders it as one self-contained HTML document through a style sheet: styleSheet by name, or the report's own General/Stylesheet option. The HTML has no script and no external resource, and is the same bytes for the same book, options, now and settings. Nothing is written to disk: the server never writes to a path you name. The CLI's --output writes the html on your side.

An unknown styleSheet is a report-option error. A saved configuration that names a style sheet that has since been deleted renders with the base look.

Examples

Example: with a copy of the reports/test-data example book open as book.gnucash, at 2024-03-15T12:00:00Z.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"report.export","params":{"report":"Balance Sheet","options":{"General":{"Balance Sheet Date":{"absolute":"1978-12-31"}}}}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "title": " Balance Sheet 12/31/78",
    "html": "…"
  }
}

Command line

red-ale exec --book book.gnucash report.export '{"report":"Balance Sheet","options":{"General":{"Balance Sheet Date":{"absolute":"1978-12-31"}}}}'

It prints:

{
  "title": " Balance Sheet 12/31/78",
  "html": "…"
}

MCP tool call

Tool call:

{"name":"report.export","arguments":{"report":"Balance Sheet","options":{"General":{"Balance Sheet Date":{"absolute":"1978-12-31"}}}}}

Result:

{
  "structuredContent": {
    "title": " Balance Sheet 12/31/78",
    "html": "…"
  }
}

Effect: read.

Params

Params of report.export.

  • report (ReportRef, required): The report.
  • options (ReportOptions or null): Changes over the template's defaults, or over the saved configuration's values.
  • now (Timestamp or null): The time to run the report for; by default the session's clock.
  • styleSheet (string or null): The style sheet to render through, instead of the one the report's General/"Stylesheet" option names.
  • locale (string or null): The Locale to format numbers and dates in for this run, as in report.run.

Result

The result of report.export. Nothing is written to disk.

  • title (string, required): The report's title.
  • html (string, required): One self-contained HTML document: no script and no external resource.