数据连结用的是ADO
数据库用的是access我查了一下午的资料也没有找到,
请问应该用什么控件,能不能给我的范例?谢谢!
解决方案 »
- 续刚刚问题,程序在最前方了,但是。。。
- 求DELPHI下跨物理区域的解决方案。
- Stream对象,又称流式对象,是TStream、THandleStream、TFileStream、TMemoryStream、TResourceStream
- ActiveForm多次访问后出现的DAX Error错误:?
- 男人\女人看过来
- 关于socket的问题!!!
- 请问TClass =class of TObject 这种语法是什么意思,它的用处在哪儿?
- 不行了,请教各位,关于tp在图形方面的应用。
- 奇怪的数据库字段问题
- 大家好啊,我是delphi初学者(我的qq:1138483.如果您是delphi的初学者,爱好者,加我哦)
- 谁知道DELPHI共有多少种数据库创建方法?
- DELPHI写的远程控制源代码,要吗?
你也可以让你的程序生成HTML让浏览器打开
{*************************************************************}
{ KDatabase Export pack version 1.01 }
{ Copyright ?2000 Korzh company }
{ http://www.korzh.com/delphi/ }
{ mailto:[email protected] }unit DsExport;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DB;type
TKHTMLFormatCellEvent = procedure(Sender: TObject; CellRow, CellColumn: Integer; FieldName: string;
var CustomAttrs, CellData: string) of object; TDataSetToHTML = class(TComponent)
private
FDataSet: TDataSet;
FHeader: TStrings;
FFooter: TStrings;
FOnFormatCell: TKHTMLFormatCellEvent;
procedure SetHeader(Value: TStrings);
procedure SetFooter(Value: TStrings);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Transfer(const FileName: string);
published
property DataSet: TDataSet read FDataSet write FDataSet;
property Header: TStrings read FHeader write SetHeader;
property Footer: TStrings read FFooter write SetFooter;
property OnFormatCell: TKHTMLFormatCellEvent read FOnFormatCell write FOnFormatCell;
end;implementationconstructor TDataSetToHTML.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataSet := nil;
FHeader := TStringList.Create;
FFooter := TStringList.Create;
FOnFormatCell := nil;
end;destructor TDataSetToHTML.Destroy;
begin
FFooter.Free;
FHeader.Free;
inherited;
end;procedure TDataSetToHTML.SetHeader(Value: TStrings);
begin
FHeader.Assign(Value);
end;procedure TDataSetToHTML.SetFooter(Value: TStrings);
begin
FFooter.Assign(Value);
end;procedure TDataSetToHTML.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FDataSet) then
FDataSet := nil;
end;procedure TDataSetToHTML.Transfer(const FileName: string);
var
HTML: TStrings;
i, RowNum, ColNum: integer;
CustomAttrs: string;
S: string;
begin
HTML := TStringList.Create;
try
if FHeader.Count > 0 then
HTML.Assign(FHeader)
else
begin
HTML.Add('<html>');
HTML.Add('<head> <title> DataSet </title> </head>');
HTML.Add('<body>');
end;
HTML.Add('<table border = "1" rows = "' + IntToStr(FDataSet.RecordCount) +
'" bordercolor="#000000" cellspacing="0" cellpadding="2">');
with FDataSet do
begin
//filling table header
HTML.Add('<tr>'); ColNum := 1;
for i := 0 to FieldCount - 1 do
begin
if Fields[i].Visible then
begin
CustomAttrs := '';
S := Fields[i].DisplayLabel;
if Assigned(FOnFormatCell) then
FOnFormatCell(Self, 1, ColNum,
Fields[i].FieldName, CustomAttrs, S);
HTML.Add('<th ' + CustomAttrs + ' >' + S + ' </th>');
inc(ColNum)
end;
end;
HTML.Add('</tr>'); First; RowNum := 2;
while not EOF do
begin
HTML.Add('<tr>'); ColNum := 1;
for i := 0 to FieldCount - 1 do
begin
if Fields[i].Visible then
begin
CustomAttrs := '';
{
if Fields[i].DataType = ftCurrency then
begin
S := FloatToStrF(Fields[i].AsCurrency, ffCurrency, 20, 2)
end
else if Fields[i].DataType = ftFloat then
begin
S := FloatToStrF(Fields[i].AsFloat, ffGeneral, 4, 1);
end
else
S := Fields[i].AsString;
}
S := Fields[i].Text;
if S = '' then S := ' '; if Assigned(FOnFormatCell) then
FOnFormatCell(Self, RowNum, ColNum,
Fields[i].FieldName, CustomAttrs, S);
HTML.Add('<td nowrap ' + CustomAttrs + ' >' + S + ' </td>');
inc(ColNum)
end;
end;
HTML.Add('</tr>');
FDataSet.Next; inc(RowNum);
end;
end;
HTML.Add('</table>');
if FFooter.Count > 0 then
HTML.AddStrings(FFooter)
else
begin
HTML.Add('</body>');
HTML.Add('</html>');
end;
HTML.SaveToFile(FileName);
finally
HTML.Free;
end;
end;end.
myquickrep.exportfilter := tqrasciiexportfilter.create("c:\test.htm");
myquickrep.prepare;
myquickrep.exportfilter.free;