JasperReport的使用过程.docx

上传人:b****5 文档编号:6877418 上传时间:2023-01-12 格式:DOCX 页数:9 大小:326.18KB
下载 相关 举报
JasperReport的使用过程.docx_第1页
第1页 / 共9页
JasperReport的使用过程.docx_第2页
第2页 / 共9页
JasperReport的使用过程.docx_第3页
第3页 / 共9页
JasperReport的使用过程.docx_第4页
第4页 / 共9页
JasperReport的使用过程.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

JasperReport的使用过程.docx

《JasperReport的使用过程.docx》由会员分享,可在线阅读,更多相关《JasperReport的使用过程.docx(9页珍藏版)》请在冰豆网上搜索。

JasperReport的使用过程.docx

JasperReport的使用过程

JasperReport(http:

//jasperforge.org/)

MinimumRequirementsandrequiredjarfiletogetstartedjasperreport:

●SunJDK1.4orlaterversion

●commons-beanutils-{version}.jar

●commons-collections-{version}.jar

●commons-digester-{version}.jar;

●commons-logging-{version}.jar;

●commons-logging-api-{version}.jar;

●itext-{version}.jar(pdfprinting)

●jasperreports-{version}.jar

●jdt-compiler-{version}.jar

●jxl-{version}.jar(excelprinting)

●png-encoder-{version}.jar

●poi-2.0-final-20040126.jar(excelprinting)

●jfreechart-1.0.12.jar(chatprinting)

●barbecue-1.1.jar(barcodeprinting)

iReportGettingStarted

Step1:

Download,Install,andRuniReportDownloadinhttp:

//jasperforge.org/

ToinstalliReportonaWindowsplatform:

runiReport--windows-installer.exe.

StartiReportusingthemenuitem

Programsmenu>Jaspersoft>iReport

IfyouareusingaMacoraLinuxbox,considertodownloadiReport-.tar.gz,extractthearchiveinyourfavoritedirectoryandrun:

iReport.sh.fromashell.

Step2:

Connecttoadatabase

iReportcanuseseveraldatasourcestocreatereports,suchasJDBCconnection,XMLfile,CSVfile,JavaBeanresultset,Hibernateconnection,etc...ThisdocumentwillshowhowtocreateJDBCconnectionDataSourceandXMLfileDataSource.

AddOracleJDBCDrivertoiReport

iReportrequiredtoaddthejavajarfileoftheJDBCDriver.IfyouareconnectingtheOracledatabaseasthedatasourceofthereport,youhavetoaddthejarfileoforaclejdbcdrivertoiReport.

AddingOracleclassfileforconnectiontoOracledatabase:

Tools->Options->Classpath->AddJAR

AddDataSource

ClickReportDatasourceicon

->New

OracleJDBCconnection

1.ClickDatabaseJDBCconnection.

2.fillintheconnectioninformation

XMLfileDataSource

1.ClickXMLfiledatasource

2.fillintheconnectioninformation

Step3:

Createyourfirstreport

Nowyouhavesetupadatabaseconnection,startthereportwizard(File->ReportWizard)toquicklycreateyourfirstreport.

1.Createanemptyreport“QuickQuote”

Thelayoutofreportcanbesplitinto:

TitleBand,PageHeaderBand,ColumnHeaderBand,DetailBand,ColumnFooterBand,PageFooterBand,SummaryBand

Inthisreport,wewilluseTitleBand,ColumnHeaderBandandDetailBandonly.

WecansettheBandHeightto0forunusedband

Definethequeryforthedata:

RightclickthemouseinblankareaofiReport.

Typethesqlstatementforthedata:

e.g.

SELECTID,QUICK_QUOTE_NOFROMmer_quick_quote

whereID='284e33e20a2bb9cb9ce510d0fe100897'

Addthefollowingobject,andpreviewthereport.

 

AddSubReport:

Hideunusedlayoutband:

Deletethe$F{PICTURE},andaddanImageobjectintothelayout.

Setthevalueoftheimageas:

"C:

\\filesystem\\uploadFiles\\QuickQuote\\thumbnail\\20090408\\"+$F{PICTURE}+".png"

PreviewtheSubReport:

Previewthewholereport:

UsingParametersinaQueryandSubReportQuery

ParametersmaybeusedtofilteraSQLquery.Supposeyouwanttoprintinformationabouta

particularcustomeridentifiedbycustomerID(notknownatdesigntime).Yourquerywillbeas

follows:

select*fromcustomers

whereCUSTOMERID=$P{MyCustomerId}

MyCustomerIdisaparameterdeclaredasaninteger.JasperReportswilltransformthisqueryto

select*fromcustomerswhereCUSTOMERID=?

ItwillrunthisSQLusingapreparedstatementbypassingtheMyCustomerIdvalueasa

queryparameter.Ifyouwouldliketopasstheparametervaluedirectly,youcanusethisspecial

syntax:

$P!

{parameter_name}

Thisallowsyoutoreplacetheparameternameinthequerywithitsvalue.Forexample,ifyouhave

aparameternamedMyWherewiththevalueofwhereCUSTOMERID=5,thequery

select*fromcustomers$P!

{MyWhere}

willbetransformedinto

select*fromcustomerswhereCUSTOMERID=5

byusingthissyntax.

Example:

SELECTID,QUICK_QUOTE_NOFROMmer_quick_quote

whereID=$P{docId}

 

PrintingbarcodeiniReport

1.Addanimagetothereport

2.SettheImageExpressionas:

e.g.

mon.image.BarcodeImage.getBarcodeImage(13,"0815",true,false,null,0,0)

3.SettheImageExpressionClass:

java.awt.Image

 

SubReportwithXMLdatasource:

ConnectionType

Useadatasourceexpression

DataSourceExpression

((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/DOC/LIN")

JasperPrintinginMerchant

Configuredinstruts-printing.xml

XMLsourcetoPDF->xml_print_pdf.action

XMLsourcetoExcel->xml_print_excel.action

XMLsourcetoHTML->xml_print_html.action

Exampletoruntheprintfeatureinoursystem:

http:

//localhost:

8083/merchantWeb/xml_print_pdf.action?

reportName=PacSunPO&docId=0000201569.xml

:

Parameter

Value

Parameter

Value

reportName

JasperclassfileName

docId

Xmlfilename

DBtoPDF->jasper_print_pdf.action

DBtoExcel->jasper_print_excel.action

DBtoHTML->jasper_print_html.action

Exampletoruntheprintfeatureinoursystem:

http:

//localhost:

8083/merchantWeb/jasper_print_pdf.action?

reportName=QuickQuote&docId=284e33e20a2bb9cb9ce510d0fe100897

http:

//localhost:

8083/merchantWeb/jasper_print_html.action?

reportName=CHART

 

UsefullinkforjasperreportandiReport.

iReportTutorials

http:

//ireport-

CreatingandDesigningReportUsingiReport(usingoldversionasexample)

JasperReport报表设计总结

JasperReport经验谈

 

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

当前位置:首页 > 人文社科

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

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