Posted on 2009-07-02 17:00
FineReport——报表技术领跑者 阅读(2154)
评论(0) 编辑 收藏 所属分类:
Java报表技术知识
1.写一个Java文件如SaveReportAction所示,其包名为com.demo,编译这个Java文件为类文件,保存到设计器的classpath下面。代码如下:
package com.demo;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.base.Inter;
import com.fr.cell.JWorkBook;
import com.fr.cell.ReportPane;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.core.DesignUtils;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JReportInternalFrame;
import com.fr.report.Report;
public class SaveReportAction extends UpdateAction {
public SaveReportAction() {
this.setName(Inter.getLocText("M-Save"));
this.setMnemonic('S');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/save.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
}
public void actionPerformed(ActionEvent arg0) {
JReportInternalFrame reportFrame = DesignUtils.getReportFrame(DesignerContext.getDesignerFrame());
if(reportFrame == null) {
return;
}
ReportPane reportPane = reportFrame.getReportPane();
Report report;
if(reportPane instanceof JWorkBook) {
report = ((JWorkBook)reportPane).getWorkBook();
} else {
report = reportPane.getReport();
}
// 可以通过TemplateExporter导出该Report
System.out.println("Report.getRowCount is " + report.getRowCount());
}
}
2.打开设计器,主菜单 | 窗口 | 选项,打开对话框导出菜单配置文件
3.修改menu.xml
4.再次打开设计器,主菜单 | 窗口 | 选项,打开对话框,指定菜单配置文件的目录为D:"menu.xml
5.重启设计器,可以看到File菜单下多了一个”保存”按钮