private static JasperPrint fillReport(JRFileVirtualizer virtualizer) throws JRException { long start = System.currentTimeMillis(); // Virtualization works only with in memory JasperPrint objects. // All the operations will first fill the report and then export // the filled object. // creating the data source JRDataSource dataSource = new JREmptyDataSource(1000); // Preparing parameters Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); // filling the report JasperPrint jasperPrint = JasperFillManager.fillReport("build/reports/VirtualizerReport.jasper", parameters, dataSource); virtualizer.setReadOnly(true); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); return jasperPrint; }
public static void getDefaults(IPreferenceStore store) { store.setDefault(NSF_FILES_DELETE_ONEXIT, "true"); //$NON-NLS-1$ store.setDefault(JSS_VIRTUALIZER_USE, "false"); //$NON-NLS-1$ store.setDefault(JSS_VIRTUALIZER_TYPE, JRFileVirtualizer.class.getName()); store.setDefault(JSS_VIRTUALIZER_MAX_SIZE, 100); store.setDefault(JSS_VIRTUALIZER_TMP, ""); //$NON-NLS-1$ store.setDefault(JSS_VIRTUALIZER_BLOCK_SIZE, 100); store.setDefault(JSS_VIRTUALIZER_MIN_GROW_COUNT, 100); store.setDefault(JSS_VIRTUALIZER_PAGE_ELEMENT_SIZE, 1); store.setDefault(JSS_LIMIT_RECORDS, "false");//$NON-NLS-1$ store.setDefault(JSS_MAX_RECORDS, -1);//$NON-NLS-1$ store.setDefault(JSS_IGNOREPAGINATION, "false");//$NON-NLS-1$ store.setDefault(JSS_REPORT_LOCALE, Locale.getDefault().toString());//$NON-NLS-1$ store.setDefault(JSS_REPORT_TIMEZONE, TimeZone.getDefault().getID());//$NON-NLS-1$ }
private void build() { TextColumnBuilder<String> itemColumn = col.column("Item", "item", type.stringType()); TextColumnBuilder<Integer> quantityColumn = col.column("Quantity", "quantity", type.integerType()); TextColumnBuilder<BigDecimal> priceColumn = col.column("Unit price", "unitprice", type.bigDecimalType()); try { report() .setTemplate(Templates.reportTemplate) .columns( itemColumn, quantityColumn, priceColumn) .title(Templates.createTitleComponent("Virtualizer")) .pageFooter(Templates.footerComponent) .setDataSource(createDataSource()) .setVirtualizer(new JRFileVirtualizer(2)) .show(); } catch (DRException e) { e.printStackTrace(); } }
/** * */ public void export() throws JRException { // creating the virtualizer JRFileVirtualizer virtualizer = new JRFileVirtualizer(2, "tmp"); JasperPrint jasperPrint = fillReport(virtualizer); exportPdf(jasperPrint); exportXml(jasperPrint, false); exportHtml(jasperPrint); exportCsv(jasperPrint); // manually cleaning up virtualizer.cleanup(); }
private static JasperPrint fillReport() throws JRException { // creating the virtualizer JRFileVirtualizer virtualizer = new JRFileVirtualizer(2, "tmp"); return fillReport(virtualizer); }
/** * @return the jrVirtualizer */ public JRFileVirtualizer getJrVirtualizer() { return jrVirtualizer; }
/** * @param jrVirtualizer the jrVirtualizer to set */ public void setJrVirtualizer(JRFileVirtualizer jrVirtualizer) { this.jrVirtualizer = jrVirtualizer; }
@Override protected void configureReport(JasperReportBuilder rb) { rb.title(cmp.text("title")) .setVirtualizer(new JRFileVirtualizer(2)); }