interface
uses
System.Win.ComObj,
Vcl.Buttons,
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms,
Vcl.Dialogs, Excel2010, Vcl.OleServer,
Vcl.ComCtrls, Vcl.StdCtrls,
Vcl.DBCtrls, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
SpeedButton1: TSpeedButton;
DBRadioGroup1: TDBRadioGroup;
DBListBox1: TDBListBox;
Edit1: TEdit;
GetRange: TButton;
Label1: TLabel;
procedure SpeedButton1Click(Sender: TObject);
procedure GetRangeClick(Sender: TObject);
private
{ Private declarations }
FExcelApp: TExcelApplication; // Uses Excel2010
public
{ Public declarations }
//FExcelApp: ExcelApplication; // TExcelApplication; khai báo sử dụng ExcelApp
end;
{ var
Form1: TForm1; code Delphi tao ra }
{ Khai bao cac bien su dung Cho Form }
procedure ShowForm;
var
Form1: TForm1;
f: TForm1; // Su dung Form
implementation
{$R *.dfm}
procedure ShowForm;
begin
f := TForm1.Create(nil);
try
// f.Show; //.ShowModal;
f.ShowModal;
finally
f.free
end;
end;
procedure TForm1.GetRangeClick(Sender: TObject);
var
sh: _WorksheetDisp;
begin
if Assigned(FExcelApp) then
begin
sh := _WorksheetDisp(FExcelApp.ActiveSheet);
sh.Cells._Default[1, 1].Value := 'Kiều Mạnh';
ShowMessage(sh.name);
end;
end;