KB Article Q279230
Visible to All Users

How to copy or clone an existing report

You can consider the following solutions depending on the reporting module version you are using:

Reports V2 Module
1. If a report was created at design time in Visual Studio, consider one of the following solutions:
1.1.  Use the Copy Predefined Report Action to clone a predefined report and then modify the copy (supported for both WinForms and ASP.NET);

NOTE:  When you create a predefined report with scripts that will possibly be modified by end-users, do not use XtraReport events directly. Instead, use the XtraReport.Scripts and/or XRControl.Scripts properties in the Report Designer, as demonstrated in the Scripting Overview topic. Otherwise, your code will not be copied to user scripts via the Copy Predefined Report Action. If you use this approach, add references to assemblies used in scripts to the XtraReport.ScriptReferences property. Assemblies used in your application will be attached to scripts automatically. If classes from such assemblies cause errors when scripts are evaluated, either use fully qualified names, or add the using (Imports in VB) directive at the beginning of the script.

1.2.  If you happen to have a ready *.REPX definition for your report, create a new report and then use the built-in import and export commands in the WinForms or design-time report designer (unavailable for ASP.NET).

1.3.  You can copy the corresponding files - YourReportName.cs, YourReportName.resx, YourReportName.Designer.cs. Alternatively, create a separate assembly with your reports and reference this assembly in all projects where these reports are required.

2. If a report was created at runtime, consider one of the following solutions:
2.1.  Copy data rows in the ReportDataV2 table manually using your database server means;
2.2.  Copy related ReportDataV2 persistent objects using programmatic solutions from the Should I use XPO to transfer/synchronize data between databases? and How execute "copy pre-defined reports" in XAF ReportsV2 from code? articles, e.g. the Cloner or ReportsStorage.CopyFrom APIs.
2.3.  Add the Clone Object module in the Module or Application Designers and set the BOModel | DevExpress.Persistent.BaseImpl | ReportDataV2 | IsClonable property to True in the Model Editor to enable the Clone Object Action for Views with ReportDataV2 objects (available for XPO only):

With EF, you can use any native EF approach to clone the ReportDataV2 object, since it is a simple record in the database with a serialized report.
Reports Module (Obsolete)
Use the 2.1 -  2.3 solutions, but work with the ReportData table/type instead of the ReportDataV2 one. Be sure to add the ReportsModule component using the Module or Application Designers before invoking the Model Editor for customizations.

Comments (3)

    Worked like a BREEZE! Perfect! The last suggestion was very intelligent… Thanks a million (again).

      I love it! Especially because the DetailView for the cloned report is opened!

      Did not get it working for the platform-agnostic module however. Added the ReportModule to Module.cs (the design file showed the requiredfile line), but in the model nothing showed up.

      Willem

      Dennis Garavsky (DevExpress) 13 years ago

        @Willem:
        I cannot replicate this problem in my tests. See the attached screenshot.
        If you require any further assistance with this, please create a separate ticket and attach your problematic sample project along with exact repro and screenshots.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.