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

📄 scexcelexportreg.pas

📁 delphi读写取excel,内附源码和Demo文件
💻 PAS
字号:
{--------------------------------------------------------------------------------
* Description : Property & Component Editors of TscExcelExport
* Dates : February 2000 - May 2003
* Version : 3.12 (Delphi 5,6 & 7)

* Author : Stefan Cruysberghs
* Email : stefancr@yucom.be
* Website : http://users.pandora.be/stefancr
  Visit Stefan's Homepage for other components and tools
--------------------------------------------------------------------------------
* $Archive: /Component Library/SC/scExcelExportReg.pas $
* $Author: Stefancr $
* $Date: 26/04/02 19:12 $
* $Modtime: 26/04/02 19:11 $
* $Revision: 3 $
--------------------------------------------------------------------------------
* This component is free of charge.
* The author doesn't give a warranty for error free running
  of this component and he doesn't give any support.
* Suggestions and bugs can be send by email.
--------------------------------------------------------------------------------
Installation
* Open the package dclExcelExport5.dpr (Delphi5), dclExcelExport6.dpr (Delphi6)
  or dclExcelExport7.dpr (Delphi7). Compile and Install the package.
* The TscExcelExport component can be found in the tabsheet 'SC' of the
  component palette.
* When you like to add the component to an existing package, add the unit
  scExcelExportReg.pas to a package. Make sure the DCP file dclOffice
  is added as required.
--------------------------------------------------------------------------------}


unit scExcelExportReg;

interface

uses Classes, {$IFDEF VER130} Dsgnintf; {$ELSE} DesignEditors, DesignIntf; {$ENDIF}

type
  TscExcelExportEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
    procedure Edit; override;
  end;

  TscFileProperty = class(TStringProperty)
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit; override;
  end;

procedure Register;

implementation

uses scExcelExport, TypInfo, Dialogs;

{$R scExcelExport.dcr}

procedure Register;
begin
  RegisterComponents('SC', [TscExcelExport]);
  RegisterComponentEditor(TscExcelExport,TscExcelExportEditor);
  RegisterPropertyEditor(TypeInfo(string),TscExcelExport,'Filename',TscFileProperty);
end;

//==============================================================================
// TscExcelExportEditor
//==============================================================================
procedure TscExcelExportEditor.Edit;
begin
  inherited;
  ExecuteVerb(1);
end;

//------------------------------------------------------------------------------
procedure TscExcelExportEditor.ExecuteVerb(Index: Integer);
var
  ExcelExport : TscExcelExport;
begin
  ExcelExport := (Component as TscExcelExport);

  case Index of
    0 :
      begin
        MessageDlg('TscExcelExport 3.12'+#13+#10+'Stefan Cruysberghs'+#13+#10+
          'Freeware, May 2003'+#13+#10+
          'http://users.pandora.be/stefancr', mtInformation, [mbOK], 0);
      end;
    1 :
      begin
        try
          ExcelExport.ExportDataset;
        finally
          ExcelExport.Disconnect;
        end
      end;
    2 :
      begin
        ExcelExport.LoadDefaultProperties;
      end;
  end;
end;

//------------------------------------------------------------------------------
function TscExcelExportEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0 : Result := 'About';
    1 : Result := 'Export to Excel';
    2 : Result := 'Load default properties';
  end;
end;

//------------------------------------------------------------------------------
function TscExcelExportEditor.GetVerbCount: Integer;
begin
  Result := 3;
end;

//==============================================================================
// TscFileProperty
//==============================================================================
procedure TscFileProperty.Edit;
var
  OpenDialog : TOpenDialog;
begin
  OpenDialog := TOpenDialog.Create(nil);
  try
    OpenDialog.Filter := 'Excel files|*.XLS';
    OpenDialog.DefaultExt := 'XLS';
    OpenDialog.Title := 'Select Excel file';
    if OpenDialog.Execute then
      SetStrValue(OpenDialog.FileName);
  finally
    OpenDialog.Free;
  end;
end;

//------------------------------------------------------------------------------
function TscFileProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

end.

⌨️ 快捷键说明

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