LazReport Documentation/es

From Free Pascal wiki
Revision as of 21:33, 12 November 2010 by Jesusrmx (talk | contribs) (→‎AUTORES)
Jump to navigationJump to search

Deutsch (de) English (en) español (es) polski (pl)

PRESENTACIÓN

LazReport es un grupo de componentes que agregan la capacidad ed generar reportes a las aplicaciones, usa un diseñador visual para crear reportes basados en bandas e incluye un mecanismo de reportes con previsualizador que ademas incluye un interprete para ejecutar guiones de usuario. El diseñador de reportes puede ser invocado en tiempo de ejecución

LINCENCIA

LazReport se origina en FreeReport 2.32 y gracias a la compañía Fast Reports Inc. esta disponible bajo la licencia LGPL modificada, la mista licencia que usa la libreria LCL de Lazarus. Para mayor información, vea los archivos lazreport/ license.txt, license-rus.txt y licence-lazreport.txt

AUTORES

FreeReport fué creado por la compañía Fast Reports Inc. La adaptación inicial del código a LazReport fue hecha por Olivier Guilbaud, para mayor infomación visite el sitio original de LazReport en SourceForge http://lazreport.sourceforge.net/. La integración en Lazarus y actual encargado del proyecto es Jesús Reyes Aguilar. LazReport no podría haber llegado a su estado actual sin la colaboración de muchos otros desarrolladores, vea el archivo lazreport/doc/contributors.txt

INSTALACIÓN

To install LazReport under lazarus IDE:

  1. Open LazReport Package. Menu: Components->Open package file (.lpk)...
  2. Open file components/lazreport/source/lazreport.lpk
  3. Install

Next time lazarus is started, it should show a LazReport tab in component palette.

DOCUMENTACIÓN

El Manual del Desarrollador y La Guia del Usuario específicas para LazReport están aún por escribirse, mientras tanto, la mayoría de las funciones de LazReport están descritas en el Manual del Desarrollador de FreeReport (vea lazreport/doc/fr_eng.sxw), Algunas cosas dependientes de la plataforma descritas allí, como objetos OLE, no están implementados en LazReport. También algunos ejemplos o imágenes hacen referencia a ejemplos que están disponibles solamente en Delphi.

Hasta que la documentación especifica para LazReport sea elaborada, ésta página wiki será usada como repositorio de documentación, quizás en el futuro la documentación faltante pueda ser generada desde aquí. Se alienta a los usuarios a que agreguen temas que sientan haya necesidad de documentar, incluso si la descripción o contenido de dichos temas deba ser proporcionado por otros usuarios.

Export Filters

LazReport export filters are invoked using the following code. <Delphi>

 if TheReport.PrepareReport then
   TheReport.ExportTo(TfrHTMExportFilter, 'exportedfile.html');

</Delphi> Where TheReport holds an instance of TfrReport component. In this sample a TfrHTMExportFilter is used to generate a file named 'exportedfile.html'. It's not necesary to prepare again the report if it has been prepared previously. In order to use TfrHTMExportFilter the developer has to drag and drop an instance of TfrHTMExportFilter component from the LazReport tab in componente palette to form in Form Desginer. As an alternative the unit lr_e_htm.pas file needs to be added to unit uses clause.

Since LazReport 0.9.6, the export filters support has been enhanced, now export filters can take parameters which users can customize either by changing values directly or by presenting the end user some UI. In order to make changes in parameters, the developer can create an event handler for TfrReport.OnExportFilterSetup event, available by selecting the TfrReport component and selecting the Events tab in Object Inspector.

The OnExportFilterSetup (of type TExportFilterSetup) event handler takes an argument sender of type TfrExportFilter, in order to use this types, lr_class.pas unit must be added to unit uses clause. All ExportFilter clases share this event and developer has to type-cast the sender argument to the desired export filter class for example: <Delphi> if sender is TfrHTMExportFilter then begin

 TfrHTMExportFilter(sender).UseCSS := false;

end; </Delphi> below a description of available export filters.

TfrExportFilter

is the base class of all export filters, and defines two properties that can be modified by developer in the OnExportFilterSetup event:

  • BandTypes: TfrBandTypes. this is a set of band types, only bands included in this set are actually exported, the rest of bands present on report will be ignored. Using this property a developer could for example export only the master band content, leaving titles, headers and footers out of exported output by doing:

<Delphi> sender.BandTypes := [btMasterData]; </Delphi> by default, all bands are processed but TfrCSVExportFilter changes this property to process only master header, column header and master data bands.

  • UseProgressbar: boolean. This property enable or disable showing the progress bar while processing the export filter. This property is false by default.

TfrTextExportFilter

inheritance: TfrExportFilter <- TfrTextExportFilter
located in: lr_e_txt.pas file included with LazReport package.

is the base class of text based export filters. This export filter tries to make a text representation of a graphical report by fitting the original graphical coordinates into a more coarse grid where each unit is of "UsedFont" pixels, depending on the value of UsedFont value, the exported output may more or less represent the layout of objects in graphical report. Beside the properties inherited from TfrExportFilter class, TfrTextExportFilter define two more properties.

  • UsedFont:integer. this property define the pixel dimensions on the output grid, objects on report are fitted into this grid by reclaculating each x and y position. The default value is 10, if user changes this value to 0 o less, LazReport will show automatically a dialog asking for the UsedFont value, if user enter a invalid value, a 10 value will be used. The 10 value is used because is the value that better fits the usual reports which are made with fonts 10-13 points.
  • UseBOM:boolean. This property enable the inclusion of UTF-8 Byte Order Mark character at the start of text output (see BOM) needed by some editors/viewers, by default no BOM is used in exported output.

