FastReport Documentation

repository·master·Indexed 25 days ago

https://github.com/fastreports/fastreport

FastReport is an open-source report generator for .NET (6, Core, and Framework) that enables developers to create complex, band-oriented reports using various data sources and scripting languages. The documentation includes guidance on the fastreport-web package (v1.0.0) and development workflows for the React-based client application, covering project structure, npm scripts, debugging in VS Code and WebStorm, and Webpack configuration for assets and styles.

Tokens
16.9K
Snippets
87
Records
112
Agent score
84%

What's inside FastReport

  1. Overview of FastReport features

    master

    FastReport is an open-source, band-oriented report generator for .NET 6, .NET Core, and .NET Framework. It is compatible with .NET Standard 2.0 and higher.

    Key Capabilities:

    • Band-Oriented Design: Supports 13 band types (e.g., Report Title, Page Header, Data, Group Header, etc.) for complex layouts like master-detail or multi-column reports.
    • Rich Object Set: Includes text, picture, line, shape, barcode, matrix, table, and checkbox objects.
    • Data Integration: Connects to XML, CSV, JSON, MS SQL, MySQL, Oracle, Postgres, MongoDB, Couchbase, RavenDB, and SQLite. It also supports IEnumerable business objects.
    • Internal Scripting: Includes a built-in engine supporting C# and VB.NET for complex data handling within reports.
    • Report Inheritance: Allows creating a base report with common elements (logos, footers) and inheriting them in other reports.
  2. Understand the project folder structure

    master

    The project follows a standard structure where specific files are required for the build to function:

    • public/index.html: The page template.
    • src/index.js: The JavaScript entry point.

    Important constraints:

    • All JS and CSS files must be placed inside the src directory for Webpack to process them.
    • Only files inside the public folder can be referenced directly from public/index.html.
    • You can create top-level directories for non-production items like documentation, but they will not be included in the production build.
    my-app/
      README.md
      node_modules/
      package.json
      public/
        index.html
        favicon.ico
      src/
        App.css
        App.js
        App.test.js
        index.css
        index.js
        logo.svg
  3. Import components using ES6 modules

    master

    This project uses ES6 modules. While require() is supported, it is recommended to use import and export.

    Default Exports: Use when a module exports a single entity (e.g., a component).

    Named Exports: Use for utility modules exporting multiple functions.

    Example of importing a component:

    // Button.js
    import React, { Component } from 'react';
    
    class Button extends Component {
      render() {
        // ...
      }
    }
    
    export default Button;
    
    // DangerButton.js
    import React, { Component } from 'react';
    import Button from './Button';
    
    class DangerButton extends Component {
      render() {
        return <Button color="red" />;
      }
    }
    
    export default DangerButton;
    import Button from './Button';
    
    class DangerButton extends Component {
      render() {
        return <Button color="red" />;
      }
    }
  4. Register SQLite data connection in FastReport

    master

    To use SQLite as a data source in FastReport, you must register the SQLiteDataConnection type with the FastReport utility system once during your application's startup sequence. This enables the Designer and the report engine to recognize SQLite connections.

    FastReport.Utils.RegisteredObjects.AddConnection(typeof(SQLiteDataConnection));
  5. Deploy to GitHub Pages

    master

    To deploy to GitHub Pages, follow these steps:

    1. Add homepage to package.json:
      "homepage": "https://myusername.github.io/my-app"
    2. Install gh-pages and add scripts:
      npm install --save gh-pages
      In package.json, add these to your scripts:
      "predeploy": "npm run build",
      "deploy": "gh-pages -d build"
    3. Deploy:
      npm run deploy
    4. Configure GitHub Settings: Ensure your GitHub project settings use the gh-pages branch for Pages.

    Note on Routing: GitHub Pages does not support the HTML5 pushState API. To use client-side routing, you must either use hashHistory in your router or use a workaround like a 404.html redirect.

    npm install --save gh-pages
    npm run deploy
  6. Set up React Styleguidist for component documentation

    master

    React Styleguidist provides a style guide and an environment for developing components in isolation using Markdown examples.

    1. Install the package: npm install --save react-styleguidist (or yarn add react-styleguidist)
    2. Add the following scripts to your package.json:
      • styleguide: styleguidist server
      • styleguide:build: styleguidist build
    3. Run the styleguide server: npm run styleguide
       "scripts": {
    +    "styleguide": "styleguidist server",
    +    "styleguide:build": "styleguidist build",
         "start": "react-scripts start",
     }
  7. Configure Firebird data connection in FastReport

    master

    To use Firebird as a data source in FastReport, you must first register the Firebird connection type at application startup. Once registered, you can programmatically create a FirebirdDataConnection, configure its connection string, and add it to the report's dictionary.

    // 1. Execute this once at application start
    FastReport.Utils.RegisteredObjects.AddConnection(typeof(FirebirdDataConnection));
    
    // 2. Create and add the connection to your report
    Report report = new Report(); 
    report.Load(@"YourReport.frx");
    
    FirebirdDataConnection conn = new FirebirdDataConnection();
    conn.ConnectionString = "connection string";
    conn.CreateAllTables();
    report.Dictionary.Connections.Add(conn);
  8. Configure Progressive Web App (PWA) service workers

    master

    The production build is a Progressive Web App by default. You can manage service worker behavior in src/index.js.

    Opting Out of Caching

    To disable service workers before your initial production deployment, remove the call to registerServiceWorker() from src/index.js.

    Disabling Service Workers for Existing Users

    To uninstall a service worker from users who already have it enabled, modify your service worker import in src/index.js to use unregister instead of register:

    import { unregister } from './registerServiceWorker';
    // ... call unregister() instead of registerServiceWorker()

    Note: Depending on your server configuration, it may take up to 24 hours for the cache to be invalidated.

    import { unregister } from './registerServiceWorker';