我有一个动态碧玉报告的例子。
我正在使用 NetBeans IDE。
我包括库文件如下:
Dynamic-jasper-3.2.1.jar
Dynamic-jasper-3.2.1-test.jar
jasperreport-4.5.jar
commons-beanutils-1.8.2.jar
commons-collections-3.2.1.jar
commons-digester-1.7.jar
commons-logging-1.1.jar
junit-3.8.2.jar
import java.util.Date;
import net.sf.jasperreports.view.JasperDesignViewer;
import net.sf.jasperreports.view.JasperViewer;
import ar.com.fdvs.dj.domain.DynamicReport;
import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
import ar.com.fdvs.dj.test.BaseDjReportTest;
public class FastReportTest extends BaseDjReportTest {
public DynamicReport buildReport() throws Exception {
FastReportBuilder drb = new FastReportBuilder();
drb.addColumn("State", "state", String.class.getName(), 30)
.addColumn("Branch", "branch", String.class.getName(), 30)
.addColumn("Product Line", "productLine", String.class.getName(), 50)
.addColumn("Item", "item", String.class.getName(), 50)
.addColumn("Item Code", "id", Long.class.getName(), 30, true)
.addColumn("Quantity", "quantity", Long.class.getName(), 60, true)
.addColumn("Amount", "amount", Float.class.getName(), 70, true)
.addGroups(2)
.setTitle("November \"2006\" sales report")
.setSubtitle("This report was generated at " + new Date())
.setPrintBackgroundOnOddRows(true)
.setUseFullPageWidth(true);
DynamicReport dr = drb.build();
return dr;
}
public static void main(String a[]) throws Exception {
FastReportTest test = new FastReportTest();
// test.
test.testReport();
test.exportToJRXML();
JasperViewer.viewReport(test.jp); //finally display the report report
JasperDesignViewer.viewReportDesign(test.jr);
}
}
我有这样的错误:
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DynamicJasperHelper generateJasperReport
INFO: generating JasperReport
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DynamicJasperHelper generateJasperReport
INFO: generating JasperReport
Feb 17, 2012 10:30:58 AM ar.com.fdvs.dj.core.DJJRDesignHelper getNewDesign
INFO: obtaining DynamicJasperDesign instance
Exception in thread "main" java.lang.NoSuchMethodError: ar.com.fdvs.dj.domain.DynamicJasperDesign.setPrintOrder(B)V
at ar.com.fdvs.dj.core.DJJRDesignHelper.getNewDesign(DJJRDesignHelper.java:69)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperDesign(DynamicJasperHelper.java:207)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:535)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:518)
at ar.com.fdvs.dj.test.BaseDjReportTest.testReport(BaseDjReportTest.java:83)
at FastReportTest.main(FastReportTest.java:34)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)