HTML template for making reports
<HTML>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<TITLE> report Templates </TITLE>
<BODY>
<table border= "1" cellpadding= "0" cellspacing= "0" >
<TR>
<TH> Company Name </TH>
<TH> Contact Person </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
Get the report's data 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 header
L.add (' <TR> ');
L.add (' <TH> store number </TH> ');
L.add (' <TH> store name </TH> ');
L.add (' <TH> system version </TH> ');
L.add (' <TH> agreement version </TH> ');
L.add (' <TH> leave Time </TH> ');
L.add (' </TR> ');
Data
Cds. First;
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 footer
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