HTML template for making reports
<HTML>
<meta http-equiv= "Content-type" content= "text/html charset=gb2312"/>
> Report template </TITLE>
<BODY>
<table border= "1" cellpadding= "0" cellspacing= "0" >
<tr >
<TH> Company name </TH>
<TH> contacts </TH> <TH>
product name </TH>
<TH> Product name </TH>
</TR>
<TR>
<td>exotic liquids</td>
<TD> Charlotte cooper</td>
<TD>Chai</TD>
<TD>18.0000</TD>
</TR>
<TR>
<td>exotic liquids</td>
<td>charlotte cooper</td>
<td >Chang</TD>
<TD>19.0000</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Browser Open Effect Diagram
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Delphi/
Get data from a report through a stored procedure, and then generate the report template HTML above
function tform1.datatohtml (cds:tclientdataset): Boolean;
var l:tstringlist;
I:integer;
Begin Result: = False; if (CDs = nil) or (not CDs). Active) or (CDS).
IsEmpty) then Exit;
L: = tstringlist.create;
Try try//HTML header L.add (' <HTML> ');
L.add (' <meta http-equiv= "Content-type" content= "text/html; charset=gb2312"/> ");
L.add (' <TITLE> report template </TITLE> ');
L.add (' <BODY> ');
L.add (' <table border= "1" cellpadding= "0" cellspacing= "0" > ");
Table Head l.add (' <TR> ');
L.add (' <TH> store number </TH> ');
L.add (' <TH> store name </TH> ');
L.add (' <TH> system version </TH> ');
L.add (' <TH> protocol version </TH> ');
L.add (' <TH> departure time </TH> ');
L.add (' </TR> '); Data CDs.
A; While not CDs.
Eof do begin L.add (' <TR> '); For I: = 0 to CDs. FieldCount-1 do begin L.add (' <TD> ' + CDs. Fields[i].
Text + ' </TD> ');
End
L.add (' </TR> '); Cds.
Next;
End
HTML tail l.add (' </TABLE> ');
L.add (' </BODY> ');
L.add (' </HTML> '); Save As HTML file L.savetOfile (Extractfilepath (application.exename) + ' 1.html ');
Result: = True;
Except result: = False;
End
Finally L.free;
End End
Author:cnblogs Yong South Delphi