Jump to content
Changes to the Jaspersoft community edition download ×

szaharia

Jaspersoft Staff
  • Posts

    16
  • Joined

  • Last visited

szaharia's Achievements

  1. When using a table component in a report, we often prefer to organise data by grouping it inside the table upon various criteria. Also, we can display summary data (such as totals, average value or number of records) using the group footer section. Such tables with organised data and group footers can be easily converted into Excel documents with outlined row groups, with the help of the net.sf.jasperreports.export.xls.row.outline.level.<suffix> properties. In order to obtain a consistent Excel document with outline row groups the following rules should be applied: The <suffix> fragment should be replaced with the outline level number (between 1 and 7). For instance: net.sf.jasperreports.export.xls.row.outline.level.1 for outline level 1, net.sf.jasperreports.export.xls.row.outline.level.3 for outline level 3.The outline level 1 represents the outermost level, while level 7 represents the innermost level. Use the outline levels as follows: level 1 for elements in the first group declared in the report (which encloses all subsequent groups), level 2 for elements in the second group, and so on.For elements in group headers and detail cells use the "Body" value for the net.sf.jasperreports.export.xls.row.outline.level.<suffix> property. This ensure the row the element belongs to is part of an outline group.For instance: <property name="net.sf.jasperreports.export.xls.row.outline.level.2" value="Body"/> ensures the row containing this element belongs to a level 2 row group. For elements in group footers use the "End" value for the net.sf.jasperreports.export.xls.row.outline.level.<suffix> property. This ensure the related outline group will end on that row and a new one will begin on the next row.For instance: <property name="net.sf.jasperreports.export.xls.row.outline.level.2" value="End"/> ensures the level 2 row group ends on this line. There is no need to set this property for every element in a group header or in a detail row, or in a group footer. Using it for a single element per group header, per detail row and per group footer is enough to enable row outlining in Excel output.Attached is an example report with 3 groups declared in a subdataset to be used in a table component: <group name="product_class_id_group"> <groupExpression><![CDATA[$F{product_class_id}]]></groupExpression> </group> <group name="brand_name_group"> <groupExpression><![CDATA[$F{brand_name}]]></groupExpression> </group> <group name="recyclable_package_group"> <groupExpression><![CDATA[$F{recyclable_package}]]></groupExpression> </group> So the outermost group (level 1) is product_class_id_group and the innermost (level 3) is recyclable_package_group: There are no group headers in the report, so we have the following settings: For the first textfield in the detail row:<property name="net.sf.jasperreports.export.xls.row.outline.level.1" value="Body"/> <property name="net.sf.jasperreports.export.xls.row.outline.level.2" value="Body"/> <property name="net.sf.jasperreports.export.xls.row.outline.level.3" value="Body"/> This ensures that every detail row belongs to all 3 outline level groups. For the first element in the recyclable_package_group (level 3) group footer:<property name="net.sf.jasperreports.export.xls.row.outline.level.3" value="End"/> <property name="net.sf.jasperreports.export.xls.row.outline.level.2" value="Body"/> <property name="net.sf.jasperreports.export.xls.row.outline.level.1" value="Body"/> This ensures that level 3 outline group ends in this line, while it is still contained in the level 2 and level 1 row groups. For the first element in the brand_name_group (level 2) group footer:<property name="net.sf.jasperreports.export.xls.row.outline.level.2" value="End"/> <property name="net.sf.jasperreports.export.xls.row.outline.level.1" value="Body"/> This ensures that level 2 outline group ends in this line, while it is still contained in the level 1 row group. Automatically, any level 3 outline group will end in this row too. For the first element in the product_class_id_group (level 1) group footer:<property name="net.sf.jasperreports.export.xls.row.outline.level.1" value="End"/> This ensures that level 1 outline group ends in this line. Automatically, any level 2 and 3 outline groups will end in this row too. The report sample can be run using the Sample DB data adapter in Jaspersoft Studio. outline_levels.jrxml
  2. Many times we need to represent the same data in different forms in a given report. For instance, we have to display them in a chart, then list them in a table in order to perform some calculations and finally summarize the same data in a crosstab. In such cases, reusing the data between these components is crucial in performance improving, especially when the database or network connection works very slow, or we run complex queries. Once we gathered the data in a datasource, it would be very useful to cache this data and reuse it as needed in subdatasets and report components. Some useful hints on how to do this are also presented in these pages: https://community.jaspersoft.com/wiki/how-cache-data-report-use-multiple-datasetshttps://stackoverflow.com/questions/29943470/multiple-subreports-in-main-report-using-same-datasourceHere we will provide another method that would work for any type of data source and would allow the reuse of a subdataset data for multiple runs. This workaround is based on the following steps: use a dummy sortField in subdataset based on the REPORT_COUNT built-in variable to force the engine to cache the subdataset data. It first iterates through it and caches it because the sorting occurs in memory. Sorting on REPORT_COUNT does not actually affect the sort order, but helps us get an instance of SortableDataSource as REPORT_DATA_SOURCE parameter for the subdataset when first run:<sortField name="REPORT_COUNT" type="Variable"/> return the sorted data source from the subdataset in a main variable called MySubDataSource:<variable name="MySubDataSource" class="net.sf.jasperreports.engine.fill.SortedDataSource" calculation="System"/> ... <timeSeriesChart> ... <timeSeriesDataset timePeriod="Month"> <dataset resetType="Report"> <datasetRun subDataset="Country_Orders" uuid="c8f3b123-7be5-4ea0-9002-5fc495821df5"> <datasetParameter name="Country"> <datasetParameterExpression><![CDATA[$F{ShipCountry}]]></datasetParameterExpression> </datasetParameter&gt; <returnValue fromVariable="MyDataSource" toVariable="MySubDataSource"/> </datasetRun> </dataset> pass that MySubDataSource as the dataSourceExpression for the other report components that need to reuse the data, andmake sure the record pointer is moved back to the firsts record by calling moveFirst() in the dataSourceExpression of the report components:<timeSeriesChart> ... <timeSeriesDataset timePeriod="Month"> <dataset resetType="Report"> <datasetRun subDataset="Country_Orders" uuid="c8f3b123-7be5-4ea0-9002-5fc495821df5"> <dataSourceExpression><![CDATA[$V{MySubDataSource}; $V{MySubDataSource}.moveFirst()]]></dataSourceExpression> </datasetRun> </dataset> This way, the data source produced by the first subdataset run can be used multiple times. Attached is a modified version of a JRL sample that can be found in the demo/samples/charts directory in the JRL project distro. The original sample file can be found here: https://github.com/TIBCOSoftware/jasperreports/blob/master/jasperreports/demo/samples/charts/reports/SubDatasetChartReport.jrxml The modified version of this report displays each chart twice, using the same subdataset, but the second time around, it does not execute the query of the subdataset again, it rather uses cached data from the first run of the dataset performed for the first chart. The report can be run in JSS using the built-in Sample DB datasource. subdatasetchartreport.jrxml
  3. Changed Resolution from Open to Fixed Changed Status from Assigned to Resolved The issue is now fixed and will be part of the next JasperReports release.To have cells set as Text type in Excel, you need to set the following property for that element:Also, if the net.sf.jasperreports.export.xls.detect.cell.type property is set to false, the cell type will be set as Text.
  4. Changed Status from Resolved to Closed
  5. Changed Resolution from Open to Unable to Reproduce Changed Status from New to Feedback Requested Hi, Could you post a sample report here in order to help us reproduce the problem? With our current sample barbecue report it cannot be reproduced.Thanks.
  6. Thank you. The detail band with the Break elements needs to be placed after the band containing the subreport in the JRXML. Something like: <detail> <band height="20" splitType="Stretch"> <subreport isUsingCache="true" runToBottom="true"> ... </subreport> </band> <band height="50"> <break> ... </break> <staticText> ... </staticText> <break> ... </break> </band> </detail>
  7. Well, in this case it would be very useful if you could post your JRXML file here, in order to illustrate the report layout in your case. Thank you, Sanda
  8. The detail section can contain multiple bands, so you could insert a second detail band that contains 2 Break elements with an empty Static Text element between them. See the attachment.
  9. Hi, It depends on your report layout. Usually you could place a Break element before the subreport and this will do the job. Also make sure the net.sf.jasperreports.export.xls.one.page.per.sheet flag is turned on. In case these settings don't solve the problem, please post your JRXML files here.
  10. This PAGE_INDEX parameter can be used with JasperReports API directly, as C-Box said. If you are using Jaspersoft Studio, you could set this parameter by clicking on Report Parameters icon in the Parameters section of the Preview area (see attachment image)
  11. As already discussed above, you'll need to set a currency pattern for the textfield, to be considered in output formats other than Excel (PDF, HTML, etc). For the Excel output, you also need to set the net.sf.jasperreports.export.xls.pattern property for that textfield, in order to generate an Excel-specific accounting pattern when exporting to Excel. Try to use the following expression: <propertyExpression name="net.sf.jasperreports.export.xls.pattern"> <![CDATA["$\ * #,##0.00;$\ * -#,##0.00"]]></propertyExpression>
  12. As a workaround you could use the replaceAll() method in the image expression. Something like <imageExpression> <![CDATA["http://localhost:8070/webdav/Space In Name.jpg".replaceAll(" ","%20")]]></imageExpression> Or, if your image url is stored in a field named image_url: <imageExpression><![CDATA[$F{image_url}.replaceAll(" ","%20")]]></imageExpression>
  13. Spaces need to be URL-encoded in order to be considered. Try with "http://localhost:8070/webdav/Space%20In%20Name.jpg" and see if the problem is solved.
  14. You need to create and customize a JRDesignGroup first. For instance, see the noxmldesign sample shipped with the JasperReports distro: http://jasperreports.sourceforge.net/sample.reference/noxmldesign/index.html#noxmldesign
×
×
  • Create New...