function GetTD(S: string): string;
begin
if S = '' then S := ' ';
Result := '<td>' + S + '</td>';
end;
function GetTR(S: string): string;
begin
Result := '<tr>' + S + '</tr>';
end;
function GetTDNOWRAP(S: string): string;
begin
if S = '' then S := ' ';
Result := '<td nowrap>' + S + '</td>';
end;
function FormatHTMLData(const Obj: TDataSet): string;
var
SL:TStringList;
HTMLLine:string;
j:Integer;
begin
SL:=TStringList.Create;
try
SL.Add('<table border="1" cellspacing="1" bordercolor="#71C1E2" style="border-collapse: collapse">');
HTMLLine := '';
for j := 0 to Obj.FieldCount - 1 do
begin
HTMLLine := HTMLLine + GetTDNOWRAP(Obj.Fields[j].DisplayName);
end;
HTMLLine := GetTR(HTMLLine);
SL.Add(HTMLLine);
Obj.First;
while not Obj.eof do
begin
HTMLLine := '';
for j := 0 to Obj.FieldCount - 1 do
begin
HTMLLine := HTMLLine + GetTDNOWRAP(Obj.Fields[j].AsString);
end;
HTMLLine := GetTR(HTMLLine);
SL.Add(HTMLLine);
Obj.NEXT;
end;
SL.Add('</table>');
Result:=SL.Text;
finally
if Assigned(SL) then FreeAndNil(SL);
end;
end;