procedure TForm1.btnTestClick(Sender: TObject);
var
Excel: TExcelFile;
begin
Excel := TExcelFile.Create;
try
with Excel
do begin
Visible := False;
DisplayAlerts := False;
if Open
then begin
if SelectWorkSheet(1)
then begin
WorkSheet.
Name := '
Erstes Blatt';
WorkSheet.Columns.Columns[1].ColumnWidth := 150;
WorkSheet.Cells[1, 1] := 123.456;
WorkSheet.Cells[1, 1].NumberFormat := '
0,00';
WorkSheet.Cells[2, 1] := 456;
WorkSheet.Cells[3, 1] := 123;
WorkSheet.Cells[1, 3] := '
Erstes Blatt';
WorkSheet.Cells[1, 1].Interior.Color := clRed;
WorkSheet.Cells[2, 1].Interior.Color := clLime;
WorkSheet.Cells[3, 1].Interior.Color := clYellow;
WorkSheet.Cells[1, 1].Font.
Name := '
Arial';
WorkSheet.Cells[1, 1].Font.Size := 20;
WorkSheet.Cells[1, 1].Font.Bold := True;
WorkSheet.Cells[1, 1].Font.Color := clYellow;
WorkSheet.Range['
A6', '
A6'].Formula := '
=Sum(A1:A3)';
if AddWorkSheet > -1
then begin;
if SelectWorkSheet(2)
then begin
Worksheet.
Name := '
Zweites Blatt';
WorkSheet.Cells[1, 5] := 0.815;
WorkSheet.Cells[1, 5].NumberFormat := '
0,00';
WorkSheet.Cells[1, 5].Font.
Name := '
Aial';
WorkSheet.Cells[1, 5].Font.Size := 6;
WorkSheet.Cells[1, 5].Font.Bold := True;
WorkSheet.Cells[1, 5].Font.Color := clRed;
WorkSheet.Cells[2, 5] := 311264;
WorkSheet.Cells[3, 5] := 270664;
WorkSheet.Cells[1, 3] := '
Zweites Blatt';
WorkSheet.Cells[1, 1].Interior.Color := clMaroon;
WorkSheet.Cells[2, 1].Interior.Color := clGray;
WorkSheet.Cells[3, 1].Interior.Color := clWhite;
end;
end;
end;
ExportFile(System.SysUtils.ExtractFilePath(
Vcl.Forms.Application.ExeName) + '
Produktionsberichte.xlsx');
Close;
end;
end;
finally
FreeAndNil(Excel);
end;
end;