WinUI | ComponentOne
Controls / FlexViewer (Beta) / View Documents
In This Topic
    View Documents
    In This Topic

    FlexViewer allows you to view different types of documents such as PDF files, FlexReport and SSRS reports. Just with a few lines of code, you can easily render these files in the FlexViewer control. Let us explore it in detail in the following sections.

    View FlexReport

    To view the report in FlexViewer, create an object of the FlexReport class and load the report into it using the Load method. Then, define the datasource and assign the object of the FlexReport class to the DocumentSource property of the FlexViewer class. In this example, the report, productreport.flxr,  is stored in the system within a folder named WinUI_FlexViewer.

     

    C#
    Copy Code
    C1.Report.FlexReport flexReport = new C1.Report.FlexReport();
    flexReport.Load(@"D:\WinUI_FlexViewer\productreport.flxr", "Product Report");
    flexReport.DataSource.Recordset = _products;
    fv.DocumentSource = flexReport;
    

    View PDF

    To view PDF files in the FlexViewer control, create an object of C1PdfDocumentSource class. Then, fetch the location of the PDF file using DocumentLocation property and assign the object of the C1PdfDocumentSource class to the DocumentSource property of the FlexViewer class. In this example, the PDF file named ProductsReport.pdf is stored in the system.

     

    C#
    Copy Code
    C1PdfDocumentSource pds = new C1PdfDocumentSource();
    pds.DocumentLocation = "D:\\ProductsReport.pdf";
    fv.DocumentSource = pds; 
    

    View SSRS Report

    Similar to FlexReport and PDF file, you can view SSRS report in the FlexViewer control. To view the SSRS report, create an object of C1SSRSDocumentSource class and set the language and credentials for the object. Then, fetch the location of the SSRS report using DocumentLocation property and assign it to the object of C1SSRSDocumentSource class. Finally, generate the report by using the Generate method and assign the object of C1SSRSDocumentSource class to the DocumentSource property of the FlexViewer class. In this example, the SSRS report is fetched from a report server location by providing the required credentials.

     

    C#
    Copy Code
    C1SSRSDocumentSource sds = new C1SSRSDocumentSource();
    sds.Language = new System.Globalization.CultureInfo("en-US");
    sds.Credential = new NetworkCredential("ssrs_****", "***********", "");
    sds.DocumentLocation = new SSRSReportLocation(http://ssrs.componentone.com:****/**********, "/*************/Employee Sales Summary Detail");
    sds.Generate();
    fv.DocumentSource = sds;