热门文章 | 热门软件| 热门源码 | 热门电影 | 知识库 | 联系我们
软件 源码 教程 影视 健康 招聘
  HTML | JavaScript | ASP | PHP | JSP | NET | VB | VC | VF | Windows | Linux | Mysql | Mssql | Oracle | Struts 
当前位置: 创世纪计算机资源网 -> 文章频道 ->struts 
站内搜索:
webwork输出PDF,CSV,XLS,HTML(3)
作者:阿栋 来源:blog 整理日期:2007-8-13

                    <reportElement
                        x="241"
                        y="3"
                        width="114"
                        height="17"
                        forecolor="#000000"
                        backcolor="#FFFFFF"
                        key="textField"/>
                    <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                    <textElement>
                        <font pdfFontName="STSong-Light" size="12" pdfEncoding ="UniGB-UCS2-H"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[$F{address.country}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
        <columnFooter>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </columnFooter>
        <pageFooter>
            <band height="27"  isSplitAllowed="true" >
                <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="325"
                        y="4"
                        width="170"
                        height="19"
                        forecolor="#000000"
                        backcolor="#FFFFFF"
                        key="textField"/>
                    <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                    <textElement textAlignment="Right">
                        <font size="10"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="499"
                        y="4"
                        width="36"
                        height="19"
                        forecolor="#000000"
                        backcolor="#FFFFFF"
                        key="textField"/>
                    <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                    <textElement>
                        <font size="10"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>
                <line direction="TopDown">
                    <reportElement
                        x="0"
                        y="3"
                        width="535"
                        height="0"
                        key="line"/>
                    <graphicElement stretchType="NoStretch"/>
                </line>
                <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="1"
                        y="6"
                        width="209"
                        height="19"
                        forecolor="#000000"
                        backcolor="#FFFFFF"
                        key="textField"/>
                    <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
                    <textElement>
                        <font size="10"/>
                    </textElement>
                <textFieldExpression   class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
                </textField>
            </band>
        </pageFooter>
        <summary>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </summary>
</jasperReport>


注册ACTION,在xwork.xml中添加们需要的action,

        <!-- Reports-START -->
       
        <action name="myJasperTest" class="JasperAction">
            <result name="success" type="jasper">
                <param name="location">/WEB-INF/reports/userList.jasper</param>
                <param name="dataSource">myList</param>
                <param name="format">PDF</param>
            </result>
        </action>
       
        <!-- Reports-END -->

可以通过url:http://localhost:8080/项目名/myJasperTest.html访问到该报表。WW提供了很好,很优雅的处理JasperReport文件解决方案;指定.jasper文件的位置,指定使用的数据源dataSource,然后她就可以工作了。

[1]  [2]  [3]  
相关文章