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

📄 uflxrepthread.pas

📁 Delphi/BCB 各种版本都支持的Excel 读写控件.一成功应用在N个项目中 .
💻 PAS
字号:
unit UFlxRepThread;

interface

uses
  Classes,UExcelAdapter, XLSAdapter, UCustomFlexCelReport, UFlexcelReport, UThreadData, SysUtils;

type
  TFlxRepThread = class(TThread)
  private
    Dm: TThreadData;
    FFileName: string;
    { Private declarations }
  protected
    procedure Execute; override;
  public
    ErrMsg: string;
    property FileName: string read FFileName;
    constructor Create;
    procedure Finish;

  end;

implementation

{ Important: Methods and properties of objects in VCL can only be used in a
  method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TFlxRepThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TFlxRepThread }

constructor TFlxRepThread.Create;
begin
  inherited Create(True);
  FreeOnTerminate:=true;
  FFileName:=ExtractFilePath(ParamStr(0))+ IntToStr(random(10000)) + IntToStr(random(10000))+'.xls';
end;

procedure TFlxRepThread.Execute;
begin
  ErrMsg:='';
  try
    Dm:=TThreadData.Create(nil);
    try
      //this is just for testing... I hope there will be no repeated filenames
      Dm.FlxRep.FileName:=FFilename;
      Dm.FlxRep.Run;
    finally
      FreeAndNil(Dm);
    end; //finally
    if Terminated then ErrMsg:='Canceled';
  except
    //Clear the Exception
    on e: Exception do ErrMsg:=e.Message;
  end; //Except
end;

procedure TFlxRepThread.Finish;
begin
  if Dm<>nil then Dm.FlxRep.Cancel;
  Terminate;
end;

end.

⌨️ 快捷键说明

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