Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Delphi/PDFReportGenerator.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ begin
AConnection.ConnectionString := 'XpoProvider=SQLite; Data Source=nwind.db; Mode=ReadOnly';

// Step 3: Define Report Parameter Values
AReport.Parameters.LoadFromLayout;
// Set the "OrderIdParameter" value in the report layout
AReport.Parameters['OrderIdParameter'].Value := AOrderID;

Expand Down
Binary file modified Delphi/PDFReportGenerator.res
Binary file not shown.
64 changes: 43 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using the DevExpress Reports backend.
Use the approach demonstrated in this sample project to implement
REST/Web API backends, Windows Services, workflows, and scheduled jobs.
This approach can be particularly beneficial for the following usage scenarios

Check warning on line 18 in README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] README.md#L18

[DX.RayRules-Alternatives] Better alternative: 'use'
Raw output
{"message": "[DX.RayRules-Alternatives] Better alternative: 'use'", "location": {"path": "README.md", "range": {"start": {"line": 18, "column": 64}}}, "severity": "WARNING"}
(reports generated without direct user interaction):

- Mass-export reports to PDF, DOCX, image, and other formats.
Expand Down Expand Up @@ -60,7 +60,9 @@

This example imports a report layout from the [Order.repx] file.

**Delphi:**
<!-- start-code-block -->
#### Delphi

```delphi
AReport := TdxReport.Create(nil); // AReport: TdxReport;
try
Expand All @@ -73,14 +75,17 @@
AReport.Free;
end;
```
<!-- end-code-block -->


### Step 2: Create a Database Connection

Create a database connection component to supply data to the report.
This example uses a SQLite sample database ([nwind.db]).

**Delphi:**
<!-- start-code-block -->
#### Delphi

```delphi
// AConnection: TdxBackendDatabaseSQLConnection;
AConnection := TdxBackendDatabaseSQLConnection.Create(nil);
Expand All @@ -94,6 +99,7 @@
AConnection.Free;
end;
```
<!-- end-code-block -->

For detailed information on data source management and supported database engines, refer to the following help topic:
[VCL Backend: Supported Database Systems][supported-dbms].
Expand All @@ -106,22 +112,25 @@
based on the same report template and underlying data.
For example, [Order.repx] includes a single `OrderIDParameter` that filters data by order ID.

To modify parameters, load them using the [TdxReport.Parameters.LoadFromLayout] method
and assign values to [TdxReport.Parameters] list members as follows:
To modify parameters, assign values to [TdxReport.Parameters] list members as follows:

<!-- start-code-block -->
#### Delphi

**Delphi:**
```delphi
AReport.Parameters.LoadFromLayout;
// Set the "OrderIdParameter" value in the report layout
AReport.Parameters['OrderIdParameter'].Value := AOrderID;
```
<!-- end-code-block -->


### Step 4: Export Report Content to a File

This example exports a report to a PDF file using the [TdxReport.ExportToPDF] method:

**Delphi:**
<!-- start-code-block -->
#### Delphi

```delphi
AStream := TMemoryStream.Create; // AStream: TMemoryStream;
try
Expand All @@ -133,6 +142,8 @@
AStream.Free;
end;
```
<!-- end-code-block -->


For detailed information on available export formats, refer to the following help topic:
[TdxReport.ExportTo].
Expand All @@ -144,11 +155,11 @@
You need to initialize the report layout and data connection once (steps 1 and 2)
and repeat steps 3 and 4 for each parameter.

**Delphi:**
<!-- start-code-block -->
#### Delphi

```delphi
// ...
AReport.LoadParametersFromReport;

for AOrderID in AOrderIDList:
AReport.Parameters['OrderIdParameter'].Value := AOrderID;

Expand All @@ -163,6 +174,7 @@
end;
end;
```
<!-- end-code-block -->


## Files to Review
Expand All @@ -179,34 +191,44 @@

## Documentation

- [Introduction to VCL Reports](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports)
- [Tutorial: Create a table report using the Report Wizard](https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-report-wizard)
- [Use SQLite as a data source for reports (as demonstrated in the current example)](https://docs.devexpress.com/VCL/405750/ExpressCrossPlatformLibrary/vcl-backend/database-engines/vcl-backend-sqlite-support)
- [Introduction to VCL Reports][reports-intro]
- [Tutorial: Create a table report using the Report Wizard][wizard-tutorial]
- [Use SQLite as a data source for reports (as demonstrated in the current example)][sqlite-data-source]
- API reference:
- [TdxReport](https://docs.devexpress.com/VCL/dxReport.TdxReport)
- [TdxReport.ExportToPDF], [TdxReport.ExportTo][TdxReport.ExportTo]
- [TdxReport.Layout](https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout)
- [TdxReport]
- [TdxReport.ExportToPDF], [TdxReport.ExportTo]
- [TdxReport.Layout]
- [TdxReport.Parameters]
- [TdxReport.Parameters.LoadFromLayout]
- [TdxBackendDatabaseSQLConnection](https://docs.devexpress.com/VCL/dxBackend.ConnectionString.SQL.TdxBackendDatabaseSQLConnection)

- [TdxBackendDatabaseSQLConnection]

<!-- documentation links -->
[designer]: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports
[supported-dbms]: https://docs.devexpress.com/VCL/405703/ExpressCrossPlatformLibrary/vcl-backend/vcl-backend-supported-database-systems
[reports-intro]: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports
[wizard-tutorial]: https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-wizard-tutorial
[sqlite-data-source]: https://docs.devexpress.com/VCL/405750/ExpressCrossPlatformLibrary/vcl-backend/database-engines/vcl-backend-sqlite-support

<!-- reference links -->
[TdxReport]: https://docs.devexpress.com/VCL/dxReport.TdxReport
[TdxReport.Layout]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout
[TdxReport.ExportToPDF]: https://docs.devexpress.com/VCL/dxReport.TdxReport.ExportToPDF(System.Classes.TStream)
[TdxReport.ExportTo]: https://docs.devexpress.com/VCL/dxReport.TdxReport.ExportTo%28dxBackend.TdxReportExportFormat-System.Classes.TStream%29#available-export-formats
[TdxReport.Parameters]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Parameters
[TdxReport.Parameters.LoadFromLayout]: https://docs.devexpress.com/VCL/dxReport.Parameters.TdxReportParameters.LoadFromLayout
[TdxBackendDatabaseSQLConnection]: https://docs.devexpress.com/VCL/dxBackend.ConnectionString.SQL.TdxBackendDatabaseSQLConnection


## More Examples

- [Store Report Layouts in REPX Files][file-example]
- [Store Report Layouts in a Database][database-example]
- [Filter data records in a report][filter-data-records]
- [Localize the Report Viewer and Report Designer][localize]


<!-- example links -->
[file-example]: https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file
[database-example]: https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-database
[filter-data-records]: https://github.com/DevExpress-Examples/vcl-filter-report-preview-based-on-grid-selected-rows
[localize]: https://github.com/DevExpress-Examples/vcl-reports-localize

<!-- feedback -->
## Does This Example Address Your Development Requirements/Objectives?
Expand Down
Loading