Jaspersoft使用文档Word文件下载.docx
- 文档编号:16226359
- 上传时间:2022-11-21
- 格式:DOCX
- 页数:11
- 大小:1.14MB
Jaspersoft使用文档Word文件下载.docx
《Jaspersoft使用文档Word文件下载.docx》由会员分享,可在线阅读,更多相关《Jaspersoft使用文档Word文件下载.docx(11页珍藏版)》请在冰豆网上搜索。
然后根据开始你的标签布局设计模版:
(注意,所有的字体显示,要选择上图那3个属性值,否则会出现乱码)
(默认打印出来是不会显示边框的,选中Rectangle标签,右击—>
PaddingandBroders)
预览成功之后会生成一个.jaspersoft文件,用来java代码解析使用.
Java代码调用jaspersoft
1):
导入jar
<
dependency>
<
groupId>
jasperreports<
/groupId>
artifactId>
/artifactId>
version>
5.6.0<
/version>
classifier>
/classifier>
/dependency>
2):
把要打印的模版存到对应的项目目录下
3):
模版里面没有sql版本事例:
publicvoidprintNewExpress(HttpServletRequestrequest,Stringno,
HttpServletResponseresponse)throwsJRException,InstantiationException,IllegalAccessException,IOException{
Collection<
Object>
storesQualitys=newArrayList<
();
List<
Pick>
pick=pickService.printExpressSingle(no);
for(Pickdetail:
pick){
StringcustomerCode=detail.getCustomerCode();
StringcustomerCompany=detail.getCustomerCompany();
StringcustomerMobile=detail.getCustomerMobile();
StringcustomerAddress=detail.getCustomerAddress();
StringcustomerZipcode=detail.getCustomerZipcode();
StringcustomerLocation=detail.getCustomerLocation();
StringclassPath=Thread.currentThread().getContextClassLoader().getResource("
"
).getPath();
StringtemplatePath="
;
ResourcePatternResolverresolver=newPathMatchingResourcePatternResolver();
Resourcehead=resolver.getResource("
classpath:
/com/iceasy/wms/console/controller/xls/template/printCarrierReport_Fed.jasper"
);
templatePath=head.getFile().getAbsolutePath();
//封装报表参数
HashMap<
String,Object>
params=newHashMap<
//获取报表模板
StringfileURL="
com"
+System.getProperty("
file.separator"
)+"
iceasy"
)+
"
wms"
console"
controller"
+System.getProperty("
xls"
)
+"
template"
StringtemplatePathImages=classPath+fileURL+"
checkbox_cheked.png"
params.put("
image_url"
templatePathImages);
//编译成JasperPrint对象
byte[]bytes=JasperRunManager.runReportToPdf(templatePath,params,newJRBeanCollectionDataSource(storesQualitys));
response.setContentType("
application/pdf"
response.setContentLength(bytes.length);
ServletOutputStreamout;
try{
out=response.getOutputStream();
out.write(bytes,0,bytes.length);
out.flush();
out.close();
}catch(IOExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
}
}
模版里面有sql版本事例:
publicvoidprintPickingList(HttpServletRequestrequest,Stringno,
HttpServletResponseresponse)throwsJRException,InstantiationException,IllegalAccessException,SQLException,IOException{
//获取报表模板
ResourcePatternResolverresolver=newPathMatchingResourcePatternResolver();
/com/iceasy/wms/console/controller/xls/template/printPickingList.jasper"
Resourcebody=resolver.getResource("
/com/iceasy/wms/console/controller/xls/template/printPickingDetailList.jasper"
SqlSessionsqlSession=sqlSessionFactory.openSession();
Connectionconnection=sqlSession.getConnection();
try{
StringtemplatePath=head.getFile().getAbsolutePath();
StringtemplatePath_Index=body.getFile().getAbsolutePath();
pickListJasper"
templatePath_Index);
no"
no);
byte[]bytes=JasperRunManager.runReportToPdf(templatePath,params,connection);
response.setContentType("
response.setContentLength(bytes.length);
ServletOutputStreamout;
out=response.getOutputStream();
out.write(bytes,0,bytes.length);
out.flush();
out.close();
}finally{
sqlSession.close();
}
(注:
有些标签要使用特定的字体,服务器上面可能没有,可以把对应的字体打成jar包上传到私服)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Jaspersoft 使用 文档
![提示](https://static.bdocx.com/images/bang_tan.gif)