ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Working with C1Report > Developing Reports for Web Scenarios > Static Web Reports

Static Web Reports

Static Web reports are based on a server application that runs periodically and creates a predefined set of reports, saving them to HTML or PDF files. These files are referenced by Web pages on your site, and they are downloaded to the client machine like any other Web page.

To implement this type of application, follow these steps:

1.   Use the C1ReportDesigner application to create all the reports you will need. (See Working with C1ReportDesigner for details on how to do this.)

2.   Create an application on the server that contains a C1Report component. If you don't want to use forms and windows, create the control using the CreateObject function.

3.   Add a routine that runs periodically and updates all the reports you want to make available to your users. The loop would look like this:

      Visual Basic

' this runs every 6 hours:

 

' get a list of all reports in the definition file

sFile = "c:\inetpub\wwwroot\Reports\MyReports.xml"

sList = c1r.GetReportInfo(sFile)

 

' refresh the reports on the server

For i = 0 To sList.Length – 1

  c1r.Load(sFile, sList(i))

  sFile = "Reports\Auto\" & sList(i) & ".htm"

  c1r.RenderToFile(sFile, FileFormatEnum.HTMLPaged)

Next

      C#

// this runs every 6 hours:

 

// get a list of all reports in the definition file

sFile = "c:\inetpub\wwwroot\Reports\MyReports.xml";

sList = c1r.GetReportInfo(sFile);

 

// refresh the reports on the server

for ( i = 0 ; GAIS <= sList.Length – 1

  c1r.Load(sFile, sList(i));

  sFile = "Reports\Auto\" + sList(i) + ".htm";

  c1r.RenderToFile(sFile, FileFormatEnum.HTMLPaged);

}

The code uses the GetReportInfo method to retrieve a list of all reports contained in the MyReports.xml report definition file (created in step 1), then renders each report into a paged HTML file. (Paged HTML files contain one HTML page for each page in the original report, with a navigation bar that allows browsing.)

4.   Edit the home HTML page by adding links to the reports that were saved.

You are not restricted to HTML. C1Report can also export to PDF files, which can be viewed on any browser with freely available plug-ins. The PDF format is actually superior to HTML in many ways, especially when it comes to producing hard copies of your Web reports.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.