ein TStringGrid in eine HTML Datei umwandeln?
Mit dieser Procedure kann man ein Stringgrid in eine html Datei umwandeln
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54:
| Procedure SGridToHtml(SG:Tstringgrid; Dest:TMemo; BorderSize:integer); var i,p:integer; SStyle1,SStyle2,Text:string; begin Dest.Clear; Dest.lines.add('<html>'); Dest.lines.add('<body>'); Dest.lines.add(' <table border="'+inttostr(BorderSize)+ '"width="'+inttostr(SG.Width)+'" height="'+inttostr(SG.Width)+'">');
for i:=0 to SG.RowCount-1 do begin Dest.lines.add(' <tr>'); for p:=0 to SG.ColCount-1 do begin SStyle1:=''; SStyle2:=''; if fsbold in SG.Font.style then begin SStyle1:=SStyle1+'<b>'; SStyle2:=SStyle2+'</b>'; end; if fsitalic in SG.Font.style then begin SStyle1:=SStyle1+'<i>'; SStyle2:=SStyle2+'</i>'; end; if fsunderline in SG.Font.style then begin SStyle1:=SStyle1+'<u>'; SStyle2:=SStyle2+'</u>'; end; text:=sg.Cells[p,i]; if text='' then text:=' ' ; Dest.lines.add(' <td width="'+inttostr(sg.ColWidths[p])+ '" height="'+inttostr(sg.RowHeights[p])+ '"><font color="#'+inttohex(sg.Font.Color,6)+ '" face="'+SG.Font.Name+'">'+SStyle1+ text+SStyle2+'</font></td>'); end; Dest.lines.add(' </tr>'); end; Dest.lines.add(' </table>'); Dest.lines.add('</body>');; Dest.lines.add('</html>'); end;
procedure TFormCSVInport.Button6Click(Sender: TObject); begin SGridToHtml(StringGrid1,Memo1,1); memo1.Lines.SaveToFile('c:\test.html'); end; |
Viel Spass
Greez Cyrus
Copyright by Cyrus
Moderiert von jasocul: Beitrag geprüft am 22.05.2006
_________________
Wer glaub er ist, hört auf zu werden!
Delphi Rulez!!!