我很想知道如何通过使用动态报告来精确设置页面高度以适应(表格高度)来获得表格的高度。 所以,页面的高度=表格的高度
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;
}