Jaspersoft使用文档Word文件下载.docx

上传人:b****3 文档编号:16226359 上传时间:2022-11-21 格式:DOCX 页数:11 大小:1.14MB
下载 相关 举报
Jaspersoft使用文档Word文件下载.docx_第1页
第1页 / 共11页
Jaspersoft使用文档Word文件下载.docx_第2页
第2页 / 共11页
Jaspersoft使用文档Word文件下载.docx_第3页
第3页 / 共11页
Jaspersoft使用文档Word文件下载.docx_第4页
第4页 / 共11页
Jaspersoft使用文档Word文件下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

Jaspersoft使用文档Word文件下载.docx

《Jaspersoft使用文档Word文件下载.docx》由会员分享,可在线阅读,更多相关《Jaspersoft使用文档Word文件下载.docx(11页珍藏版)》请在冰豆网上搜索。

Jaspersoft使用文档Word文件下载.docx

 

然后根据开始你的标签布局设计模版:

(注意,所有的字体显示,要选择上图那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包上传到私服)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1