Ver Mensaje Individual
  #2  
Antiguo 15-01-2014
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Reputación: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Creo que existen alternativas...

Mira estas opciones con FastReport.

Opcion 1:
Interceptar envento GETVALUE y reemplazar contenido de campo TfrxRichView de nombre RTFFILE

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
     frxReport1.ShowReport;
end;

procedure TForm1.frxReport1GetValue(VarName: String; var Value: Variant);
var
  sl: TStringList;
begin
    
     if CompareText(VarName, 'RTFFILE') = 0 then
     begin
          sl := TStringList.Create;
          sl.LoadFromFile('d:\Demo.rtf');
          {Aquí tendrías que buscar y reemplazar los marcadores de campos de tus tablas...}
          Value := sl.Text;
          sl.Free;
     end;
end;


Opcion 2:
Cargar rtf en campo TfrxRichView y realizar el reemplazo en el contenido de acuerdo a función adjunta...

Código Delphi [-]
{Refrencia
http://www.fast-report.com/en/forum/...php/t3415.html
}
procedure TForm1.Button1Click(Sender: TObject);
var
   RichView:TfrxRichView;
begin
     RichView := TfrxRichView( frxReport1.FindObject( 'Rich1' ) );
     If RichView <> Nil Then Begin
        RichView.RichEdit.Lines.LoadFromFile( 'D:\Demo.rtf' );
        SearchAndReplace( RichView.RichEdit,'[NAME]','CHRISTIAN');
        SearchAndReplace( RichView.RichEdit,'[DIRECCION]','2 NORTE');
        SearchAndReplace( RichView.RichEdit,'[CIUDAD]','CONCEPCION');
     End;
     frxReport1.ShowReport;
end;

procedure TForm1.SearchAndReplace( Rich: TrxRichEdit; InSearch,InReplace: String );
var
   X,ToEnd: Integer;
begin
     X := 0;
     ToEnd := Length( Rich.Text );
     X := Rich.FindText( inSearch,X,ToEnd,[] );

     While X <> -1 Do
     Begin
          Rich.SelStart := X;
          Rich.SelLength := Length( inSearch );
          Rich.SelText := inReplace;
          X := Rich.FindText( inSearch,X + Length( inReplace ),ToEnd,[] );
     End;
end;

Saludos cordiales...
Responder Con Cita