eXtremeTable体验

eXtremeTable体验

   最近做excel,pdf导出,拿出最早的jxl.jar的程序出来看了下,太烦了,早先玩过displaytag,拿出来试了下,还行,excel到是出来,PDF中文不行,所以决定尝试下eXtremeTable,从http://extremecomponents.org下载到最近的1.0.1版本,唉,文档,build.xml全没,说实话这个开源项目这方面做的的确不咋的,费了些时间把相关的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的路径.
经过一段时后.......终于搞定,唉,汗
从官方网站上抄了一个导出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是去掉按某个属性查询的功能,经测试,中文在上面基本没用......
好了,回归正题,我们主要的问题是导出PDF中文的问题,如何做请查看这篇文章 http://www.blogjava.net/lucky/archive/2006/03/10/34717.html,我只做一些补充,让用到的朋友少走些弯路,关于FOP看了上文中推荐IBM上的文章差不多就明白了.
这里主要讲的就是userconfig.xml这个配置文件
如果你出现
[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配置文件没有写对,现在给出我的
< 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 >
至此所有问题全部解决,系统正式用上eXtremetable,目前感觉还不错.

你可能感兴趣的:(eXtremeTable体验)