Delphi实现操作Excel示例
implementation
uses ComOBJ;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var ExcelAPP1:Variant;
ExcelApp2:Variant;
I,j: Integer;
ID,IDX:string;
begin
try
ExcelAPP1:=CreateOleObject('Excel.Application');
ExcelAPP1.Workbooks.Open('D:\Program Files\Embarcadero\Projects\操作Excel\奖.xls');
ExcelAPP2:=CreateOleObject('Excel.Application');
ExcelApp2.Workbooks.Open('D:\Program Files\Embarcadero\Projects\操作Excel\贫2.xls');
for I := 2 to 610 do
begin
Label1.Caption:=IntToStr(i)+'行';
ID:=trim(ExcelAPP1.cells[I,2].value);
for j := 4 to 549 do
begin
IDX:=trim(ExcelAPP2.cells[j,4].value);
if (IDX=ID) then
begin
ExcelAPP1.cells[i,12].value:='已建档';
Break;
end;
end;
end;
Label1.Caption:='全部完成,正在保存......';
ExcelAPP1.Save;
Label1.Caption:='全部完成,已保存';
finally
ExcelAPP1.WorkBooks.Close;
ExcelAPP1.Quit;
ExcelApp2.WorkBooks.Close;
ExcelAPP2.Quit;
end;
end;
相关文档:
uses ShellAPI;
procedure TForm1.Button1Click(Sender: TObject);
begin
//用IE打开
ShellExecute(Handle, 'open', 'IExplore.EXE', 'about:blank', nil, SW_SHOWNORMAL);
//用火狐打开
ShellExecute(Handle, 'open', 'firefox.exe', 'about:blank', nil, SW_SHOWNORMAL);
//用默认浏览器打开
&nbs ......
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, Buttons;
type
TDemoForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
GetButton: TBitBtn;
CloseButton: TBitBtn;
Bevel1: TBevel;
Label5: TLabel;
......
输入验证码 一个文本框 24字母随机出4个字母 然后用户
输入所随机出的字母 输入正确 进入界面。。错误又随机下。。。
*/
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
lbl1: TLabel;
Edit1: TEdit; ......
program Project1;
{$APPTYPE CONSOLE}
uses
windows, Tlhelp32, SysUtils;
//===========================获得系统目录=======================================
function GetWinDir: string;
var
Buf: array[0..MAX_PATH] of char;
begin
GetSystemDirector ......