私はDynamicReportsを使って動的なレポートを生成しようとしましたが、いつも例外を受けています。スレッド "AWT-EventQueueの-0" java.lang.NoSuchMethodErrorの中DynamicReportsを使用して動的レポートを生成するにはどうすればよいですか?
例外:net.sf.jasperreports.engine.base.JRBaseStyle.getParagraph()LNET/SF/JasperReportsの/エンジン/ JRParagraph。 (スタイルトランスフォーム。 dynamicreports.jasper.transformation.StyleTransform.addStyle(StyleTransform.java:65) at net.sf.dynamicreports.jasper.transformation.StyleTransform.transform(StyleTransform.java:59) at net.sf.dynamicreports.jasper.base。 (JasperReportDesign.java:77) at net.sf.dynamicreports.jasper.base.JasperReportDesign。(JasperReportDesign.java:107) 69) at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperReportDesig N(JasperReportBuilder.java:215)net.sf.dynamicreports.jasper.builder.JasperReportBuilder.toJasperPrintでnet.sf.dynamicreports.jasper.builder.JasperReportBuilder.getJasperParametersで (JasperReportBuilder.java:242) (JasperReportBuilder.java。 net.sf.dynamicreports.jasper.builder.JasperReportBuilder.show(JasperReportBuilder.java:281)ClsManufac.ClsDynamicReportでClsManufac.ClsDynamicReport.build(ClsDynamicReport.java:43) においてにおける252) 。(ClsDynamicReport.java:30 )Manufacturing.FrmMonthlyStock $ 5.actionPerformed(FrmMonthlyStock.java:148)でManufacturing.FrmMonthlyStock.access $ -400(FrmMonthlyStock.java:23) でManufacturing.FrmMonthlyStock.jButton1ActionPerformed(FrmMonthlyStock.java:335) で でjavax.swing.AbstractButton $ Handler.actionPerformed(AbstractButton.java:2335)javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404) で でのjavax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012) javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) のjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253) at java.awt.Component.processMouseEvent(Component.java:6175) java.awt.Container.processEventでjava.awt.Component.processEvent(Component.java:5940) でjavax.swing.JComponent.processMouseEvent(JComponent.java:3267) (Container.java:2105) ででjava.awt.Component.dispatchEventImpl(Component.java: 4536) at java.awt.Container.dispatchEventImpl(Container.java:2163) at java.awt.Component.dispatchEvent(Component.java:4362) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461) java.awt.Container.dispatchEventImplでjava.awt.LightweightDispatcher.dispatchEvent(Container.java:4055) でjava.awt.LightweightDispatcher.processMouseEvent(Container.java:4125) (Container.java:2149) ででjava.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4362) at java.awt.EventQueue.dispatchEvent(EventQueue.java:604) at java。 awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)java.awt.EventDispatchThread.pumpEventsでjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) でjava.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) で(EventDispatchThread.java:185) でjava.awt.EventDispatchThread。pumpEvents(EventDispatchThread.java:177)java.awt.EventDispatchThread.runで (EventDispatchThread.java:138)
私は私が必要なものJTableの、私のJFrameの中のJButtonは、レポートを生成することである必要がありボタンをクリックすると、JTableのデータからDynamicReport(http://dynamicreports.sourceforge.net/)を使用します。 ボタンをクリックすると、テーブルモデルを次のクラスに渡して、テーブルモデルをループしてレポートを生成しようとしています。
package com;
import java.awt.Color;
import java.awt.Font;
import static net.sf.dynamicreports.report.builder.DynamicReports.*;
import static net.sf.dynamicreports.report.builder.DynamicReports.*;
import java.math.BigDecimal;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import net.sf.dynamicreports.examples.DataSource;
import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.report.builder.DynamicReports;
import net.sf.dynamicreports.report.builder.style.StyleBuilder;
import net.sf.dynamicreports.report.constant.HorizontalAlignment;
import net.sf.dynamicreports.report.constant.LineStyle;
import net.sf.dynamicreports.report.exception.DRException;
import net.sf.jasperreports.engine.JRDataSource;
import org.apache.commons.lang.Validate;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.collections.ReferenceMap;
import org.apache.commons.digester.Rule;
public class SimpleReport {
DefaultTableModel model;
public SimpleReport(DefaultTableModel model) {
this.model = model;
build();
}
private void build() {
StyleBuilder boldStyle = stl.style().bold();
StyleBuilder boldCenteredStyle = stl.style(boldStyle).setHorizontalAlignment(HorizontalAlignment.CENTER);
StyleBuilder columnTitleStyle = stl.style(boldCenteredStyle);
StyleBuilder titleStyle = stl.style(boldStyle).setHorizontalAlignment(HorizontalAlignment.CENTER);
try {
JasperReportBuilder report = DynamicReports.report();
report()//create new report design
.setColumnTitleStyle(columnTitleStyle).columns(//add columns
// title, field name data type
//col.columnRowNumberColumn("No").setHorizontalAlignment(HorizontalAlignment.CENTER),
col.column("ID", "ID", type.stringType()).setHorizontalAlignment(HorizontalAlignment.LEFT),
col.column("Name", "Name", type.stringType()).setHorizontalAlignment(HorizontalAlignment.CENTER),
col.column("Phone", "Phone", type.stringType()).setHorizontalAlignment(HorizontalAlignment.CENTER)).title(cmp.text("Getting started\n").setStyle(titleStyle))//shows report title
.pageFooter(cmp.pageXofY())//shows number of page at page footer
.setDataSource(createDataSource())//set datasource
.show();//create and show report
} catch (Exception e) {
e.printStackTrace();
}
}
private JRDataSource createDataSource() {
DataSource dataSource = new DataSource("ID", "Name", "Phone");
for (int i = 0; i < model.getRowCount(); i++) {
System.out.println(model.getValueAt(i, 2));
dataSource.add(model.getValueAt(i, 0), model.getValueAt(i, 1), model.getValueAt(i, 2));
}
return dataSource;
}
}
詳細をお知らせください。 –