FastReport VCL程序员手册:如何使用样式

FastReport VCL是用于Delphi,C ++ Builder,RAD Studio和Lazarus的报告和文档创建VCL库。它提供了可视化模板设计器,可以访问为30多种格式,并可以部署到云,网站,电子邮件和打印中。

近日,FastReport VCL更新至v6.9,在新版本中,在PDF更新中增加了对以下对象的并行表单支持:文本,替换和图片。相互之间形式中。同时修复了多个Bug问题。欢迎下载体验。(旁边向下按钮下载)

首先,让我们记住什么是“样式”、“样式集”和“样式库”。

样式是一个元素,它拥有名称和属性,并决定了设计属性,即颜色、字体和框架。样式决定了报表对象的设计方式。诸如此类的对象TfrxMemoView具有Style属性,该属性旨在设置样式名称。将值应用于此属性时,样式设计属性将复制到对象。

一组样式由多个样式组成,它们引用一个报表。该TfrxReport组分具有Styles属性,该属性是指的对象TfrxStyles类型。这组样式也有一个名字。样式集决定了整个报表的设计。

样式库包括多组样式。在库的帮助下,可以方便地为报表设计选择一个具体的集合。

该TfrxStyleItem代表风格。

  TfrxStyleItem = class(TCollectionItem)
  public
    // Style name.
    property Name: String;

    // Background color.
    property Color: TColor;

    // Font.
    property Font: TFont;

    // Frame.
    property Frame: TfrxFrame;
  end;

样式集由TfrxStyles类表示。它包括执行读取、保存、添加、删除以及搜索样式等设置操作的方法。默认情况下,样式文件集具有 FS3 扩展名。

  TfrxStyles = class(TCollection)
  public
    // Creates the styles set. One can specify “nil” instead of “AReport,” however in this case a user would be unable to use the “Apply” method.
    constructor Create(AReport: TfrxReport);

    // Adds a new style.
    function Add: TfrxStyleItem;

    // Returns the style with the given name.
    function Find(const Name: String): TfrxStyleItem;

    // Applies a set to a report.
    procedure Apply;

    // Returns the list of the styles names.
    procedure GetList(List: TStrings);

    // Reads a set.
    procedure LoadFromFile(const FileName: String);
    procedure LoadFromStream(Stream: TStream);

    // Saves a set.
    procedure SaveToFile(const FileName: String);
    procedure SaveToStream(Stream: TStream);

    // The list of styles.
    property Items[Index: Integer]: TfrxStyleItem; default;

    // A set’s name.
    property Name: String;
  end;

总之,最后一个TfrxStyleSheet类代表一个样式库。它具有库读取/保存以及添加、删除和样式集搜索的方法。

 TfrxStyleSheet = class(TObject)
  public
   // Constructs a library.
    constructor Create;

   // Clears a library.
    procedure Clear;

   // Deletes a set with certain number.
    procedure Delete(Index: Integer);

   // Returns the list of the names of styles’ sets.
    procedure GetList(List: TStrings);

   // Loads a library.
    procedure LoadFromFile(const FileName: String);
    procedure LoadFromStream(Stream: TStream);

   // Saves a library.
    procedure SaveToFile(const FileName: String);
    procedure SaveToStream(Stream: TStream);

   // Adds a new set of styles to the library.
    function Add: TfrxStyles;

   // Returns a number of styles’ sets in the library.
    function Count: Integer;

   // Returns a set with the given name.
    function Find(const Name: String): TfrxStyles;

   // Returns a set number with the given name.
    function IndexOf(const Name: String): Integer;

   // The list of styles’ sets.
    property Items[Index: Integer]: TfrxStyles; default;
  end;

 

如果您对FastReport感兴趣,欢迎加入FastReport QQ交流群:702295239

posted @ 2021-06-16 15:37  roffey  阅读(107)  评论(0编辑  收藏  举报