unit uExcelExport;
interface
uses Variants,ExcelXP;
type
TExcelExport =
class(TObject)
private
FLocaleIdentifier: Integer;
{ private-Deklarationen }
protected
{ protected-Deklarationen }
public
{ public-Deklarationen }
FExcel:TExcelApplication;
FExcelWB:_Workbook;
FExcelWS:_Worksheet;
procedure OpenVorlage(Pfad:
string);
procedure ExportToExcel(DateiName:
string);
constructor Create;
published
{ published-Deklarationen }
end;
implementation
uses
Windows, SysUtils;
{ TExcelExport }
constructor TExcelExport.Create;
begin
FExcel := TExcelApplication.Create(
nil);
// FExcelWB := TExcelWorkbook.Create( nil );
// FExcelWS := TExcelWorksheet.Create( nil );
// Get current user locale ID
FLocaleIdentifier := GetUserDefaultLCID();
end;
procedure TExcelExport.ExportToExcel(DateiName:
string);
var
I: Integer;
begin
FExcelWB:=FExcel.Workbooks.Item[1];
FExcelWS:=FExcelWB.Worksheets.Get_Item(1)
as _Worksheet;
for I := 1
to 1000 - 1
do
FExcelWS.Cells.Item[i+2,1]:='
Test '+IntToStr(i) ;
FExcelWB.SaveCopyAs(DateiName,FLocaleIdentifier);
end;
procedure TExcelExport.OpenVorlage(Pfad:
string);
begin
FExcel.Connect;
FExcel.Workbooks.Open('
template.xls', False, False, EmptyParam, '
', False, False, EmptyParam, EmptyParam, false, false, EmptyParam, EmptyParam, EmptyParam, false, 0);
FExcel.Visible[FLocaleIdentifier]:=True;
end;
end.