Title: save a TListView as an HTML page?
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,''+listview.columns[i].caption+'') else
WriteLn(tfile,''+listview.columns[i].caption+'');
end;
WriteLn(tfile,'');
WriteLn(tfile,'');
for i := 0 to listview.Items.Count-1 do
begin
WriteLn(tfile,''+listview.items.item[i].caption+'');
for f := 0 to listview.Columns.Count-2 do
begin
if listview.items.item[i].subitems[f]='' then Write(tfile,'-') else
Write(tfile,''+listview.items.item[i].subitems[f]+'');
end;
Write(tfile,'');
end;
WriteLn(tfile,'');
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;