Skip to content

Commit e32ffb4

Browse files
committed
readme: Add example and reference links
- Refactor the links structure to simplify maintenance. - Bring the file and code entity links to the DevExpress standard. - Add meta-markup to the code snippet blocks. Experimental markup to improve example import to the DevExpress Support Center.
1 parent aae84ff commit e32ffb4

1 file changed

Lines changed: 172 additions & 142 deletions

File tree

README.md

Lines changed: 172 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,172 @@
1-
<!-- default badges list -->
2-
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/1051124732/25.2.3%2B)
3-
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1306454)
4-
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
5-
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
6-
<!-- default badges end -->
7-
8-
# DevExpress&nbsp;VCL&nbsp;Reports&nbsp;– Import&nbsp;and&nbsp;Save Report&nbsp;Layouts to XML&nbsp;Files
9-
10-
This example uses XML-based REPX files as [report layout](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports) storage.
11-
12-
Run the app and execute the following actions:
13-
14-
- Customize our predefined layout and save it to a new file.
15-
- Create a new report layout and save it to a file.
16-
- Import a report layout you created earlier from a file.
17-
18-
<img width="450" src="./images/app.png" alt="An application with buttons to create a new report, import and save reports, open a report designer and report viewer" />
19-
20-
21-
## Prerequisites
22-
23-
[DevExpress Reports Prerequisites](https://docs.devexpress.com/VCL/405773/ExpressCrossPlatformLibrary/vcl-backend/reports-dashboards-app-deployment#vcl-reportsdashboards-prerequisites)
24-
25-
26-
## Implementation Details
27-
28-
### Import a Report Layout from a File
29-
30-
To import (load) a report layout from a file, call the
31-
[`Layout.LoadFromFile`](https://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TStrings.LoadFromFile)
32-
method and assign a name to the
33-
[`ReportName`](https://docs.devexpress.com/VCL/dxReport.TdxReport.ReportName) property:
34-
35-
**Delphi:**
36-
```delphi
37-
procedure TMainForm.ImportReport(const AFileName: string);
38-
begin
39-
// Import a report layout from a file
40-
dxReport1.Layout.LoadFromFile(AFileName);
41-
// Assign the file's name as an internal report name
42-
dxReport1.ReportName := ChangeFileExt(ExtractFileName(AFileName), '');
43-
end;
44-
```
45-
46-
**C++Builder:**
47-
```cpp
48-
void __fastcall TMainForm::ImportReport(const String &FileName)
49-
{
50-
// Import a report layout from a file
51-
dxReport1->Layout->LoadFromFile(FileName);
52-
// Assign the file's name as an internal report name
53-
dxReport1->ReportName = ChangeFileExt(ExtractFileName(FileName), "");
54-
}
55-
```
56-
57-
> [!Note]
58-
> An internal report name may differ from the source REPX file name.
59-
60-
61-
### Save a Report Layout to a File
62-
63-
To save the current report layout to a file, call the
64-
[`Layout.SaveToFile`](https://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TStrings.SaveToFile) method:
65-
66-
**Delphi:**
67-
```delphi
68-
procedure TMainForm.SaveReport(const AFileName: string);
69-
begin
70-
// Save the report layout to a file
71-
dxReport1.Layout.SaveToFile(AFileName);
72-
end;
73-
```
74-
75-
**C++Builder:**
76-
```cpp
77-
void __fastcall TMainForm::SaveReport(const String &FileName)
78-
{
79-
// Save the report layout to a file
80-
dxReport1->Layout->SaveToFile(FileName);
81-
}
82-
```
83-
84-
> [!Note]
85-
> Internal report names are not stored in REPX files.
86-
87-
88-
## Test the Example
89-
90-
### Modify the Pre-loaded Layout and Save to a New File
91-
92-
The example application loads a predefined layout at startup: `TableReport.repx`.
93-
You can modify this preloaded report layout and then save changes to a REPX file.
94-
95-
1. Build and run the sample application.
96-
Note the preloaded layout's name in the application's caption.
97-
2. Click **Open Designer** to edit the loaded layout in the DevExpress
98-
[Report Designer](https://docs.devexpress.com/XtraReports/119176/web-reporting/web-end-user-report-designer).
99-
Modify the layout as you see fit.
100-
3. Once you have made changes in the **Report Designer** dialog, click the hamburger button, select **Save**, and close the dialog.
101-
4. Click **Save to File** to save the report layout to a REPX file.
102-
You can overwrite an existing file or create a new file.
103-
5. Restart the application and click **Import from File** to import a report layout from the previously saved REPX file.
104-
6. Click **Open Viewer** to display the imported layout in the DevExpress
105-
[Report Viewer](https://docs.devexpress.com/XtraReports/401850/web-reporting/web-document-viewer).
106-
107-
108-
### Create, Design, and Save a New Layout
109-
110-
You can design a new layout from scratch and then save it to a REPX file:
111-
112-
1. Build and run the sample application.
113-
2. Click **Create New** to open a new blank report layout in the DevExpress
114-
[Report Designer](https://docs.devexpress.com/XtraReports/119176/web-reporting/web-end-user-report-designer).
115-
3. Design the report layout (template) using tools available in the **Report Designer**.
116-
Follow the tutorial: [Create a table report using the Report Wizard](https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-report-wizard).
117-
4. Once you have made all necessary changes in the **Report Designer** dialog, click the hamburger button, select **Save**, and enter a report layout name.
118-
Click **Save** and close the dialog.
119-
5. Click **Save to File** to save the report layout to a REPX file.
120-
6. Restart the application and click **Import from File** to import a report layout from the previously saved REPX file.
121-
7. Click **Open Viewer** to display the imported layout in the DevExpress
122-
[Report Viewer](https://docs.devexpress.com/XtraReports/401850/web-reporting/web-document-viewer).
123-
124-
125-
## Documentation and Examples
126-
127-
- [Introduction to VCL Reports](https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports)
128-
- [Tutorial: Create a table report using the Report Wizard](https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-report-wizard)
129-
- [How to store report layouts in REPX files at design-time](https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout#string-list-editor)
130-
- [How to store report layouts in a database (example application)](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-database)
131-
- [How to 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)
132-
- [API reference: `TdxReport.Layout` Property](https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout)
133-
- [API reference: `TdxBackendDatabaseSQLConnection` Component](https://docs.devexpress.com/VCL/dxBackend.ConnectionString.SQL.TdxBackendDatabaseSQLConnection)
134-
135-
136-
<!-- feedback -->
137-
## Does This Example Address Your Development Requirements/Objectives?
138-
139-
[<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-file&~~~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-file&~~~was_helpful=no)
140-
141-
(you will be redirected to DevExpress.com to submit your response)
142-
<!-- feedback end -->
1+
<!-- default badges list -->
2+
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/1051124732/25.2.3%2B)
3+
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1306454)
4+
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
5+
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
6+
<!-- default badges end -->
7+
8+
# DevExpress Reports for Delphi/C++Builder – Import and Save Report Layouts to XML Files
9+
10+
This example uses XML-based REPX files as [report layout][vcl-reports] storage.
11+
12+
Run the app and execute the following actions:
13+
14+
- Customize our predefined layout and save it to a new file.
15+
- Create a new report layout and save it to a file.
16+
- Import a report layout you created earlier from a file.
17+
18+
<img width="450" src="./images/app.png" alt="An application with buttons to create a new report, import and save reports, open a report designer and report viewer" />
19+
20+
21+
## Prerequisites
22+
23+
[DevExpress Reports Prerequisites][req]
24+
25+
[req]: https://docs.devexpress.com/VCL/405773/ExpressCrossPlatformLibrary/vcl-backend/reports-dashboards-app-deployment#vcl-reportsdashboards-prerequisites
26+
27+
28+
## Implementation Details
29+
30+
### Import a Report Layout from a File
31+
32+
To import (load) a report layout from a file, call the [Layout.LoadFromFile]
33+
method and assign a name to the [ReportName] property:
34+
35+
<!-- start-code-block -->
36+
#### Delphi
37+
```delphi
38+
procedure TMainForm.ImportReport(const AFileName: string);
39+
begin
40+
// Import a report layout from a file
41+
dxReport1.Layout.LoadFromFile(AFileName);
42+
// Assign the file's name as an internal report name
43+
dxReport1.ReportName := ChangeFileExt(ExtractFileName(AFileName), '');
44+
end;
45+
```
46+
47+
#### C++Builder
48+
```cpp
49+
void __fastcall TMainForm::ImportReport(const String &FileName)
50+
{
51+
// Import a report layout from a file
52+
dxReport1->Layout->LoadFromFile(FileName);
53+
// Assign the file's name as an internal report name
54+
dxReport1->ReportName = ChangeFileExt(ExtractFileName(FileName), "");
55+
}
56+
```
57+
<!-- end-code-block -->
58+
59+
> [!Note]
60+
> An internal report name may differ from the source REPX file name.
61+
62+
63+
### Save a Report Layout to a File
64+
65+
To save the current report layout to a file, call the [Layout.SaveToFile] method:
66+
67+
<!-- start-code-block -->
68+
#### Delphi
69+
```delphi
70+
procedure TMainForm.SaveReport(const AFileName: string);
71+
begin
72+
// Save the report layout to a file
73+
dxReport1.Layout.SaveToFile(AFileName);
74+
end;
75+
```
76+
77+
#### C++Builder
78+
```cpp
79+
void __fastcall TMainForm::SaveReport(const String &FileName)
80+
{
81+
// Save the report layout to a file
82+
dxReport1->Layout->SaveToFile(FileName);
83+
}
84+
```
85+
<!-- end-code-block -->
86+
87+
> [!Note]
88+
> Internal report names are not stored in REPX files.
89+
90+
91+
## Test the Example
92+
93+
### Modify the Pre-loaded Layout and Save to a New File
94+
95+
The example application loads a predefined layout at startup: [TableReport.repx].
96+
You can modify this preloaded report layout and then save changes to a REPX file.
97+
98+
1. Build and run the sample application.
99+
Note the preloaded layout's name in the application's caption.
100+
2. Click **Open Designer** to edit the loaded layout in the DevExpress
101+
[Report Designer][designer].
102+
Modify the layout as you see fit.
103+
3. Once you have made changes in the **Report Designer** dialog, click the hamburger button, select **Save**, and close the dialog.
104+
4. Click **Save to File** to save the report layout to a REPX file.
105+
You can overwrite an existing file or create a new file.
106+
5. Restart the application and click **Import from File** to import a report layout from the previously saved REPX file.
107+
6. Click **Open Viewer** to display the imported layout in the DevExpress
108+
[Report Viewer][viewer].
109+
110+
111+
### Create, Design, and Save a New Layout
112+
113+
You can design a new layout from scratch and then save it to a REPX file:
114+
115+
1. Build and run the sample application.
116+
2. Click **Create New** to open a new blank report layout in the DevExpress
117+
[Report Designer][designer].
118+
3. Design the report layout (template) using tools available in the **Report Designer**.
119+
Follow the tutorial: [Create a table report using the Report Wizard][wizard-tutorial].
120+
4. Once you have made all necessary changes in the **Report Designer** dialog, click the hamburger button, select **Save**, and enter a report layout name.
121+
Click **Save** and close the dialog.
122+
5. Click **Save to File** to save the report layout to a REPX file.
123+
6. Restart the application and click **Import from File** to import a report layout from the previously saved REPX file.
124+
7. Click **Open Viewer** to display the imported layout in the DevExpress
125+
[Report Viewer][viewer].
126+
127+
128+
## Files to Review
129+
130+
- [uMainForm.pas] (Delphi) and [uMainForm.cpp] (C++Builder) import and save report layouts to REPX files.
131+
- [TableReport.repx] contains a report layout designed to generate a customer order report.
132+
133+
[uMainForm.pas]: ./Delphi/uMainForm.pas
134+
[uMainForm.cpp]: ./CPB/uMainForm.cpp
135+
[TableReport.repx]: ./Table%20Report.repx
136+
137+
## Documentation
138+
139+
- [Introduction to VCL Reports][vcl-reports]
140+
- [Tutorial: Create a table report using the Report Wizard][wizard-tutorial]
141+
- [Store report layouts in REPX files at design-time](https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout#string-list-editor)
142+
- [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)
143+
- API reference:
144+
- [TdxReport.Layout]
145+
- [TdxReport.Layout.LoadFromFile][Layout.LoadFromFile]
146+
- [TdxReport.Layout.SaveToFile][Layout.SaveToFile]
147+
- [TdxReport.ReportName][ReportName]
148+
- [TdxBackendDatabaseSQLConnection]
149+
150+
[vcl-reports]: https://docs.devexpress.com/VCL/405469/ExpressReports/vcl-reports
151+
[designer]: https://docs.devexpress.com/XtraReports/119176/web-reporting/web-end-user-report-designer
152+
[viewer]: https://docs.devexpress.com/XtraReports/401850/web-reporting/web-document-viewer
153+
[wizard-tutorial]: https://docs.devexpress.com/VCL/405760/ExpressReports/getting-started/create-table-report-using-report-wizard
154+
155+
[TdxReport.Layout]: https://docs.devexpress.com/VCL/dxReport.TdxReport.Layout
156+
[Layout.LoadFromFile]: https://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TStrings.LoadFromFile
157+
[Layout.SaveToFile]: https://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TStrings.SaveToFile
158+
[ReportName]: https://docs.devexpress.com/VCL/dxReport.TdxReport.ReportName
159+
[TdxBackendDatabaseSQLConnection]: https://docs.devexpress.com/VCL/dxBackend.ConnectionString.SQL.TdxBackendDatabaseSQLConnection
160+
161+
## More Examples
162+
163+
- [Store DevExpress VCL Report Layouts in a Database](https://github.com/DevExpress-Examples/vcl-reports-store-layout-template-database)
164+
- [Localize the DevExpress VCL Report Viewer and Report Designer UI](https://github.com/DevExpress-Examples/vcl-reports-localize)
165+
166+
<!-- feedback -->
167+
## Does This Example Address Your Development Requirements/Objectives?
168+
169+
[<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-file&~~~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-file&~~~was_helpful=no)
170+
171+
(you will be redirected to DevExpress.com to submit your response)
172+
<!-- feedback end -->

0 commit comments

Comments
 (0)