锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
2銆乂ML鏍囪鏀寔鐨凥TML閫氱敤灞炴?br />
灞炴у悕
榛樿鍊?/td>
鍊肩被鍨?鑼冨洿
鐢ㄩ?/td>
strokeweight
0.75pt=1px
number
鎻忚堪鍥懼艦鐨勮竟妗嗙矖搴?/td>
strokecolor
black
color
鎻忚堪鍥懼艦鐨勮竟妗嗛鑹?/td>
stroked
true
boolean
鎻忚堪鍥懼艦鏄惁浣跨敤杈規(guī)
fillcolor
white
color
鎻忚堪鍥懼艦鐨勮儗鏅鑹?/td>
filled
true
boolean
鎻忚堪鍥懼艦鏄惁浣跨敤鑳屾櫙
print
true
boolean
鎻忚堪鍥懼艦鏄惁鍏佽琚墦鍗版満鎵撳嵃
coordsize
1000,1000
Vector2D
鏆楃ず鍥懼艦涓庡鍣ㄧ┖闂寸殑澶у皬姣斾緥
coordorigin
0 0
Vector2D
coordinate at top-left corner of element
wrapcoords
null
string
outline to use for tight text wrapping
3銆乂ML鏍囪鏀寔鐨凜SS閫氱敤灞炴?br />
灞炴у悕
榛樿鍊?/td>
鍊肩被鍨?鑼冨洿
鐢ㄩ?/td>
id
null
string
瀹氫箟鍏冪礌鐨勬爣璇嗙儲寮?澶氱敤浜嶥HTML緙栫▼)
class
null
classname
瀹氫箟鍏冪礌浣跨敤鐨凜SS鏍峰紡綾?/td>
style
null
CSS string
鎻忚堪鍥懼艦鐨凜SS鏍峰紡琛?/td>
title
null
string
瀹氫箟鍥懼艦鐨勬彁紺烘爣棰?榧犳爣闈犺繎鍚庣殑甯姪鎻愮ず)
href
null
string
瀹氫箟鍥懼艦閾炬帴鐨刄RL鍦板潃
target
_self
_self/_blank/_top
瀹氫箟鍥懼艦浠ヤ綍縐嶅艦寮忔墦寮閾炬帴
contentEditable
false
boolean
鎻忚堪鍥懼艦鍐呭鏄惁鍏佽鐢ㄦ埛緙栬緫
dir
ltr
ltr/rtl
鎻忚堪鍥懼艦鍐呭浠ュ摢縐嶆柟鍚戣緭鍑?/td>
disabled
false
boolean
鎻忚堪鍥懼艦鑳藉鍝嶅簲鐢ㄦ埛浜嬩歡瑙﹀彂
灞炴у悕
鍙敤鍊?鍙敤鍊艱寖鍥?/td>
鐢ㄩ?/td>
width
0-9999
鎻忚堪瀹藉害
height
0-9999
鎻忚堪楂樺害
position
static absolute fixed relative
鎻忚堪濡備綍瀹氫綅杈撳嚭
left
0-9999
鎻忚堪璺濈欏甸潰浣嶇疆宸?/td>
top
0-9999
鎻忚堪璺濈欏甸潰浣嶇疆涓?/td>
z-index
0-9999
鎻忚堪3D浣嶇疆
cursor
auto crosshair hand move help wait text……
鎻忚堪榧犳爣褰㈢姸
zoom
0-99
鎻忚堪緙╂斁姣斾緥
clip
rect(涓?鍙?涓?宸?
鎻忚堪瑁佸壀瀵硅薄
border
0-99 style color
鎻忚堪杈規(guī)
display
block none inline list-item
鎻忚堪鏄劇ず鎴栭殣钘?/td>
overflow
visible auto hidden scroll
鎻忚堪婊氬姩鏉?/td>
color
colorstring
鎻忚堪鏂囨湰鍐呭棰滆壊
font-size
0-999
鎻忚堪鏂囨湰鍐呭瀛楀彿
filter
xray flipv fliph invert alpha(opacity=num)
鎻忚堪婊ら暅鏁堟灉
rotation
(0-9999)%360
鎻忚堪鏃嬭漿搴?/td>
flip
x y
鎻忚堪鍙嶈漿鎴栭鍊掑浘褰?/td>
]]>
List list=this.customerDao.getAllCustomer(); //寰楀埌鎵鏈夊鎴?br />
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = JasperFillManager.fillReport(
reportFilePath, parameters, ds);
寰楀~鍏呮暟鎹悗錛屽嵆鍙緭鍑烘樉紺哄埌PDF,Excel,Html
鍒癙DF:
public byte[] generatePDF(String begCustNo, String endCustNo,
String reportTitle, String reportFilePath) throws DemoException {
// TODO Auto-generated method stub
//begCustNo,endCustNo鍒嗗埆涓烘煡璇紶鍏ョ殑寮濮嬬紪鍙鳳紝緇撴潫緙栧彿.
jdbcCustomerDao = new JdbcCustomerDao();
Map parameters = new HashMap();
parameters.put("ReportTitle", reportTitle);//鎶ヨ〃鏍囬
List list = jdbcCustomerDao.getAllCustomer(begCustNo, endCustNo);
try {
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = JasperFillManager.fillReport(
reportFilePath, parameters, ds); return JasperExportManager.exportReportToPdf(jasperPrint);
} catch (JRException e) {
throw new DemoException("Report Export Failed.");
}
}
鍒癏tml:
public byte[] generateHtml(String begCustNo, String endCustNo,
String reportTitle, String reportFilePath) throws DemoException {
jdbcCustomerDao = new JdbcCustomerDao();
Map parameters = new HashMap();
parameters.put("ReportTitle", reportTitle);
List list = jdbcCustomerDao.getAllCustomer(begCustNo, endCustNo);
System.out.println("list size is :" + list.size());
JRHtmlExporter exporter = new JRHtmlExporter();
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
try {
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = JasperFillManager.fillReport(
reportFilePath, parameters, ds);
exporter.setParameter(
JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,
Boolean.FALSE);
exporter
.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter
.setParameter(JRExporterParameter.CHARACTER_ENCODING, "GBK");
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, oStream);
exporter.exportReport();
byte[] bytes = oStream.toByteArray();
return bytes;
} catch (JRException e) {
throw new DemoException("Report Export Failed.");
}
}
鍒癊xcel:
public byte[] generateExcel(String begCustNo, String endCustNo,
String reportTitle, String reportFilePath) throws DemoException {
jdbcCustomerDao = new JdbcCustomerDao();
Map parameters = new HashMap();
parameters.put("ReportTitle", reportTitle);
List list = jdbcCustomerDao.getAllCustomer(begCustNo, endCustNo);
System.out.println("list size is :" + list.size());
JRXlsExporter exporter = new JRXlsExporter(); // Excel
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
try {
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = JasperFillManager.fillReport(
reportFilePath, parameters, ds);
exporter
.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, oStream);
exporter.setParameter(
JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,
Boolean.FALSE);
exporter.setParameter(
JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,
Boolean.FALSE);
exporter.exportReport();
byte[] bytes = oStream.toByteArray();
return bytes;
} catch (JRException e) {
throw new DemoException("Report Export Failed.");
}
}
jsp璋冪敤鏂規(guī)硶錛?br />
<%
String filePath=getServletContext().getRealPath("/")+"report.jasper";
CustomerServiceImpl custs=new CustomerServiceImpl();
byte[] bytes=null;
String begNo=request.getParameter("beginCustNo");
String endNo=request.getParameter("endCustNo");
String type=request.getParameter("type");
if(type.equals("Pdf")){
bytes= custs.generatePDF(begNo,endNo,"瀹㈡埛璧勬枡鏄庣粏琛?,filePath);
}else if(type.equals("Excel")){
bytes=custs.generateExcel(begNo,endNo,"瀹㈡埛璧勬枡鏄庣粏琛?,filePath);
}else
bytes=custs.generateHtml(begNo,endNo,"瀹㈡埛璧勬枡鏄庣粏琛?,filePath);
if(bytes!=null){
if(type.equals("Pdf")){
response.setContentType("application/pdf");
}else if(type.equals("Excel")){
response.setContentType("application/vnd.ms-excel");
}else
response.setContentType("text/html");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes,0,bytes.length);
ouputStream.flush();
ouputStream.close();
}else
{
out.println("error");
}
%>
======================================
servlet 杈撳嚭