VCL Delphi

function ListViewConfHTML(Listview:TListview; output:string; center: Boolean) : Boolean;
var
i,f: Integer;
tfile: TextFile;
begin
try
ForceDirectories(ExtractFilePath(output));
AssignFile(tfile,output);
ReWrite(tfile);
WriteLn(tfile,'');
WriteLn(tfile,'');
WriteLn(tfile,'HTML-Ansicht: '+listview.Name+'');
WriteLn(tfile,'');
WriteLn(tfile,'');
WriteLn(tfile,'');
for i := 0 to listview.Columns.Count - 1 do
begin
if center then
WriteLn(tfile,'') else
WriteLn(tfile,'');
end;
WriteLn(tfile,'');
WriteLn(tfile,'');
for i := 0 to listview.Items.Count-1 do
begin
WriteLn(tfile,'');
for f := 0 to listview.Columns.Count-2 do
begin
if listview.items.item[i].subitems[f]='' then Write(tfile,'') else
Write(tfile,'');
end;
Write(tfile,'');
end;
WriteLn(tfile,'
'+listview.columns[i].caption+'
'+listview.columns[i].caption+'
'+listview.items.item[i].caption+'-'+listview.items.item[i].subitems[f]+'
');
WriteLn(tfile,'');
CloseFile(tfile);
Result := True;
except
Result := False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if ListViewConfHTML(form1.ListView1,'C:\text.html', true) then
ShowMessage('OK/ Hat geklappt') else
ShowMessage('Error occured/ Hat nicht geklappt');
end;