Saturday 31 August 2013


How to save (load) a report definition from a file

0
This example demonstrates how to save / load a report definition from a REPX file.
Open in popup window
using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...

namespace SaveLoadDefinition {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        // A temporary path to save a report to.
        string filePath = @"C:\Temp\XtraReport1.repx";

        private void button1_Click(object sender, EventArgs e) {
            // Create a report.
            XtraReport1 report = new XtraReport1();

            // Save the report's layout to the configuration file.
            report.SaveLayout(filePath);
        }

        private void button2_Click(object sender, EventArgs e) {
            // Create a report.
            XtraReport1 report = new XtraReport1();
            ReportPrintTool printTool = new ReportPrintTool(report);

            // Load the report's layout from the specified file.
            ((XtraReport1)printTool.Report).LoadLayout(filePath);

            // Display the print preview.
            printTool.ShowPreviewDialog();
        }

    }
}

No comments:

Post a Comment