Jump to content
JasperReports Library 7.0 is now available ×
  • Making HTML, XLS or CSV friendly reports

    • Features: Exporters Version: v5.1, v5.0, v4.8, v4.7, v4.6, v4.5 Product: JasperReports® Library

    When generating reports, the TIBCO JasperReports® engine uses the absolute position of each report element to layout the content of each page. Absolute positioning the report elements allows full control over the content of the output documents.

    The PDF format supports absolute positioning of the text and graphic elements on a document page and this is why it is widely used on various platforms. You can be sure that once created, a PDF document will look the same no matter what is the viewer's platform.

    The JasperReports proprietary document format (JasperPrint objects) is also based on absolute positioning of elements on the page. The position and size of each element are defined by the x, y, width and height properties.

    However, other document formats such as XLSX, XLS or DOCX, do not support absolute positioning of the text and graphic elements. The content of such documents is arranged in a grid or table structure.

    This is why the JasperReports built-in exporters that produce XLSX, XLS, DOCX, ODS or CSV documents use a special algorithm in order to arrange the elements present on a certain document page in some sort of a grid.

    When the report designs are very complex or agglomerated, passing from absolute positioning to grid or table layout produces very complex tables with many unused rows and columns, to make it for the empty space between elements or their special alignment.

    There are a few, very simple guidelines that should be followed by those who want to obtain optimized XLS, DOCX, ODS or CSV documents when using the built-in JasperReports grid exporters.

    1. Minimizing the number of rows and columns in the grid oriented formats (minimizing the number of "cuts").

      To do that, you have to make sure you align your report elements as often as you can, both on the horizontal and the vertical axis and that you eliminate the space between elements.
      1. Inefficient Layout:

      2. Grid friendly layout:

    2. Avoiding overlapping report elements.

      Make sure report element will not overlap when the report will be generated. This is because if you have two elements that share some region, it will be impossible for them to share the same cell in the resulting grid structure. You might obtain some unexpected results if elements overlap.

    3. Give up using page headers and page footers.

      Especially when you want to obtain documents in which the page breaks are not relevant (CSV for example), make sure that you suppress the page header and page footer sections in your report design. You could also minimize the top and bottom margins for your report, so that when exported to XLSX, XLS, DOCX, ODS or CSV, your documents will be made of a single chunk, without page separators.

    User Feedback

    Recommended Comments

    There are no comments to display.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...