Skip to content

Commit e89c668

Browse files
committed
delphi: Revise application steps
1 parent 0db2838 commit e89c668

2 files changed

Lines changed: 38 additions & 33 deletions

File tree

Delphi/PDFReportGenerator.dpr

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,33 @@ var
2727
AReportParameter: TdxReportParameter;
2828
AStream: TMemoryStream;
2929
begin
30-
// Create a database connection
31-
AConnection := TdxBackendDatabaseSQLConnection.Create(nil);
30+
// Step 1: Create a report instance and load the report layout
31+
AReport := TdxReport.Create(nil);
3232
try
33-
// Assign a database name matching the name specified in the report ALayout
34-
AConnection.DisplayName := 'NWindConnectionString';
35-
// Assign a connection string to use the local SQLite database
36-
AConnection.ConnectionString := 'XpoProvider=SQLite; Data Source=..\nwind.db; Mode=ReadOnly';
33+
// Set an internal report name (does not affect the exported PDF content and file name)
34+
AReport.ReportName := 'OrderReport';
35+
// Load the report layout from the specified file
36+
AReport.Layout.LoadFromFile(ALayout);
3737

38-
// Create a report instance
39-
AReport := TdxReport.Create(nil);
38+
// Step 2: Create a database connection
39+
AConnection := TdxBackendDatabaseSQLConnection.Create(nil);
4040
try
41-
// Set an internal report name (does not affect the exported PDF content and file name)
42-
AReport.ReportName := 'OrderReport';
43-
// Load the report ALayout from the specified file
44-
AReport.Layout.LoadFromFile(ALayout);
45-
// Load report parameters to enable changing their values
46-
AReport.LoadParametersFromReport;
41+
// Assign a database name matching the name specified in the report layout
42+
AConnection.DisplayName := 'NWindConnectionString';
43+
// Assign a connection string to use the local SQLite database
44+
AConnection.ConnectionString := 'XpoProvider=SQLite; Data Source=..\nwind.db; Mode=ReadOnly';
4745

48-
// Set the value of the "OrderIdParameter" parameter in the report ALayout
46+
// Step 3: Define Report Parameter Values
47+
AReport.LoadParametersFromReport;
48+
// Set the value of the "OrderIdParameter" parameter in the report layout
4949
for AReportParameter in AReport.Parameters do
5050
if AReportParameter.Name = 'OrderIdParameter' then
5151
AReportParameter.Value := AOrderID;
5252

53+
// Step 4: Export a report to PDF
5354
AStream := TMemoryStream.Create;
5455
try
55-
// Export the report to PDF format and save it to a memory stream
56+
// Export a report to PDF format and save it to a memory stream
5657
AReport.ExportToPDF(AStream);
5758
// Write the content of the memory stream to a file
5859
AStream.SaveToFile(AOutput);
@@ -61,10 +62,10 @@ begin
6162
AStream.Free;
6263
end;
6364
finally
64-
AReport.Free;
65+
AConnection.Free;
6566
end;
6667
finally
67-
AConnection.Free;
68+
AReport.Free;
6869
end;
6970
end;
7071

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,52 @@
44
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
55
<!-- default badges end -->
66

7-
# DevExpress VCL Reports—Generate a PDF Report Using a non-GUI application
7+
# DevExpress VCL Reports—Generate a PDF Report Using a Headless (non-GUI) application
88

9-
This command line application uses the DevExpress VCL Reports components to generate a PDF report.
10-
The application obtains data from a database using a SQL query that includes report layout parameters.
9+
This example uses the DevExpress VCL Reports components to generate a PDF report using a command line application.
10+
The example demonstrates the capabilities of VCL Reports for producing reports in backend applications, webservers, or command line applications, all without the need for a GUI.
1111

1212
The example includes projects for both [Delphi](./Delphi) and [C++Builder](./CPB).
1313

1414
> ![Example of a PDF report produced by the command line application, showing an alphabetical list of products](./images/report.png)
1515
1616
## Prerequisites
1717

18-
See: [DevExpress Reports Prerequisites](https://docs.devexpress.com/VCL/405768/ExpressCrossPlatformLibrary/general-recommendations/vcl-web-view-2-based-app-deployment#vcl-reportsdashboards-prerequisites)
18+
See: [DevExpress Reports Prerequisites](https://docs.devexpress.com/VCL/405773/ExpressCrossPlatformLibrary/vcl-backend/reports-dashboards-app-deployment#vcl-reportsdashboards-prerequisites)
1919

20+
> [!Note]
21+
> An application using VCL Reports in headless mode does not require the `WebView2Loader.dll` library (unlike GUI applications).
2022
2123
## Implementation Details
2224

23-
By following the steps outlined in this example, you'll create a standalone command line application using the
24-
[DevExpress VCL ](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports).
25+
By following the steps outlined in this example, you'll create an application that produce the
26+
[DevExpress VCL Reports](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports).
2527

2628
### Prepare a Template Report Layout
2729

2830
An application needs a template report layout, created in the [Report Designer](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports).
29-
You can [store a report layout in a `.repx` file](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file)
31+
32+
You can [store a report layout in a REPX file](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file)
3033
or [in a database](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-database).
3134

32-
This example loads a report layout from the [`Layout.repx`](./Layout.repx) file.
35+
This example loads a report layout from the [`Order.repx`](./Order.repx) file.
3336

3437
###
3538

39+
40+
## Files to Review
41+
42+
- [`Delphi/PDFReportGenerator.dpr`](./Delphi/PDFReportGenerator.dpr) generates a report in headless (non-GUI) mode.
43+
- [`Order.repx`](./Order.repx) contains a report layout which produces a customer order report.
44+
You view and edit this file using the [file storage example application](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file).
45+
- [`nwind.db`](./nwind.db) contains the Northwind example database.
46+
3647
## Documentation and Examples
3748

3849
- [Documentation: DevExpress VCL Reports](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports)
3950
- [Example: Store Report Layouts within Text Files](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file)
4051
- [Example: Store Report Layouts in a Database](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-database)
4152

42-
## Files to Review
43-
44-
- [`PDFReportGenerator.ini`](./PDFReportGenerator.ini) defines configuration settings used to generate a report.
45-
In your product, you can implement these settings as
46-
- [`Layout.repx`](./Layout.repx) contains visual report layout and database connection data.
47-
- [`Delphi/PDFReportGenerator.dpr`](./Delphi/PDFReportGenerator.dpr) generates a report in headless (non-GUI) mode.
48-
4953

5054
<!-- feedback -->
5155
## Does This Example Address Your Development Requirements/Objectives?

0 commit comments

Comments
 (0)