|
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComObj;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
Var
XLApp: OLEVariant;
Sheet1: Variant;
s: WideString;
begin
XLApp := CreateOleObject('Excel.Application'); // requires comobj in uses
XLApp.Visible := true;
XLApp.WorkBooks.Add;
Sheet1 := XLApp.workBooks[1].WorkSheets[1];
s := UTF8Decode('中国');
Sheet1.Cells[8, 8].Value := s;
end;
end.
|
|