???最近做excel,pdf導(dǎo)出,拿出最早的jxl.jar的程序出來看了下,太煩了,早先玩過displaytag,拿出來試了下,還行,excel到是出來,PDF中文不行,所以決定嘗試下eXtremeTable,從http://extremecomponents.org下載到最近的1.0.1版本,唉,文檔,build.xml全沒,說實話這個開源項目這方面做的的確不咋的,費了些時間把相關(guān)的jar庫放到lib,和web.xml的一些配置做好
<?xml?version="1.0"?encoding="ISO-8859-1"?>?????????????
<web-app?xmlns="http://java.sun.com/xml/ns/j2ee"
???xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
???xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
???version="2.4">???????????
????<taglib>
????<taglib-uri>/tld/extremecomponents</taglib-uri>
????<taglib-location>/WEB-INF/tld/extremecomponents.tld</taglib-location>
????</taglib>??
????
????<filter>
????????<filter-name>eXtremeExport</filter-name>
????????<filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class>
????</filter>
????
????<filter-mapping>
????????<filter-name>eXtremeExport</filter-name>
????????<url-pattern>/*</url-pattern>
????</filter-mapping>

</web-app>測試test.jsp頁面,注意tld的路徑.
經(jīng)過一段時后.......終于搞定,唉,汗
從官方網(wǎng)站上抄了一個導(dǎo)出excel,pdf的例子
<ec:table?
????var="pres"?
????items="pres"
????action="${pageContext.request.contextPath}/test2.jsp"?
????imagePath="${pageContext.request.contextPath}/images/table/compact/*.gif"
????view="compact"
????title=""
????showTooltips="true"
????filterable="false"
??????????????>
??????<ec:exportPdf?
???????????fileName="output.pdf"?
???????????tooltip="Export?PDF"?
???????????headerColor="black"?
???????????headerBackgroundColor="#b6c2da"?
???????????headerTitle="Presidents"
???????????text="PDF"
???????????/>
??????<ec:exportXls
???????????fileName="output.xls"?
???????????tooltip="Export?Excel"
???????????text="XLS"
???????????/>
????????<ec:row>
????????????<ec:column?property="name"/>
????????????<ec:column?property="nickname"/>
????????????<ec:column?property="term"/>
????????</ec:row>
??</ec:table>注意我加的filerable是去掉按某個屬性查詢的功能,經(jīng)測試,中文在上面基本沒用......
好了,回歸正題,我們主要的問題是導(dǎo)出PDF中文的問題,如何做請查看這篇文章
http://www.tkk7.com/lucky/archive/2006/03/10/34717.html,我只做一些補充,讓用到的朋友少走些彎路,關(guān)于FOP看了上文中推薦IBM上的文章差不多就明白了.
這里主要講的就是userconfig.xml這個配置文件
如果你出現(xiàn)
[ERROR] Failed to read a font metrics file: Invalid font metrics file: arialuni.
xml (no protocol: arialuni.xml)
[ERROR] unknown font arialuni,normal,normal so defaulted font to any
[ERROR] unknown font arialuni,normal,normal so defaulted font to any
這種類似的錯誤,都是因為userconfig.xml配置文件沒有寫對,現(xiàn)在給出我的
<configuration>
<fonts>
???<font?metrics-file="E:/jakarta-tomcat-5.5.10/eXtremeComponents/WEB-INF/classes/org/extremecomponents/resource/fonts/arialuni.xml"?embed-file="E:/jakarta-tomcat-5.5.10/eXtremeComponents/WEB-INF/classes/org/extremecomponents/resource/fonts/arialuni.ttf"?kerning="yes">
????<font-triplet?name="arialuni"?style="normal"?weight="normal"/>
????<font-triplet?name="arialuni"?style="normal"?weight="bold"/>
????<font-triplet?name="arialuni"?style="italic"?weight="normal"/>
????<font-triplet?name="arialuni"?style="italic"?weight="bold"/>
???</font>
</fonts>
</configuration>至此所有問題全部解決,系統(tǒng)正式用上eXtremetable,目前感覺還不錯.