Reports
Design and preview printable, banded reports from any table, view, or saved query — with grouping, sorting, expressions, aggregate functions, and configurable page layout.
Overview
The Reports module is a Blazor-based reporting system integrated into the CSharpDB Admin UI. It provides a WYSIWYG designer for creating banded reports and a paginated preview with browser printing support.
- Data sources — tables, views, and saved queries
- Banded layout — report header/footer, page header/footer, group header/footer, and detail bands
- Controls — Label, BoundText, CalculatedText, Line, and Box
- Expressions — arithmetic, field references, and aggregate functions (SUM, COUNT, AVG, MIN, MAX)
- Grouping & sorting — multi-level data grouping with ascending/descending sort direction
- Page settings — Letter/A4 paper size, portrait/landscape orientation, configurable margins
- Preview & print — paginated preview up to 10,000 rows / 250 pages with browser print support
Report Designer
Open the designer from the Reports section of the Object Explorer or click New Report in the toolbar. The designer provides a multi-panel layout for building reports visually.
Toolbox
Drag controls from the toolbox onto any report band:
| Control | Description |
|---|---|
| Label | Static text with configurable font size, weight, and alignment. |
| BoundText | Displays a field value with optional .NET format string (e.g. C2 for currency, yyyy-MM-dd for dates). |
| CalculatedText | Evaluates expressions with field references, arithmetic, and aggregate functions. Supports optional prefix text. |
| Line | Horizontal or vertical line for visual separation. |
| Box | Rectangle shape for grouping or highlighting areas. |
Report Bands
Reports use a banded layout where each band controls when its contents are rendered:
| Band | When Rendered |
|---|---|
| Report Header | Once at the beginning of the report. |
| Page Header | At the top of every page. |
| Group Header | At the start of each group break. |
| Detail | Once for every data row. |
| Group Footer | At the end of each group. |
| Page Footer | At the bottom of every page. |
| Report Footer | Once at the end of the report. |
Grouping & Sorting
Use the Groups panel to define grouping levels. Each group specifies a field and sort direction (ascending or descending). When groups are defined, the report engine automatically creates group header and footer bands. Use the Sorts panel to add additional sort levels beyond the group ordering.
Page Settings
Configure paper size (Letter or A4), orientation (Portrait or Landscape), and margins. These settings control pagination in the preview and affect printed output.
Canvas Interaction
- Drag controls to reposition them within a band.
- Resize using corner/edge handles.
- Select a control to edit its properties in the property inspector.
- Z-order — Bring to Front / Send to Back arrangement.
- Generate — Auto-generate a default layout from the data source fields.
Expressions & Aggregates
CalculatedText controls evaluate expressions prefixed with =. Expressions support field references, arithmetic operators, and aggregate functions.
Field References
Reference fields using bracket notation ([FieldName]) or simple identifiers. Field values are resolved from the current data row.
Arithmetic
Standard operators: +, -, *, /
=Price * Quantity
=[UnitPrice] * [Qty] - [Discount]
Aggregate Functions
| Function | Description |
|---|---|
SUM(field) | Sum of all values in the current scope. |
COUNT(field) | Count of non-null values. |
AVG(field) | Average of all values. |
MIN(field) | Minimum value. |
MAX(field) | Maximum value. |
Aggregates are typically placed in group footer or report footer bands to summarize grouped data.
Special Expressions
| Expression | Value |
|---|---|
=PageNumber | Current page number. |
=PrintDate | Current date/time when the report is rendered. |
Data Sources
Reports can be bound to three types of data sources:
| Source | Description |
|---|---|
| Table | Direct table data with all columns available as fields. |
| View | Database view output. |
| Saved Query | A pre-built SQL query saved in the system catalog. |
Each source provides field metadata including data types, nullability, and display names. The designer detects schema changes since the report was created and displays a warning if fields have changed.
Formatting
BoundText and CalculatedText controls accept standard .NET format strings:
| Format | Example Output |
|---|---|
C2 | $1,234.56 (currency) |
N0 | 1,235 (number, no decimals) |
P1 | 85.3% (percentage) |
yyyy-MM-dd | 2026-04-03 (date) |
Text alignment (left, center, right), font size, and font weight are configurable per control.
Preview & Print
The preview renders the report with live data from the bound source. It displays paginated output with page navigation controls.
- Page navigation — Browse through rendered pages.
- Print — Send the report to the browser's print dialog via JavaScript interop.
- Refresh — Re-render with the latest data.
- Edit — Jump back to the designer to modify the layout.
Preview limits: 10,000 rows and 250 pages maximum. A truncation indicator is shown if limits are exceeded.
Report Storage
Report definitions are stored in the __reports metadata table with the report layout serialized as JSON in __report_definition_chunks. The system supports:
- CRUD operations (create, read, update, delete)
- Optimistic concurrency with version tracking
- Listing reports by source type and name