




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Jaspersoft使用文档1:安装jaspersoft.不做介绍。2:创建文件。打开菜单:文件new选择Blank A4,点击Launch Report Wizard按钮确定.点击下一步后面连续点击”下一步”,完成文件的创建。一般情况下,只留Detail 1 模块即可,其它都可删除。特殊标签可能用到Page Header和page Footer删除之后,如下图所示,并且在属性栏设置文件的高、宽。然后根据开始你的标签布局设计模版:(注意,所有的字体显示,要选择上图那3个属性值,否则会出现乱码)(默认打印出来是不会显示边框的,选中Rectangle标签,右击Padding and Broders )预览成功之后会生成一个.jaspersoft文件,用来java代码解析使用.Java代码调用jaspersoft1):导入jarjasperreportsjasperreports5.6.0jasperreports2):把要打印的模版存到对应的项目目录下3):模版里面没有sql版本事例: public void printNewExpress(HttpServletRequest request,String no,HttpServletResponse response) throws JRException, InstantiationException, IllegalAccessException, IOException Collection storesQualitys = new ArrayList(); List pick=pickService.printExpressSingle(no); for (Pick detail : pick) String customerCode=detail.getCustomerCode(); String customerCompany=detail.getCustomerCompany(); String customerMobile=detail.getCustomerMobile(); String customerAddress=detail.getCustomerAddress(); String customerZipcode=detail.getCustomerZipcode(); String customerLocation=detail.getCustomerLocation(); String classPath=Thread.currentThread().getContextClassLoader().getResource().getPath(); String templatePath=; ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource head = resolver.getResource(classpath:/com/iceasy/wms/console/controller/xls/template/printCarrierReport_Fed.jasper); templatePath =head.getFile().getAbsolutePath(); /封装报表参数 HashMap params = new HashMap(); /获取报表模板 String fileURL=com+System.getProperty(file.separator)+iceasy+System.getProperty(file.separator)+ wms+System.getProperty(file.separator)+console+System.getProperty(file.separator)+controller +System.getProperty(file.separator)+xls+System.getProperty(file.separator) +template+System.getProperty(file.separator); String templatePathImages =classPath + fileURL+checkbox_cheked.png; params.put(image_url, templatePathImages); /编译成JasperPrint对象 byte bytes = JasperRunManager.runReportToPdf(templatePath, params, new JRBeanCollectionDataSource(storesQualitys); response.setContentType(application/pdf);response.setContentLength(bytes.length);ServletOutputStream out;try out = response.getOutputStream();out.write(bytes, 0, bytes.length);out.flush();out.close(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace(); 3):模版里面有sql版本事例:public void printPickingList(HttpServletRequest request,String no,HttpServletResponse response) throws JRException, InstantiationException, IllegalAccessException, SQLException, IOException /获取报表模板 ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource head = resolver.getResource(classpath:/com/iceasy/wms/console/controller/xls/template/printPickingList.jasper); Resource body = resolver.getResource(classpath:/com/iceasy/wms/console/controller/xls/template/printPickingDetailList.jasper); SqlSession sqlSession = sqlSessionFactory.openSession(); Connection connection = sqlSession.getConnection(); try String templatePath = head.getFile().getAbsolutePath(); String templatePath_Index = body.getFile().getAbsolutePath(); /封装报表参数 HashMap params = new HashMap(); params.put(pickListJasper, templatePath_Index); params.put(no, no); byte bytes = JasperRunManager.runReportToPdf(templatePath, params, connection); response.setContentType(application/pdf); response.setContentLength(bytes.length); ServletOutput
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业家投资交流活动方案
- 企业年终摸奖活动方案
- 企业忆苦思甜活动方案
- 企业控制活动方案
- 企业校园活动方案
- 企业活动进校园活动方案
- 企业班会活动方案
- 企业筹办活动方案
- 企业联村包户活动方案
- 企业青工创新活动方案
- GB/T 19410-2008螺杆式制冷压缩机
- GA/T 645-2014安全防范监控变速球型摄像机
- 8D改善报告模板
- 广东药学院棒垒球协会公开课~2013课件
- 最新医疗“三基三严”知识考试题库及答案
- 2023年福建省高一数学竞赛试题参考答案
- 婴幼儿上呼吸道感染的护理课件
- 一年级英语下册素材-Unit 1 Lets count!课文翻译 译林版(一起)
- 幼儿园大班数学口算练习题可打印
- 功能薄膜材料与技术课件
- 应急救援预案组织机构图
评论
0/150
提交评论