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

📄 unit1.pas

📁 很实用的程序
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Excel2000, OleServer, Excel97, ComCtrls,
  FlEdit;

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    ExcelApplication1: TExcelApplication;
    ExcelWorksheet1: TExcelWorksheet;
    ExcelWorkbook1: TExcelWorkbook;
    ProgressBar1: TProgressBar;
    FloatEdit1: TFloatEdit;
    Label1: TLabel;
    procedure BitBtn1Click(Sender: TObject);
    procedure FloatEdit1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);

 var
  i,TempInt:integer;
  aa,bb,cc,dd:string;
begin
  ExcelApplication1.FindFile;
  Try
    ExcelApplication1.Connect;
  Except
    MessageDlg('Excel 没有安装,请安装后运行。', mtError, [mbOk], 0);
    Abort;
  End;
  ProgressBar1.Visible:=True;
  ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
  ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
  dd:=FloatEdit1.text;
  tempint:=strtoint(dd);
  ProgressBar1.StepIt;
  for i:=1 to TempInt  do begin
    aa:=ExcelWorksheet1.Cells.item[i,1];
    bb:=ExcelWorksheet1.Cells.item[i,2];
    cc:=aa+bb;
    ExcelWorksheet1.Cells.item[i,3]:=cc;
    Application.ProcessMessages;
    ProGressBar1.StepBy(1);
  end;
    ProgressBar1.Visible:=false;
    ExcelWorkbook1.Disconnect;
    ExcelWorksheet1.Disconnect;
    ExcelApplication1.Disconnect;
    ExcelApplication1.Visible[1]:=True;
//  ExcelApplication1.Quit;

end;

procedure TForm1.FloatEdit1Change(Sender: TObject);
begin
  BitBtn1.Enabled:=FloatEdit1.Value>0;   
end;

end.

⌨️ 快捷键说明

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