FlexReport for UWP | ComponentOne
FlexReport Quick Start / Step 2 of 2: Loading and Rendering the Report
In This Topic
    Step 2 of 2: Loading and Rendering the Report
    In This Topic
    1. Create a new UWP project and select Blank App (Universal Windows) in Visual Studio.
    2. Add the C1FlexViewer control to the main page.
    3. Add a reference to C1.UWP.FlexReport.
    4. Download the FlexReport.SQLite project and add it to your solution.
      Also, if UWP Edition is installed on your system, you can find FlexReport.SQLite project in Documents\ComponentOne Samples\UWP\C1.UWP.FlexReport\CS folder.
    5. Rebuild your project after adding the project.
    6. Right-click your existing project in Solution Explorer and Select Add|Reference.... The Reference Manager opens.
    7. Select Projects|Solution from the left pane and then select FlexReport.SQLite and click OK. This will add the FlexReport.SQLite.dll to the References folder in your project.
      Note: Adding FlexReport.SQLite project as a reference to your app's project is required for FlexReport to be able to use SQLite. FlexReport.SQLite works as a wrapper that allows the FlexReport assembly to avoid having a hard reference to SQLite.
    8. Add the report definition file created using the designer in Step 1 of 2: Creating a Report Definition to the Assets folder of your project and set its Build Action property to Content.
    9. Add C1NWind.mdb database to the Assets folder, set its Build Action property to Content.
    10. Add the following Page_Loaded event in the code view to load and render the report in FlexViewer control:
      Private Sub Page_Loaded(sender As Object, e As RoutedEventArgs)
            ' Copy the SQLite database file from app's Assets to LocalFolder - in a .FLXR report def,
            ' it can be referenced as ?(SpecialFolder.SystemDefault):
            ' Data Source=?(SpecialFolder.SystemDefault)\C1NWind.db
            ' When designing the report, ?(SpecialFolder.SystemDefault) refers to Environment.SpecialFolder.MyDocuments, so you can
            ' put the report database file in your MyDocuments folder to conveniently design and test run your reports:
              Dim dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "C1NWind.db")
              If Not File.Exists(dbPath) Then
                      File.Copy("Assets\C1NWind.db", dbPath)
              End If
      
              ' Create and load the report:
              Dim report As New C1FlexReport()
              Using fs As Stream = File.OpenRead("Assets/ProductsUWP.flxr")
                      report.Load(fs, "ProductList")
              End Using
      
              ' Assign the report to the viewer's DocumentSource - it will be generated automatically
              ' (asynchronously by default) when the viewer shows it:
              Me.flexViewer.DocumentSource = report
      End Sub
      
      private async void Page_Loaded(object sender, RoutedEventArgs e)
      { 
      // Copy the SQLite database file from app's Assets to LocalFolder-in .FLXR report definition
          var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "C1NWind.db");
          if (!File.Exists(dbPath))
              File.Copy(@"Assets\C1NWind.db", dbPath);
      
      // Create and load the report:
          C1FlexReport report = new C1FlexReport();
          using (Stream fs = File.OpenRead("Assets/ProductsUWP.flxr"))
              report.Load(fs, "ProductList");
      
      // Assign the report to the viewer's DocumentSource - it will be generated automatically
      // (asynchronously by default) when the viewer shows it:
          this.flexViewer.DocumentSource = report;
      }