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 |
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 |
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 |
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 |
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 |
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.