TfrCSVExportFilter

inheritance: TfrExportFilter <- TfrTextExportFilter <- TfrCSVExportFilter
located in: lr_e_csv.pas file included in LazReport package.

This special text export filter produces Comma Separated Value output (actually any character can be used as separator), it differs from it's ancestor in that it doesn't try to create text layout representation of graphical report, instead, for each record output it tries to guess the fields order from the source report, it then produce a list of fields using a separator defined by the user. Beside the properties inherited from its ancestor classes it defines some properties to customize the generated output.

  • QuoteType:TfrQuoteType. This property controls whether the generated field value should be wrapped using specified quote char or not. Possible values are qtNone, qtQuoteChar and qtAutoQuote. With qtNone the field value is never wrapped, qtQuoteChar will use the character specified by property QuoteChar, any instance of QuoteChar already present in field value is duplicated. qtAutoQuote first try to find if any instance of separator or QuoteChar is already present in field value, if affirmative it behaves as if qtQuoteChar has been specified, on the contrary case, the field value is not wrapped just as if qtNone has been specified. QuoteType property is set to qtQuoteChar by default.
  • QuoteChar:TUTF8Char. This holds the character to be used to wrap the field value in case of QuoteType of value qtQuoteChar has been specified or deduced if qtAutoQuote is set. Any instance of this character in the field value will be duplicated. by default QuoteChar is set to the " character.
  • Separator:TUTF8Char. This is the character used to separate the fields in each record, by default is set to the ',' (COMMA) character but any UTF-8 valid character could be used. Some CSV files are actually TAB separated files, to get this, set Separator:=#9;

The CSV exporter do not use the inherited UsedFont property value so any value set will be ignored. With default property values, TfrCSVExportFilter will produce Excel compatible files, the only caveat is that Excel will not recognize the file as UTF-8 encoded. To force Excel to recognize the encoding automatically, set the property UseBOM to true.

TfrHTMExportFilter

inheritance: TfrExportFilter <- TfrTextExportFilter <- TfrHTMExportFilter.
Located in: lr_e_htm.pas in LazReport package.

This special text export filter produces valid "HTML 4.01 Transitional" output. Currently it defines only one additional property.

  • UseCSS:boolean. This property controls whether or not the produced output include CSS information, this property is set to true by default.

INICIO RÁPIDO

Reporte de Registros de un Dataset

En este ejemplo diseñaremos un reporte para imprimir registros desde un componente derivado de TDataset (TDbf, TSQLQuery, TZTable, TZQuery, Etcetera.). Primero se supone que LazReport ya esta instalado y que el componente dataset, llamado "Dbf1" aquí, ya esta configurado y activo.

  1. Del separador LazReport en la paleta de componentes, seleccionamos el componente TfrReport y lo arrojamos en el Diseñador de Formularios, será nombrado automáticamente "frReport1".
  2. Colocar también un componente TfrDbDataset, será nombrado "frDbDataset1"
  3. Colocar un componente TButton, será nombrado "Button1", cambie su nombre a "btnShowReport"
  4. Con el componente frDbDataset1 seleccionado, en el Inspector de Objectos seleccione "Dbf1" en la propiedad "Dataset"
  5. Ahora seleccione frReport1 y usando el mismo procedimiento enlace su propiedad "Dataset" al componente "frDbDataset1":lrformsetup.png
  6. Haga clic con el botón derecho sobre frReport1 y del menú seleccione "Diseñar Reporte". Se mostrará El Diseñador de Reportes de LazReport.
  7. En la ventana del Diseñador de LazReport, seleccione el menu Herramientas->Herramientas->Insertar Campos DB. El diálogo "Insertar Campos" aparecerá.
  8. En la lista de campos seleccione los campos que desee que aparezcan en el reporte
  9. Seleccione las opciones "Incluir Encabezados" y "Incluir Bandas", el resultado debería ser similar a esto:lrinsertfieldsdialog.png
  10. Presione el botón "Aceptar", LazReport colocara bandas y campos en el reporte de una formasimilar a la siguiente:

    lrreportwithfields.png

  11. Presione el boton de Vista Previa lrprevieweye.png, LazReport mostrará entonces una vista previa del reporte:lrpreviewreport.png
  12. Guarde el reporte usando el menú Archivos->Guardar, seleccione el mismo directorio del proyecto actual y guardelo como listing1.lrf
  13. Cierre el Diseñador de Reportes.
  14. Haga doble clic sobre el botón btnShowReport y teclee el siguiente código:<Delphi>
 frReport1.LoadFromFile('listing1.lrf');
 frReport1.ShowReport;</Delphi>

BUG REPORTS

Please report problems using the lazarus/freepascal bugtracker, project: "Lazarus Packages", Category "LazReport", for patches please submit a bug report and attach the patch to it.