Skip to content

Commit b66a349

Browse files
committed
draft
1 parent 8b4e761 commit b66a349

5 files changed

Lines changed: 73 additions & 15 deletions

File tree

CPB/uMainForm.dfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ object MainForm: TMainForm
2525
Width = 377
2626
Height = 25
2727
Caption = 'Design Report'
28-
SpeedButtonOptions.CanBeFocused = False
2928
TabOrder = 1
3029
OnClick = btnDesignClick
3130
end

Delphi/uData.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ implementation
3333

3434
{$R *.dfm}
3535
const
36-
DataFileName = '..\..\data.dat';
36+
DataFileName = 'data.dat';
3737

3838
procedure TDataModule1.DataModuleCreate(Sender: TObject);
3939
begin

Delphi/uMainForm.dfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ object MainForm: TMainForm
2525
Width = 377
2626
Height = 25
2727
Caption = 'Design Report'
28-
SpeedButtonOptions.CanBeFocused = False
2928
TabOrder = 1
3029
OnClick = btnDesignClick
3130
end

Delphi/uMainForm.pas

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ implementation
5252

5353
procedure TMainForm.btnNewClick(Sender: TObject);
5454
begin
55+
// Add a new record to the dataset
5556
DataModule1.mdLayouts.Append
5657
end;
5758

@@ -62,9 +63,10 @@ procedure TMainForm.btnDesignClick(Sender: TObject);
6263
ShowMessage('The database is empty');
6364
Exit;
6465
end;
65-
66+
// Load the report layout from the in-memory dataset
6667
dxReport1.ReportName := DataModule1.mdLayoutsName.AsString;
6768
dxReport1.Layout.Assign(DataModule1.mdLayoutsLayout);
69+
// Display the report designer dialog
6870
dxReport1.ShowDesigner;
6971
end;
7072

README.md

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,88 @@
44
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
55
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
66
<!-- default badges end -->
7-
# DevExpress VCL Reports - Store Report Layouts in a Database
87

