user93796
user93796

Reputation: 18389

Exporting jsp tables to excel, word, pdf

Can anyone suggest me any library/jar files which I can use to export my table to excel/pdf/word.

Please tell me if there is any library by which I can create reports in jsp.

Upvotes: 6

Views: 23322

Answers (7)

user18943
user18943

Reputation: 747

If you'r working with JSP's you can try using displaytag library which gives you export to all (pdf, excel, csv, xml). You can also customize them or override exporters if you want.

Just take a look at this url http://displaytag.sourceforge.net/10/export.html

Upvotes: 1

Paul Jowett
Paul Jowett

Reputation: 6581

Docmosis and JODReports can produce PDF and DOC from the server side (JSPs, servlets, J2EE etc). Docmosis provides formatting/layout in a template so you have less coding to do and possibly even have non-developers maintaining the report look and feel. Both are free.

Upvotes: 0

Jonik
Jonik

Reputation: 81802

It should also be mentioned that you can export tables to Excel simply by outputting an HTML table, and setting response-type to application/vnd.ms-excel. No external libraries whatsoever needed.

Something like this:

<%@ page language="java" session="true" %>
<%@ taglib uri="/WEB-INF/tld/response.tld" prefix="res" %>
<res:setHeader name="Content-Type">application/vnd.ms-excel</res:setHeader>
<res:setHeader name="Content-Disposition">attachment; filename=excel-test.xls</res:setHeader>

<table>
    <tr>
        <td>foo</td>
        <td>bar</td>
    </tr>
</table>

Note: this answer is meant to supplement this and this as it covers only one of the cases (Excel).

Upvotes: 8

jb.
jb.

Reputation: 23995

I think that itext is still better for report creation, it is more straightforward, i had some (less than enough) experience with Jasper Reports, and it seemed clumsy. OTOH itext is very easy to use for developer, and we had pretty big reports done with it, without problems.

You may even create rtf's (readable by Word) from itext.

Upvotes: 1

Robert Campbell
Robert Campbell

Reputation: 6958

I'd say JasperReports - which is open source - is your best bet. It would allow you to code the report once, but export it to the various formats you need. It even supports direct streaming of HTML to the browser, so it really is a code-once, use anywhere type thing. It can also scale up nicely via JasperServer.

Upvotes: 4

Fortyrunner
Fortyrunner

Reputation: 12792

If your spreadsheet is very simple then exporting as CSV is acceptable; its quick and easy to code.

Upvotes: 0

cletus
cletus

Reputation: 625327

It's different in each case.

As for creating reports, I would instead use a dedicated reporting tool, specifically Jasper Reports.

Upvotes: 2

Related Questions