1. 程式人生 > 其它 >FastReport VCL程式設計師手冊:如何使用樣式

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