|
1 | | -# RptToXml |
| 1 | +# Crystal Report XML Extractor |
2 | 2 |
|
3 | | -Dumps a Crystal Reports RPT file to XML. Useful for diffs. |
| 3 | +Extracts the complete definition of Crystal Report (`.rpt`) files into structured XML, including report layout, formatting, data sources, SQL commands, formulas, parameters, and saved data. |
4 | 4 |
|
5 | | -Binary releases available on the [Releases](https://github.com/ajryan/RptToXml/releases) page. |
| 5 | +This is Step 1 of the Crystal Report to Power BI migration pipeline. The extracted XML serves as the source of truth for all downstream conversion steps. |
6 | 6 |
|
7 | | -Ported to C# from the [original VB project](http://code.google.com/p/rpttoxml/) |
| 7 | +Based on [RptToXml](https://github.com/ajryan/RptToXml) by Aidan Ryan (MIT License). |
8 | 8 |
|
9 | | -## Running |
| 9 | +--- |
10 | 10 |
|
11 | | -Download the latest [release](https://github.com/ajryan/RptToXml/releases). |
| 11 | +## What It Extracts |
12 | 12 |
|
13 | | -RptToXml references Crystal Reports assemblies. The easiest way to get them onto a development machine is to install the Crystal Reports Runtime from an MSI downloaded from [this page](https://www.sap.com/cmp/td/sap-crystal-reports-visual-studio-trial.html). |
| 13 | +| Data | Description | |
| 14 | +|---|---| |
| 15 | +| **Report Layout** | Sections (header, detail, footer), objects with exact positions (x, y, width, height) | |
| 16 | +| **Formatting** | Font (name, size, bold, italic, underline), text color, alignment, borders | |
| 17 | +| **Data Sources** | Database connections (server, database), SQL command text, table joins | |
| 18 | +| **Fields** | Database fields with type and length, formula field definitions | |
| 19 | +| **Formulas** | Full Crystal formula text (supports multilingual switch statements) | |
| 20 | +| **Parameters** | Report parameters with types and default values | |
| 21 | +| **Saved Data** | Cached report data exported as tab-separated values | |
| 22 | +| **Visual Elements** | Lines, boxes, images, subreports with positions and styles | |
| 23 | +| **Suppress Conditions** | Visibility rules and conditional formatting formulas | |
14 | 24 |
|
15 | | -Install the SAP frameworks (probably need 32-bit and 64-bit): |
| 25 | +--- |
16 | 26 |
|
17 | | -- SAP Crystal Reports for Visual Studio (SP##) runtime engine for .NET framework MSI (32-bit) |
18 | | -- SAP Crystal Reports for Visual Studio (SP##) runtime engine for .NET framework MSI (64-bit) |
| 27 | +## Prerequisites |
19 | 28 |
|
20 | | -Run the executable from the command line with |
| 29 | +**SAP Crystal Reports Runtime** (64-bit) must be installed: |
21 | 30 |
|
22 | | -```sh |
23 | | -# process a single file |
24 | | -RptToXml.exe path/to/report_name.rpt path/to/output.xml |
| 31 | +1. Go to https://origin.softwaredownloads.sap.com/public/site/index.html |
| 32 | +2. Search for: "SAP Crystal Reports, developer version" |
| 33 | +3. Download: **CR for Visual Studio SP39 CR Runtime 64-bit MSI** (117.1 MB) |
| 34 | +4. Run the MSI installer |
25 | 35 |
|
26 | | -# process a directory of reports |
27 | | -cd path/to/reports |
28 | | -RptToXml.exe -r |
| 36 | +--- |
| 37 | + |
| 38 | +## Building |
| 39 | + |
| 40 | +Open `Source\RptToXml.sln` in Visual Studio and build (Debug or Release). |
| 41 | + |
| 42 | +The executable is at `Source\bin\Debug\RptToXml.exe`. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Usage |
| 47 | + |
| 48 | +**Single file:** |
| 49 | +```bat |
| 50 | +RptToXml.exe "path\to\report.rpt" "path\to\output.xml" |
29 | 51 | ``` |
30 | 52 |
|
31 | | -## Building From Source |
| 53 | +**All files in a folder:** |
| 54 | +```bat |
| 55 | +cd path\to\rpt_folder |
| 56 | +RptToXml.exe -r --ignore-errors |
| 57 | +``` |
32 | 58 |
|
33 | | -The solution will build with VS2012 or higher. Express editions have not been tested but should work. |
| 59 | +**Options:** |
| 60 | + |
| 61 | +| Flag | Description | |
| 62 | +|---|---| |
| 63 | +| `-r` | Recursively process all .rpt files in the current directory | |
| 64 | +| `--ignore-errors` | Continue to the next file if an error occurs | |
| 65 | +| `--stdout` | Write XML to console instead of file | |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## Output Structure |
| 70 | + |
| 71 | +```xml |
| 72 | +<Report Name="" FileName="report.rpt" HasSavedData="True"> |
| 73 | + <Summaryinfo ReportTitle="..." /> |
| 74 | + <PrintOptions PageContentWidth="..." PageContentHeight="..." PaperOrientation="..." /> |
| 75 | + <Database> |
| 76 | + <TableLinks> ... </TableLinks> |
| 77 | + <Tables> |
| 78 | + <Table Alias="Header" ClassName="CrystalReports.CommandTable"> |
| 79 | + <ConnectionInfo QE_ServerDescription="." QE_DatabaseName="..." /> |
| 80 | + <Command>SELECT ... FROM ...</Command> |
| 81 | + <Fields> |
| 82 | + <Field Name="..." Type="..." Length="..." /> |
| 83 | + </Fields> |
| 84 | + </Table> |
| 85 | + </Tables> |
| 86 | + </Database> |
| 87 | + <DataDefinition> |
| 88 | + <FormulaFieldDefinition Name="Title" ...> |
| 89 | + switch({@X_Language} = 'EN', 'Service Contract', True, 'Default') |
| 90 | + </FormulaFieldDefinition> |
| 91 | + <ParameterFieldDefinition Name="DocKey" ValueType="NumberField" /> |
| 92 | + </DataDefinition> |
| 93 | + <ReportDefinition> |
| 94 | + <Areas> |
| 95 | + <Area Kind="PageHeader"> |
| 96 | + <Section Height="2705" Kind="PageHeader" Name="PageHeaderSection1"> |
| 97 | + <ReportObjects> |
| 98 | + <FieldObject Name="Title1" DataSource="{@Title}" Top="191" Left="0" Width="6313" Height="529"> |
| 99 | + <Font Name="Arial" Size="16" Bold="False" /> |
| 100 | + <ObjectFormat HorizontalAlignment="DefaultAlign" EnableSuppress="False" /> |
| 101 | + </FieldObject> |
| 102 | + </ReportObjects> |
| 103 | + </Section> |
| 104 | + </Area> |
| 105 | + </Areas> |
| 106 | + </ReportDefinition> |
| 107 | + <SavedData> |
| 108 | + <Row Index="0"><Col Index="0">Service Contract</Col></Row> |
| 109 | + <Row Index="1"><Col Index="0">Customer Name</Col><Col Index="1">:</Col><Col Index="2">Microchips</Col></Row> |
| 110 | + </SavedData> |
| 111 | +</Report> |
| 112 | +``` |
34 | 113 |
|
35 | | -Install the SAP pacakge for Visual Studio: |
| 114 | +--- |
36 | 115 |
|
37 | | -- SAP Crystal Reports for Visual Studio (SP##) installation package for Microsoft Visual Studio IDE (VS 20## and above or below) |
| 116 | +## License |
38 | 117 |
|
| 118 | +MIT License. See [LICENSE](LICENSE) for details. |
39 | 119 |
|
40 | | -Find the executable `RptToXml.exe` in ```RptToXml/bin/<where did you build to?>``` after building the solution in Visual Studio. |
| 120 | +Original work by [Aidan Ryan](https://github.com/ajryan/RptToXml). Modified for the Crystal Report to Power BI migration pipeline with saved data extraction and security hardening. |
0 commit comments