如何在动态报告Java中获取表的高度

时间:2017-10-04 20:54:35

标签: java jasper-reports dynamic-reports

我很想知道如何通过使用动态报告来精确设置页面高度以适应(表格高度)来获得表格的高度。 所以,页面的高度=表格的高度

 private void build() {
    try {
        JasperReportBuilder report = report()
                .columns(
                        col.column("Qty", "qty", type.integerType()).setHorizontalTextAlignment(HorizontalTextAlignment.LEFT).setFixedWidth(25),
                        col.column("Item", "item", type.stringType()).setHorizontalTextAlignment(HorizontalTextAlignment.LEFT),
                        col.column("UP", "price", type.bigDecimalType()).setHorizontalTextAlignment(HorizontalTextAlignment.LEFT).setFixedWidth(30),
                        col.column("Sub", "sub", type.bigDecimalType()).setHorizontalTextAlignment(HorizontalTextAlignment.LEFT).setFixedWidth(30)
                )

                .setDataSource(createDataSource())
                .setPageFormat(200,???,  PageOrientation.PORTRAIT) // width , height               
                .show() ;


    } catch (DRException e) {
        e.printStackTrace();
    }

}

private JRDataSource createDataSource() {
    DRDataSource dataSource = new DRDataSource("qty" , "item" ,"price", "sub");
    dataSource.add(4,"Book" ,new BigDecimal("33"), new BigDecimal("33"));
    dataSource.add(6,"CD", new BigDecimal("33"),new BigDecimal("24"));

    return dataSource;
}

enter image description here

0 个答案:

没有答案