FlexReport lets you load reports in Visual Studio or end-user Report Designers. You can load .flxr files, both at design time and run time using Load method of the C1FlexReport class.
The Load method provides various overloads for loading the reports as listed below.
Overload | Description |
---|---|
Load(string reportName) | Loads a report without loading the FLXR file again. |
Load(string fileName, string reportName) | Loads a report from an XML report definition file. |
Load(string fileName, string reportName, out bool converted) | Loads a report from an XML report definition file and specifies if report definition was imported from an old C1Report format. |
Load(System.IO.Stream stream, string reportName) | Loads a report from an XML report definition in stream. |
Load(System.IO.Stream stream, string reportName, out bool converted) | Loads a report from an XML report definition in stream and specifies if report definition was imported from an old C1Report format. |
Load(System.Xml.Linq.XDocument doc, string reportName) | Loads a report from an System.Xml.Linq.XDocument. |
Load(System.Xml.Linq.XDocument doc, string reportName, out bool converted) | Loads a report from an System.Xml.Linq.XDocument and specifies if report definition was imported from an old C1Report format. |
Load(System.Xml.XmlDocument doc, string reportName) | Loads a report from an System.Xml.XmlDocument. |
Load(System.Xml.XmlDocument doc, string reportName, out bool converted) | Loads a report from an System.Xml.XmlDocument and specifies if report definition was imported from an old C1Report format. |
Lets explore how to use the Load method to load reports at design time and run time in the following sections.
Following are the steps to load the report at design time in Visual Studio:
C# |
Copy Code
|
---|---|
private void btnProductsReport_Click(object sender, EventArgs e) { //load report definition c1FlexReport1.Load(@"..\..\ProductsReport.flxr", "Products Report"); //preview the report c1FlexViewer1.DocumentSource = c1FlexReport1; } |
The output looks like the snapshot below:
Loading reports at run time requires a report definition file and viewer. The main advantage of this type of application is that if you modify the report format, there's no need to update the application. Simply send the new report definition file to the users and you are done.
To load reports at run time using the Load method, follow these steps:
The code starts by getting the location of the file that contains the report definitions. This is done using static methods in the system-defined Path and Application classes. You may have to adjust the code to reflect the location and name of your report definition file.
Then it uses the GetReportList method to retrieve an array containing the names of all reports in the report definition file (created in step 1), and populates the combo box allowing users to select the report.