9-
This example stores a [report layout](https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout) (XML-based template) in the BLOB field of a memory-based dataset ([TdxMemData](https://docs.devexpress.com/VCL/dxmdaset.TdxMemData) inherited from the [TDataSet](https://docwiki.embarcadero.com/Libraries/Athens/en/Data.DB.TDataSet) class shipped with the standard VCL library).
8+
# DevExpress Reports for Delphi/C++Builder – Store Report Layouts in a Database
109

11-
## Testing the example
10+
This example application stores [DevExpress report layouts][TdxReport.Layout] in a database.
11+
The application allows users to create and save report layouts, modify existing layouts, and open layouts in Report Designer/Viewer.
12+
13+
14+
## Prerequisites
15+
16+
[DevExpress Reports Prerequisites][req]
17+
18+
[req]: https://docs.devexpress.com/VCL/405773/ExpressCrossPlatformLibrary/vcl-backend/reports-dashboards-app-deployment#vcl-reportsdashboards-prerequisites
19+
20+
## Implementation Details
21+
22+
The example application stores report layouts in the BLOB field of a memory-based dataset
23+
([TdxMemData] from the DevExpress library, inherited from [TDataSet], shipped with the standard VCL library).
24+
Follow the steps below to store report layouts in a database of your choice, using the corresponding `TDataSet` descendant.
25+
26+
27+
28+
## Test the Example
1229

1330
* Run the sample app and click **New Report** to create an empty database record.
14-
* Click **Show Designer** to display the [Report Designer](https://docs.devexpress.com/XtraReports/119176/web-reporting/web-end-user-report-designer) dialog.
31+
* Click **Show Designer** to display the [Report Designer][dx-report-designer] dialog.
1532
* Create a report layout using tools available within the UI.
1633
* Click the hamburger button, select the **Save** option, and close the dialog.
17-
* Close the app. The [TdxMemData](https://docs.devexpress.com/VCL/dxmdaset.TdxMemData) component will store layout data between sessions.
18-
* Run the sample app again. Click **View Designer** to load the saved report layout, or **View Report** to preview a layout-based report in the [Report Viewer](https://docs.devexpress.com/XtraReports/401850/web-reporting/web-document-viewer) dialog.
34+
* Close the app. The [TdxMemData] component will store layout data between sessions.
35+
* Run the sample app again. Click **View Designer** to load the saved report layout, or **View Report** to preview a layout-based report in the [Report Viewer][dx-report-viewer] dialog.
36+
37+
## Files to Review
38+
39+
- [uData.pas] (Delphi) and [uData.cpp] (C++Builder) read and store data in the database.
40+
- [uMainForm.pas] (Delphi) and [uMainForm.cpp] (C++Builder) supply layout data from the data module to [TdxReport.Layout] and display Report Designer and Viewer.
41+
- [nwind.db] contains the Northwind sample database used as a data source for report content.
42+
43+
[uData.pas]: ./Delphi/uData.pas
44+
[uData.cpp]: ./CPB/uData.cpp
45+
[uMainForm.pas]: ./Delphi/uMainForm.pas
46+
[uMainForm.cpp]: ./CPB/uMainForm.cpp
47+
[nwind.db]: ./Delphi/nwind.db
1948

2049
## Documentation
2150

22-
* [TdxReport.Layout Property](https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout)
23-
* [TdxBackendDataSetJSONConnection Component](https://docs.devexpress.com/VCL/dxBackend.ConnectionString.JSON.DataSet.TdxBackendDataSetJSONConnection)
51+
- [Introduction to VCL Reports][reports-intro]
52+
- [Tutorial: Create a table report using the Report Wizard][report-wizard]
53+
- [Store report layouts in REPX files at design-time][reports-design-time-store]
54+
- [Use SQLite as a data source for reports (as demonstrated in the current example)][sqlite-data-source]
55+
- API reference:
56+
- [TdxReport.Layout] (an XML-based layout template that can be stored in the BLOB field of a database)
57+
- [TdxMemData] (used to store report layout data between sessions)
58+
- [TdxBackendDatabaseSQLConnection] (used to supply data to reports)
59+
60+
<!-- documentation links -->
61+
[reports-intro]: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports
62+
[report-wizard]: https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-report-wizard
63+
[reports-design-time-store]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout#string-list-editor
64+
[sqlite-data-source]: https://docs.devexpress.com/VCL/405750/ExpressCrossPlatformLibrary/vcl-backend/database-engines/vcl-backend-sqlite-support
65+
[dx-report-viewer]: https://docs.devexpress.com/XtraReports/401850/web-reporting/web-document-viewer
66+
[dx-report-designer]: https://docs.devexpress.com/XtraReports/119176/web-reporting/web-end-user-report-designer
67+
68+
69+
<!-- reference links -->
70+
[TdxReport.Layout]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout
71+
[TdxBackendDatabaseSQLConnection]: https://docs.devexpress.com/VCL/dxBackend.ConnectionString.SQL.TdxBackendDatabaseSQLConnection
72+
[TdxBackendDataSetJSONConnection]: https://docs.devexpress.com/VCL/dxBackend.ConnectionString.JSON.DataSet.TdxBackendDataSetJSONConnection
73+
[TdxMemData]: https://docs.devexpress.com/VCL/dxmdaset.TdxMemData
74+
[TDataSet]: https://docwiki.embarcadero.com/Libraries/Athens/en/Data.DB.TDataSet
75+
76+
<!-- external documentation links -->
77+
<!-- in-repository links -->
78+
79+
## More Examples
80+
81+
- [Store report layouts in REPX files (example application)][file-example]
82+
83+
[file-example]: https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file
84+
2485
<!-- feedback -->
2586
## Does This Example Address Your Development Requirements/Objectives?
2687

2788
[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=vcl-reports-store-layout-template-database&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=vcl-reports-store-layout-template-database&~~~was_helpful=no)
2889

2990
(you will be redirected to DevExpress.com to submit your response)
3091
<!-- feedback end -->
31-
32-
33-

0 commit comments

Comments
 (0)