⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datadump.pas

📁 此控件可将数据表转换成多种格式:文本,HTML,RTF
💻 PAS
字号:
{
=========
DATA DUMP
=========
dump data set via exporter....


Copyright 10.1997 By MAD Soft

Telephone: Bulgaria, Sofia, 37-06-23
E_Mail:    NMMM@NSI.BG
           NMMM@HotMail.Com
Web:       Http:\\WWW.NSI.BG\NMMM\Home.Htm

Versions:
1.0 ?10.1997 First Build
1.1 ?11.1997 Added DumpTable
1.2  01.1998 Added DumpTitle
}

unit DataDump;

interface

uses
  Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  BasicExp, DB;

type
  TDataDump = class(TComponent)
  private
    { Private declarations }
    FDataSource : TDataSource;
    FExporter   : TAbstractExporter;
    FTitle      : String;
  protected
    { Protected declarations }
  public
    { Public declarations }
    Procedure Dump;
    Procedure DumpTitle;
    Procedure DumpTable;
  published
    { Published declarations }
    Property DataSource : TDataSource        Read FDataSource Write FDataSource;
    Property Exporter   : TAbstractExporter  Read FExporter   Write FExporter;
    Property Title      : String             Read FTitle      Write FTitle;
  end;

procedure Register;

implementation

Const ftCifri = [ftSmallint, ftInteger, ftWord, ftFloat, ftCurrency];

procedure Register;
begin
  RegisterComponents('Exporter', [TDataDump]);
end;

Procedure TDataDump.Dump;
   Begin
      If (AsSigned(FDataSource)               ) And
         (FDataSource.DataSet <> Nil          ) And
         (FDataSource.DataSet.Active          ) And
         (AsSigned(FExporter)                 ) Then
         Begin
            FExporter.Open;
            DumpTitle;
            DumpTable;
            FExporter.Close;
         End;
   End;

Procedure TDataDump.DumpTitle;
   Begin
      If FTitle <> '' Then
         FExporter.QuickParagraph(FTitle,REAlignCenter,1,[REBold,REUnderline]);
   End;

Procedure TDataDump.DumpTable;
   Var I : Integer;
       T : TDataSet;
   Begin
      If (AsSigned(FDataSource)               ) And
         (FDataSource.DataSet <> Nil          ) And
         (FDataSource.DataSet.Active          ) And
         (AsSigned(FExporter)                 ) Then
         Begin
            T:=FDataSource.DataSet; {Wow!}

            If T.FieldCount = 0 Then
               Exit; {??? ;}

            FExporter.BeginTable(1);
            FExporter.BeginRow;

            For I:=0 To T.FieldCount - 1 Do
               If T.Fields[I].Visible Then
                  FExporter.Cell(T.Fields[I].DisplayLabel, REAlignCenter,9,[REBold]);

            FExporter.EndRow;

            T.First;
            While Not T.EOF Do
               Begin
                  FExporter.BeginRow;
                  For I:=0 To T.FieldCount - 1 Do
                     If T.Fields[I].Visible Then
                        If Not (T.Fields[I].DataType In FTCifri) Then
                           FExporter.Cell(T.Fields[I].AsString, REAlignLeft,10,[])
                        Else
                           FExporter.Cell(T.Fields[I].AsString, REAlignRight,10,[]);
                  FExporter.EndRow;

                  T.Next;
               End;

            FExporter.EndTable;
         End;
   End;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -