Gravar dados do quickreport em formato html

Delphi

04/09/2003

Usuários do fórum:
Estou utilizando esta rotina:
[b:5a5f5cc3a8]QuickReport.ExportToFilter(TQRHTMLDocumentFilter.Create(´c:\teste.html´)); //Exportando para HTML

Ou seja, estou mandando os dados do quickreport para um arquivo no formato html, mas quando eu abro o arquivo html, a formatação que estava no quickreport fica perdida, os dados ficam ´jogados´ no arquivo,
porquê :?:

Alguém poderia me ajudar.
[/b:5a5f5cc3a8]


Ponce :)

Ponce :)

Curtidas 0

Respostas

Mmtoor

Mmtoor

04/09/2003

Prezado colega.
Ainda não vi esta função funcionar, apesar do pessoal adorar enviar esta resposta. Ela separa a página em blocos. fica horrível.
Eu, particularmente, formato uma página html e export o resultado de uma query, isso para qualquer que seja o tipo de BD utilizado.
As páginas ganham um padrão e apresentam os dados que eu determino na pesquisa.
As páginas que uso são htm e php. funciona para ambas. Com Paradox também.
Espero ter ajudado.
MMTOOR2003


GOSTEI 0
Mmtoor

Mmtoor

04/09/2003

Prezado colega.
Me desculpe. mostrei o milagre e não disse o nome do santo.
É o seguinte:

Primeiro gera-se código e depois exporta-se para html.

unit Tab2Html;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, StdCtrls, DB, DBTables, DBGrids, Grids, Buttons;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
Label2: TLabel;
MainMenu1: TMainMenu;
Ficheiro: TMenuItem;
Abrir: TMenuItem;
Sair: TMenuItem;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
ListBox2: TListBox;
Label4: TLabel;
DataSource1: TDataSource;
Table1: TTable;
DBGrid1: TDBGrid;
Memo1: TMemo;
BitBtn2: TBitBtn;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
Label5: TLabel;
procedure SairClick(Sender: TObject);
procedure AbrirClick(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure ListBox2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetDriver(const alias: String): String;
procedure GetParams(const alias: String; the_params: TStrings);
function GetPath(const alias: String): String;
procedure ColocaObjectosInvisiveis;
procedure ColocaObjectosVisiveis;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.SairClick(Sender: TObject);
begin
Close;
end;

procedure TForm1.AbrirClick(Sender: TObject);
begin
Session.GetAliasNames(ListBox1.Items);
if ListBox1.Items.Count > 0 then
begin
ListBox1.ItemIndex := 0;
ListBox1Click(nil);
end;
Abrir.Checked := not Abrir.Checked;
if Abrir.Checked then
ColocaObjectosVisiveis
else
ColocaObjectosInVisiveis;
end;


// Get the driver name for an alias.
function TForm1.GetDriver(const alias: String): String;
begin
try
result := Session.GetAliasDriverName(alias);
finally
end;
end;


// Get the parameters for an alias.
procedure TForm1.GetParams(const alias: String; the_params: TStrings);
begin
try
Session.GetAliasParams(alias, the_params);
finally
end;
end;


// Get the path for an alias.
function TForm1.GetPath(const alias: String): String;
var
the_params: TStringList;
begin
the_params := TStringList.Create;
try
GetParams(alias,the_params);
result := the_params.Values[´PATH´];
finally
the_params.Free;
end;
end;


procedure TForm1.ColocaObjectosInvisiveis;
begin
Label1.Visible := false;
Label2.Visible := false;
Label3.Visible := false;
Label4.Visible := false;
Label5.Visible := false;
ListBox1.Visible := false;
ListBox2.Visible := false;
Edit1.Visible := false;
Edit2.Visible := false;
DBGrid1.Visible := false;
SpeedButton2.Visible := false;
SpeedButton1.Visible := false;
Memo1.Visible := false;
end;


procedure TForm1.ColocaObjectosVisiveis;
begin
Label1.Visible := true;
Label2.Visible := true;
Label3.Visible := true;
Label4.Visible := true;
Label5.Visible := true;
ListBox1.Visible := true;
ListBox2.Visible := true;
Edit1.Visible := true;
Edit2.Visible := true;
DBGrid1.Visible := true;
SpeedButton2.Visible := true;
SpeedButton1.Visible := true;
end;



procedure TForm1.ListBox1Click(Sender: TObject);
begin
if ListBox1.ItemIndex <> -1 then
begin
Edit1.Text := GetDriver(ListBox1.Items[ListBox1.ItemIndex]);
Edit2.Text := GetPath(ListBox1.Items[ListBox1.ItemIndex]);
Session.GetTableNames(ListBox1.Items[ListBox1.ItemIndex],´*.db´,False, False, ListBox2.Items);
if ListBox2.Items.Count > 0 then
begin
ListBox2.ItemIndex := 0;
ListBox2Click(nil);
end;
end;
end;

procedure TForm1.ListBox2Click(Sender: TObject);
var extfich: string;
begin
Memo1.Visible := false;
SpeedButton1.Enabled := false;
if ListBox2.Items.Count > 0 then
begin
with Table1 do
begin
Close;
DatabaseName := ListBox1.Items[ListBox1.ItemIndex];
TableName := ListBox2.Items[ListBox2.ItemIndex];
extfich := ExtractFileExt(ListBox2.Items[ListBox2.ItemIndex]);
if extfich = ´.DB´ then
TableType := ttParadox
else if extfich = ´.DBF´ then
TableType := ttDBase
else if extfich = ´.DB´ then
TableType := ttASCII
else
TableType := ttDefault;
DataSource1.DataSet := Table1;
DBGrid1.DataSource := DataSource1;
try
begin
Open;
SpeedButton2.Enabled := true;
Memo1.clear();
end
except
on EDataBaseError do
end;
end;
end;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
Memo1.Lines.SaveToFile(Edit2.Text+´\´+ExtractFileName(Table1.TableName)+´.html´);
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
var i, j: integer;
begin
Memo1.Visible := false;
Memo1.Clear();
SpeedButton1.Enabled := false;
Application.ProcessMessages();
Screen.Cursor := crHourGlass;
Memo1.Lines.Add(´<!DOCTYPE HTML Public ´-ETF//DTD HTML//EN´>´);
Memo1.Lines.Add(´ <HTML>´);
Memo1.Lines.Add(´ <HEAD>´);
Memo1.Lines.Add(´ <TITLE>´ + ExtractFileName(Table1.TableName)+ ´.html</TITLE>´);
Memo1.Lines.Add(´ <style type=´text/css´>´);
Memo1.Lines.Add(´ <!--´);
Memo1.Lines.Add(´ th { background-color: #FFCCFF }´);
Memo1.Lines.Add(´ td { background-color: 99CCCC }´);
Memo1.Lines.Add(´ td { background-color: #99CCCC }´);
Memo1.Lines.Add(´ -->´);
Memo1.Lines.Add(´ </style>´);
Memo1.Lines.Add(´ </HEAD>´);
Memo1.Lines.Add(´ <BODY>´);
Memo1.Lines.Add(´ <h2>´ + ExtractFileName(Table1.TableName)+ ´</h2>´);
Memo1.Lines.Add(´´);
Memo1.Lines.Add(´ <table border=1>´);
Memo1.Lines.Add(´ <tr>´);
Memo1.Lines.Add(´ <th>   </th>´);
for i := 0 to Table1.FieldCount - 1 do
Memo1.Lines.Add(´ <th> ´ + Table1.Fields[i].FieldName + ´ </th>´);
Memo1.Lines.Add(´ </tr>´);
while not Table1.Eof do
begin
Memo1.Lines.Add(´ <tr>´);
Memo1.Lines.Add(´ <th> ´ + IntToStr(Table1.RecNo) + ´ </th>´);
for j := 0 to Table1.FieldCount - 1 do
begin
if not Table1.Fields[j].IsNull then
Memo1.Lines.Add(´ <th> ´ + Table1.Fields[j].AsString + ´ </th>´)
else
Memo1.Lines.Add(´ <th>   </th>´);
end;
Memo1.Lines.Add(´ </tr>´);
Table1.Next;
end;
Table1.First;
Memo1.Lines.Add(´ </table>´);
Memo1.Lines.Add(´´);
Memo1.Lines.Add(´´);
Memo1.Lines.Add(´ <h3> E-Mail da Tecnirolo: <h3>´);
Memo1.Lines.Add(´<a href=´mailto:quedas@esoterica.pt´> tecnirolo@mail.telepac.pt </a>´);
Memo1.Lines.Add(´ </BODY>´);
Memo1.Lines.Add(´ </HTML>´);
Screen.Cursor := crDefault;
Memo1.Visible := true;
SpeedButton1.Enabled := true;
end;


Espero ter ajudado.
MMTOOR2003


GOSTEI 0
Ponce :)

Ponce :)

04/09/2003

Caro mmtoor,

Vou fazer o teste se acaso não funcionar peço sua juda, mas desde já agradeço sua colaboração.

Ponce[b:ddcc46a5d4][/b:ddcc46a5d4]


GOSTEI 0
POSTAR