简体   繁体   English

Jasper Reports的经验,生成单词格式和PDF

[英]Experiences with Jasper Reports producing word format and PDF

I want to create a document (such as a invoice) with jasper reports in both MS Word and PDF format. 我想用MS Word和PDF格式的jasper报告创建一个文档(例如发票)。 Is it possible to generate both from the same jrxml report definition? 是否可以从相同的jrxml报告定义生成两者?

As MS Word support starts with DOCX format and lacks of support for DOC the comparision is between MS Word DOCX format and PDF. 由于MS Word支持以DOCX格式开始并且缺乏对DOC的支持,因此MS Word DOCX格式与PDF之间的比较。

Could this be done with jasper without headache? 这可以用碧玉无头痛吗? What are your experiences with this approach? 您对这种方法有什么经验? What about fonts, layouts, page breaks, images? 字体,布局,分页符,图像怎么样? Will Jasper produce similar results with MS Word and PDF? Jasper会用MS Word和PDF产生类似的结果吗?

Regards, Stefan 此致,斯特凡

JasperReport is a reporting engine in which you create reporting template and fill in this template with the values from either data source or from the Database. JasperReport是一个报告引擎,您可以在其中创建报告模板,并使用数据源或数据库中的值填充此模板。 Once this template is filled with the data, JasperReport provides many export option for exporting the generated report in desired format of the file. 一旦此模板填充了数据, JasperReport就会提供许多导出选项,用于以所需的文件格式导出生成的报告。

The supported format from what I know are pdf/excel/html. 我所知道支持格式是pdf / excel / html。 * For .p *df , JasperReport uses iText library while for excel generation it uses POI library . * 对于.p * df,JasperReport使用iText库,而对于excel生成,它使用POI库 These libraries are standard libraries and can be used as a standalone library also in order to create Pdf or Excel. 这些库是标准库,也可以用作独立库,以便创建Pdf或Excel。

As far as formatting of the report is concerned, I would advise you to create the reporting template and the actual report in the iReport and fix the layout issues if any from ireport. 就报告的格式而言,我建议您在iReport中创建报告模板和实际报告,并修复ireport中的布局问题(如果有的话)。 Then you can export the .jrxml file from iReport into your project and fill it with Data. 然后,您可以将.jrxml文件从iReport导出到项目中,并用Data填充它。 This will take care of the formatting. 这将处理格式。

As is the case with .pdf file, it retains most of the formatting as will be observed in the iReport. 与.pdf文件一样,它保留了在iReport中观察到的大部分格式。 With excel the formatting tends to break but the API provides useful function using which the formatting in excel can also be done at ease. 使用excel时,格式化趋于破坏,但API提供了有用的功能,使用该功能也可以轻松完成excel中的格式化。

A point to note however would be that as iText and POI both are external libraries, somewhere or the other there would be a very slight mismatch in the formatting of the actual report but then you can tweak it to appear it proper with some trials. 但要注意的是,因为iText和POI都是外部库,在某个地方或另一个地方,实际报告的格式会有一个非常轻微的不匹配,但是你可以通过一些试验来调整它以使其正确显示

My personal experience on Windows and Linux suggests that first identify the target machine on which your application is expected to run. 我在Windows和Linux上的个人经验表明,首先要确定应用程序运行的目标机器 Design your reporting layout then according to the operating system. 然后根据操作系统设计报告布局。 This is needed because at time the actual report generated on Windows and Linux differ a bit in formatting and this generally happens due to Fonts. 这是必要的,因为在Windows和Linux上生成的实际报告在格式上有点不同,这通常是由于字体而发生的。

Some things, I learned since my question: 有些事,我从问题开始学到了:

The support for DOCX+XLSX improved since may '13. 自2013年5月以来,对DOCX + XLSX的支持有所改善。 The first tests produced quit poor results, bug things got better since then. 第一次测试产生了不好的结果,从那时起bug变得更好。

Get the download jasperreports-zzz-project.tar.gz and have a look at the demos . 获取下载jasperreports-zzz-project.tar.gz并查看演示 I found them useful. 我觉得它们很有用。 They gave me more insight, that the information on the G00gle. 他们给了我更多的见解,关于G00gle的信息。

regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM