📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UExcelAdapter, XLSAdapter, UFlexCelImport, StdCtrls, UFlxFormats;
type
TForm1 = class(TForm)
Button1: TButton;
Fi: TFlexCelImport;
XLSAdapter1: TXLSAdapter;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
h: THeapStatus;
lam: int64;
fam: int64;
f:TFlxFormat;
fmt: integer;
begin
Memo1.Lines.Clear;
lam:=0;fam:=-1;
for i:=0 to 5000 do
begin
Fi.OpenFile(extractfilepath(application.ExeName)+'\Test.xls');
Fi.CellValue[1,1]:='Hi from flexcel';
Fi.CellFormula[2,1]:='=1+2';
f:=Fi.DefaultFormat;
f.Font.Name:='Arial';
f.Font.ColorIndex:=Fi.NearestColorIndex(clred);
f.FillPattern.FgColorIndex:=Fi.NearestColorIndex(clBlue);
f.FillPattern.Pattern:= 2;
fmt:=Fi.AddFormat(f);
Fi.CellFormat[1,1]:=fmt;
DeleteFile(extractfilepath(application.ExeName)+'\Test2.xls');
Fi.Save(extractfilepath(application.ExeName)+'\Test2.xls');
if i mod 50 = 0 then
begin
h:=GetHeapStatus;
if fam=-1 then fam:=h.TotalAllocated;
Memo1.Lines.Add('Pass: '+IntToStr(i)+' ----- Mem used: '+IntToStr(h.TotalAllocated)+' --- Free: '+inttostr(h.TotalFree)+ ' ----- Difference: '+IntToStr(h.TotalAllocated-lam)+ ' ----- Total Diff: '+IntToStr(h.TotalAllocated-fam));
lam:=h.TotalAllocated;
Application.ProcessMessages;
end;
end;
ShowMessage('Finished');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -