ireport 5.6.0的使用(打印模板word,excel)
来源:互联网 发布:手机看网络电视流量 编辑:程序博客网 时间:2024/06/09 21:59
1.在pom.xml中导入jar包
<!-- ireport --> <dependency> <groupId>net.sf.jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>5.6.0</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>2.2.2</version> </dependency>
2.在spring-mvc中添加
<!-- 注册XmlViewResolver,用于iReport & JasperReports报表生成 --> <bean id="jasperReportResolver" class="org.springframework.web.servlet.view.XmlViewResolver"> <property name="order"> <value>0</value> </property> <property name="location"> <value>classpath:jasper-views.xml</value> </property> </bean>
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> <bean id="reportView" class="com.jinzay.smef.platform.reportView.CustomReportView"> <property name="reportDataKey" value="jrMainDataSource"/> </bean> </beans>
package com.jinzay.smef.platform.reportView;import java.util.Map;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.JasperReport;import org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView;/** * <p>Title: 报表工具</p> * */public class CustomReportView extends JasperReportsMultiFormatView{ private JasperReport report; public CustomReportView() { super(); } protected JasperPrint fillReport(Map<String, Object> model) throws Exception { if (model.containsKey("url")) { setUrl(String.valueOf(model.get("url"))); this.report = loadReport(); } return super.fillReport(model); } protected JasperReport getReport() { return this.report; }}
@RequestMapping(value = "/report", method = RequestMethod.GET) public String report(Model model) { List<Map<String, ?>> hissList = new ArrayList<Map<String,?>>(); Map<String, String> temp = new HashMap<String, String>(); hissList.add(temp);//拼装数据(map的键是$F{....}的名字,value值就是显示的值) // 报表数据源 (可以往界面添加多个数据源)名字可以随便定义 JRMapCollectionDataSource jrDataSource = new JRMapCollectionDataSource(sList); JRMapCollectionDataSource hisDataSource = new JRMapCollectionDataSource(hissList); // 动态指定报表模板url model.addAttribute("url", "/WEB-INF/classes/jasper/chedai.jasper"); //填充的jasper的文件地址 model.addAttribute("format", "pdf"); // 报表格式 model.addAttribute("jrMainDataSource", jrDataSource); //主数据源 model.addAttribute("hisDataSource", hisDataSource); //子表数据源 return "reportView"; // 对应jasper-views.xml中的bean id }
可以导入额外的jar包iTextAsian-1.0.jar
详细设计请看 Jaspersoft iReport Designer 5.6.0 的使用
8.linux上中文问题
创建jasperreports.properties文件放入classes里
net.sf.jasperreports.awt.ignore.missing.font=true
在windows里查找需要的字体,放入classes里
链接可以看这里
http://note.youdao.com/noteshare?id=70c2583ebb03578d91300b17d9694845
0 0
- ireport 5.6.0的使用(打印模板word,excel)
- 在JAVA项目中,使用JasperReports与iReport,直接连接打印机可打印(word excel xml pdf )文档
- 使用iReport打印报表
- jasperreport + ireport 导出各种类型文件(word,excel,html,pdf,打印) .
- 使用jacob打印word或excel
- C#使用指定打印机打印Word,Excel等Office文件和打印PDF文件的代码
- Jaspersoft iReport Designer 5.6.0 的使用
- iReport输出pdf,html,word,excel
- JavaScript打印Excel、Word
- PHP 替换WORD模板 实现可直接打印的WORD
- iReport打印为excel表头重复问题解决
- 使用ireport打印数据,servlet里面的固定写法。。。
- js以excel为模板的打印
- 使用iReport制作报表模板
- 使用iReport制作报表模板
- 使用iReport制作报表模板
- 使用jsp实现word、excel格式报表打印
- 使用jsp实现word、excel格式报表打印
- C#调用java webservice
- YYModel里的一些细节
- fastJSON使用(二)——json转换成对象
- POJ-2240 Arbitrage(floyd详解)
- numpy入门
- ireport 5.6.0的使用(打印模板word,excel)
- 360度不停旋转的10片叶子背景---纯css实现旋转背景
- Jmeter之三:配置元件 之 CSV Data Set Config
- 无中生有之突击NOIP(1)--排序
- 设计模式随笔-单件模式
- poj_1258 Agri-Net(prim)
- 获取栈调度信息
- 用EXCEL查询 SQL SERVER 数据库 U8 876的现存量。有重复的用黄色标记。
- 专题报道