Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

javascript - How to export table displayed on jsp to pdf in java strust2

This is my data display in table format. I want to show as it is in PDF without using display tag library of struts2.

<table border="1" align="center" style="border-color: #CCCCCC; border-width: 1px; border-style: None; width: 1320px; border-collapse: collapse;" id="tablepaging">
    <tbody>
        <tr>
            <td>Leave ID</td>
            <td>FROM DATE</td>
            <td>TO DATE</td>
            <td>DAYS REQUESTED</td>
            <td>APPROVER</td>
            <td>NOTES</td>
            <td>REMARK</td>
            <td>IS PLANNED</td>
            <td>REASON</td>
        </tr>
        <tr>
            <td>270</td>
            <td>12/27/12</td>
            <td>12/29/12</td>
            <td>2</td>
            <td>Sagar</td>
            <td>s</td>
            <td>s</td>
            <td>true</td>
            <td>s</td>
            <td>
                <a href="/HRIS_Updated/cancelRequest.action;jsessionid=A2313340A50DD2DAB054714BF65AB08B?leaveId=270" id="submitinvoice;jsessionid=A2313340A50DD2DAB054714BF65AB08B_">Cancel</a>
            </td>
            <td>
                <a href="/HRIS_Updated/requestHistory.action;jsessionid=A2313340A50DD2DAB054714BF65AB08B?leaveId=270" id="submitinvoice;jsessionid=A2313340A50DD2DAB054714BF65AB08B_">History</a>
            </td>
        </tr>
    </tbody>
</table>

Is it be possible with javascript or jquery?

Please help me with some code I have googled it for a few days but get nothing.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As far as i know unfortunately javascript cannot create pdf files by itself. And i haven't use struts yet. But I recommend you Displaytag library which is very easy to use :)

This is what you need particularly (with code) : http://displaytag.sourceforge.net/10/export.html

documentation (from beginning to end) : http://displaytag.sourceforge.net/10/displaytag.pdf


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...