unit ExcelMitEditFelderFuellenUnit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,comobj, OleServer, ExcelXP;
type
TForm1 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function EXCELStarten (
var my_EXCEL : Variant): boolean;
{erfordert in uses: comobj}
begin
try
my_EXCEL := CreateOLEObject('
Excel.Application');
Result := TRUE;
except
ShowMessage('
Excel konnte nicht gestartet werden!');
Result := FALSE;
Exit
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var Excel : Variant;
begin
EXCELStarten(Excel);
// muß wg OLE-Object auf jeden Fall (evtl. zusätzlich) gestartet werdem
Excel.Visible := TRUE;
Excel.Application.Workbooks.Add;
// Neue Arbeitsmappe öffnen in EXECL
Excel.Worksheets ['
Tabelle1'].Activate;
Excel.cells[1,1]:= Edit1.Text;
// <------ Text
Excel.cells[1,2]:= strtofloat(Edit2.Text);
// <------- Zahl
Excel.Quit;
end;
end.