|
4 | 4 | [](https://docs.devexpress.com/GeneralInformation/403183) |
5 | 5 | [](#does-this-example-address-your-development-requirementsobjectives) |
6 | 6 | <!-- default badges end --> |
7 | | -# DevExpress VCL Reports - Store Report Layouts in a Database |
8 | 7 |
|
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 |
10 | 9 |
|
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 | + |
| 21 | +## Implementation Details |
| 22 | + |
| 23 | +This example stores report layouts in the BLOB field of a memory-based dataset |
| 24 | +([TdxMemData] from the DevExpress library, inherited from [TDataSet], shipped with the standard VCL library). |
| 25 | +Follow the steps below to store report layouts in a database of your choice, using the corresponding `TDataSet` descendant. |
| 26 | + |
| 27 | +### Step 1: Implement a Data Module |
| 28 | + |
| 29 | +### Step 2: Supply Layout Data to TdxReport |
| 30 | + |
| 31 | +### Step 3: Display Report Designer and Viewer |
| 32 | + |
| 33 | +### Step 4: Handle Layout Changes |
| 34 | + |
| 35 | +## Test the Example |
| 36 | + |
| 37 | +- Run the sample app and click **New Report** to create an empty database record. |
| 38 | +- Click **Show Designer** to display the [Report Designer][dx-report-designer] dialog. |
| 39 | +- Create a report layout using tools available within the UI. |
| 40 | +- Click the hamburger button, select the **Save** option, and close the dialog. |
| 41 | +- Close the app. The [TdxMemData] component will store layout data in the [data.dat] file between sessions. |
| 42 | +- Run the sample app again. Click **View Designer** to load the saved report layout, |
| 43 | + or **View Report** to preview a layout-based report in the [Report Viewer][dx-report-viewer] dialog. |
| 44 | + |
| 45 | + |
| 46 | +## Files to Review |
| 47 | + |
| 48 | +- [uData.pas] (Delphi) and [uData.cpp] (C++Builder) read and store layout data in a database represented by an in-memory storage component. |
| 49 | +- [data.dat] stores layout data between application sessions. |
| 50 | +- [uMainForm.pas] (Delphi) and [uMainForm.cpp] (C++Builder) supply layout data from the data module to [TdxReport.Layout] and display Report Designer and Viewer. |
| 51 | +- [nwind.db] contains the Northwind sample database used as a data source for report content. |
| 52 | + |
| 53 | +[uData.pas]: ./Delphi/uData.pas |
| 54 | +[uData.cpp]: ./CPB/uData.cpp |
| 55 | +[data.dat]: ./Delphi/data.dat |
| 56 | +[uMainForm.pas]: ./Delphi/uMainForm.pas |
| 57 | +[uMainForm.cpp]: ./CPB/uMainForm.cpp |
| 58 | +[nwind.db]: ./Delphi/nwind.db |
12 | 59 |
|
13 | | -* 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. |
15 | | -* Create a report layout using tools available within the UI. |
16 | | -* 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. |
19 | 60 |
|
20 | 61 | ## Documentation |
21 | 62 |
|
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) |
| 63 | +- [Introduction to VCL Reports][reports-intro] |
| 64 | +- [Tutorial: Create a table report using the Report Wizard][report-wizard] |
| 65 | +- [Use SQLite as a data source for reports (as demonstrated in the current example)][sqlite-data-source] |
| 66 | +- [Store report layouts in REPX files at design-time][reports-design-time-store] |
| 67 | +- API reference: |
| 68 | + - [TdxReport.Layout] (an XML-based layout template that can be stored in the BLOB field of a database) |
| 69 | + - [TdxMemData] (used to store report layout data in application runtime and between sessions) |
| 70 | + - [TDataSet] (ancestor of the `TdxMemData`, contains generic database connection methods) |
| 71 | + - [TdxBackendDatabaseSQLConnection] (used to supply data to reports) |
| 72 | + |
| 73 | +<!-- documentation links --> |
| 74 | +[reports-intro]: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports |
| 75 | +[report-wizard]: https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-report-wizard |
| 76 | +[sqlite-data-source]: https://docs.devexpress.com/VCL/405750/ExpressCrossPlatformLibrary/vcl-backend/database-engines/vcl-backend-sqlite-support |
| 77 | +[reports-design-time-store]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout#string-list-editor |
| 78 | +[dx-report-viewer]: https://docs.devexpress.com/XtraReports/401850/web-reporting/web-document-viewer |
| 79 | +[dx-report-designer]: https://docs.devexpress.com/XtraReports/119176/web-reporting/web-end-user-report-designer |
| 80 | + |
| 81 | + |
| 82 | +<!-- reference links --> |
| 83 | +[TdxReport.Layout]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout |
| 84 | +[TdxBackendDatabaseSQLConnection]: https://docs.devexpress.com/VCL/dxBackend.ConnectionString.SQL.TdxBackendDatabaseSQLConnection |
| 85 | +[TdxBackendDataSetJSONConnection]: https://docs.devexpress.com/VCL/dxBackend.ConnectionString.JSON.DataSet.TdxBackendDataSetJSONConnection |
| 86 | +[TdxMemData]: https://docs.devexpress.com/VCL/dxmdaset.TdxMemData |
| 87 | +[TDataSet]: https://docwiki.embarcadero.com/Libraries/Athens/en/Data.DB.TDataSet |
| 88 | + |
| 89 | +<!-- external documentation links --> |
| 90 | +<!-- in-repository links --> |
| 91 | + |
| 92 | + |
| 93 | +## More Examples |
| 94 | + |
| 95 | +- [Store report layouts in REPX files][file-example] |
| 96 | + |
| 97 | +[file-example]: https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-file |
| 98 | + |
| 99 | + |
24 | 100 | <!-- feedback --> |
25 | 101 | ## Does This Example Address Your Development Requirements/Objectives? |
26 | 102 |
|
27 | 103 | [<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) |
28 | 104 |
|
29 | 105 | (you will be redirected to DevExpress.com to submit your response) |
30 | 106 | <!-- feedback end --> |
31 | | - |
32 | | - |
33 | | - |
|
0 commit comments