Skip to content

Reports

Once you have built up the blocks that make up your report, you can use the following functions to save, export, or stringify it.

Saving Reports

save_report

Save the app document to a local HTML file

Parameters:

Name Type Description Default
blocks BlocksT

The Blocks object or a list of Blocks

required
path str

File path to store the document

required
open bool

Open in your browser after creating (default: False)

False
name str

Name of the document (optional: uses path if not provided)

'Report'
formatting Formatting | None

Sets the basic app styling

None
offline bool

Bundle all JS/CSS inline for fully offline viewing (default: False)

False
toc bool

Generate a table of contents from Page/Group labels (default: False)

False

build_report

Build an (static) app with a directory structure, which can be served by a local http server

Note

This outputs compressed assets into the dir as well, may be an issue if self-hosting

Parameters:

Name Type Description Default
blocks BlocksT

The Blocks object or a list of Blocks

required
name str

The name of the app directory to be created

'Report'
dest NPath | None

File path to store the app directory

None
formatting Formatting | None

Sets the basic app styling

None
overwrite bool

Replace existing app with the same name and destination if already exists (default: False)

False
toc bool

Generate a table of contents from Page/Group labels (default: False)

False

Multi-Page Export

save_report_pages

Save each Page as a separate HTML file.

If blocks contains Page blocks, each page is saved as an individual HTML file named {dest}/{name} - {page_title}.html. If there are no Page blocks the entire report is saved as a single file.

Parameters:

Name Type Description Default
blocks BlocksT

The Blocks object or a list of Blocks

required
dest str

Directory to write the HTML files into (default: current dir)

'.'
name str

Base name for the files

'Report'
formatting Formatting | None

Sets the basic app styling

None
offline bool

Bundle all JS/CSS inline for fully offline viewing

False

Returns:

Type Description
list[str]

List of file paths that were created.

PDF Export

save_pdf

Save the report as a high-quality PDF file.

Uses A4 landscape by default for best dashboard rendering. Requires: uv add datainpane[pdf] then playwright install chromium

Parameters:

Name Type Description Default
blocks BlocksT

The Blocks object or a list of Blocks

required
path str

File path to store the PDF

required
name str

Name of the document

'Report'
formatting Formatting | None

Sets the basic styling

None
landscape bool

Use landscape orientation (default: True)

True
wait_for_js bool

Wait for JS rendering (charts, tables). Default True.

True

Stringify

stringify_report

Stringify the app document to a HTML string

Parameters:

Name Type Description Default
blocks BlocksT

The Blocks object or a list of Blocks

required
name str | None

Name of the document (optional: uses path if not provided)

None
formatting Formatting | None

Sets the basic app styling

None

Formatting

Formatting dataclass

Configure styling and formatting.

Use a preset theme via Formatting.from_theme(Theme.DARK) or customize individual properties directly::

dip.save_report(view, path="report.html", formatting=Formatting(
    bg_color="#1E293B",
    accent_color="#FB923C",
    font=FontChoice.SANS,
    width=Width.FULL,
))

You can also inject arbitrary CSS via custom_css::

Formatting(custom_css="h1 { border-bottom: 2px solid #FB923C; }")

Add header/footer branding::

Formatting(header="<img src='logo.png' height='40'/> My Company")

Enable dark mode toggle::

Formatting(dark_mode_toggle=True)

accent_color = '#4E46E5' class-attribute instance-attribute

bg_color = '#FFF' class-attribute instance-attribute

custom_css = '' class-attribute instance-attribute

dark_mode_toggle = False class-attribute instance-attribute

font = FontChoice.DEFAULT class-attribute instance-attribute

footer = '' class-attribute instance-attribute

header = '' class-attribute instance-attribute

light_prose = False class-attribute instance-attribute

text_alignment = TextAlignment.LEFT class-attribute instance-attribute

width = Width.MEDIUM class-attribute instance-attribute

from_theme classmethod

Create a Formatting instance from a named theme.

Any keyword arguments override the theme defaults::

fmt = Formatting.from_theme(Theme.DARK, width=Width.FULL)

to_css

Theme

Built-in report themes.

CORAL = 'coral' class-attribute instance-attribute

DARK = 'dark' class-attribute instance-attribute

DEFAULT = 'default' class-attribute instance-attribute

FOREST = 'forest' class-attribute instance-attribute

MIDNIGHT = 'midnight' class-attribute instance-attribute

MONOCHROME = 'monochrome' class-attribute instance-attribute

NAVY_APRICOT = 'navy_apricot' class-attribute instance-attribute

OCEAN = 'ocean' class-attribute instance-attribute

Width

FULL = 'full' class-attribute instance-attribute

MEDIUM = 'medium' class-attribute instance-attribute

NARROW = 'narrow' class-attribute instance-attribute

to_css

FontChoice

DEFAULT = 'Inter, ui-sans-serif, system-ui' class-attribute instance-attribute

MONOSPACE = 'ui-monospace, monospace, system-ui' class-attribute instance-attribute

SANS = 'ui-sans-serif, sans-serif, system-ui' class-attribute instance-attribute

SERIF = 'ui-serif, serif, system-ui' class-attribute instance-attribute