{zuerst werden die txt-Dateien erstelllt}
...
{Verbindung mit Excel herstellen über ConnectXL() }
{wenn erfolgreich: erstelle erst die Datei in mactext-Format}
FileFormat := xlTextMac;
ExcelApp.Workbooks.OpenText(TempFileName1, xlWindows, EmptyParam, xlDelimited,
xlDoubleQuote, EmptyParam, true, false, false,
false, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, FLCID);
ExcelSheet.ConnectTo(ExcelApp.Worksheets.Item[1]
as _Worksheet);
DeleteFileIfExists(FileNameAccurate);
ExcelSheet.SaveAs(FileNameAccurate, FileFormat);
ExcelApp.Workbooks.Item[1].Saved[FLCID] := true;
ExcelApp.Workbooks.Close(FLCID);
ExcelSheet.Disconnect;
{erstelle nun die normale Excel-Datei}
FileFormat := xlNormal;
ExcelApp.Workbooks.OpenText(TempFileName2, xlWindows, EmptyParam, xlDelimited,
xlDoubleQuote, EmptyParam, true, false, false,
false, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, FLCID);
ExcelSheet.ConnectTo(ExcelApp.Worksheets.Item[1]
as _Worksheet);
Count := InttoStr(ExceptionList.Count);
with ExcelSheet.Range['
A1' , '
B' + Count]
do
begin
Font.Bold := false;
VerticalAlignment := xlTop;
HorizontalAlignment := xlLeft;
WrapText := true;
end;
with ExcelSheet.Range['
A1' , '
A' + Count]
do
begin
Font.Size := 8;
ColumnWidth := 11;
end;
with ExcelSheet.Range['
B1' , '
B' + Count]
do
begin
Font.Size := 14;
ColumnWidth := 72;
end;
with ExcelSheet.PageSetup
do
begin
CenterHeader := '
&8&N';
CenterFooter := '
&8Seite &8&P &8von &8&A';
PrintGridlines := true;
end;
ExcelSheet.SaveAs(FileNameException, FileFormat);
//[b]FEHLER: OLE-Fehler 800A03EC[/b]
//ExcelSheet.SaveAs(FileNameException, FileFormat, '', '', EmptyParam, EmptyParam, EmptyParam); // [b]Auch nicht besser![/b]
ExcelApp.Workbooks.Item[1].Saved[FLCID] := true;
ExcelApp.Workbooks.Close(FLCID);
ExcelSheet.Disconnect
{Excel-Verbindung beenden}
...
function ConnectXL() : boolean;
begin
ConnectXL := true;
try
with ExcelApp
do
begin
ExcelApp.Visible[FLCID] := false;
// FLCID := LOCALE_USER_DEFAULT;
ExcelApp.UserControl := false;
ExcelApp.Connect;
end;
except
MessageDlg('
Verbindung zu Excel konnte nicht hergestellt werden.', mtError, [mbOK], 0);
ConnectXL := false;
end