Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
Delphi 7 Enterprise
|
Re: Excel PivotTableWizard
29. Jun 2005, 02:11
Moin,
versuch doch mal folgendes...
Delphi-Quellcode:
uses OleServer, Excel2000;
procedure TFMain.ButtonClick(Sender: TObject);
var Excel:TExcelApplication;
lcid, Zeile:integer;
Workbook:_Workbook;
Sheet:Variant;
Zeiger:Variant;
Spalte:char;
begin
Excel:=TExcelApplication.Create(Self);
try
lcid:=GetUserDefaultLCID;
Excel.Connect;
Excel.Visible[lcid] := true;
Excel.UserControl:=true;
Workbook:=Excel.Workbooks.Add(EmptyParam, lcid);
Sheet:=Workbook.ActiveSheet;
Zeiger:=IDispatch(Excel.Cells.Range['A1', 'A1']);
Zeiger.Value:='Spalte1';
Zeiger:=IDispatch(Excel.Cells.Range['B1', 'B1']);
Zeiger.Value:='Spalte2';
Zeiger:=IDispatch(Excel.Cells.Range['C1', 'C1']);
Zeiger.Value:='Spalte3';
for Zeile:=2 to 10 do
for Spalte:='A' to 'C' do begin
Zeiger:=IDispatch(Excel.Cells.Range[Spalte+inttostr(Zeile), Spalte+inttostr(Zeile)]);
Zeiger.Value:=random(10)+1;
end;
Sheet.PivotTableWizard(xlDatabase, IDispatch(Excel.Cells.Range['A1', 'C10']));
finally
Excel.Disconnect;
Excel.free;
end;
end;
MfG
Thorsten
|
|
Zitat
|