将jsp表导出到excel、word、pdf

发布于 2024-07-19 14:09:22 字数 93 浏览 5 评论 0原文

任何人都可以建议我任何库/jar 文件,我可以使用它们将我的表导出到 excel/pdf/word。

请告诉我是否有任何可以在 jsp 中创建报告的库。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

夜巴黎 2024-07-26 14:09:22

还应该提到的是,您只需输出 HTML 表格并将响应类型设置为 application/vnd.ms-excel 即可将表格导出到 Excel。 不需要任何外部库。

像这样的东西:

<%@ 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>

注意:这个答案旨在补充这个这个 因为它仅涵盖其中一种情况(Excel)。

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).

许你一世情深 2024-07-26 14:09:22

每种情况都不同。

至于创建报告,我会使用专用的报告工具,特别是 Jasper Reports。

It's different in each case.

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

浮云落日 2024-07-26 14:09:22

我认为 itext 仍然更适合创建报告,它更直接,我对 Jasper Reports 有一些(不够)的经验,而且它看起来很笨拙。 OTOH itext 对于开发人员来说非常易于使用,我们用它完成了相当大的报告,没有出现任何问题。

您甚至可以从 itext 创建 rtf(可由 Word 读取)。

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.

清欢 2024-07-26 14:09:22

如果您使用 JSP,您可以尝试使用 displaytag 库,它可以导出所有内容(pdf、excel、csv、xml)。 如果需要,您还可以自定义它们或覆盖导出器。

看看这个网址 http://displaytag.sourceforge.net/10/export.html

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

眼前雾蒙蒙 2024-07-26 14:09:22

如果您的电子表格非常简单,那么导出为 CSV 是可以接受的; 其编码快速且简单。

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

诗笺 2024-07-26 14:09:22

DocmosisJODReports 可以从服务器端(JSP、servlet、J2EE 等)生成 PDF 和 DOC。 Docmosis 在模板中提供格式/布局,因此您需要编写的代码更少,甚至可能需要非开发人员维护报告的外观和感觉。 两者都是免费的。

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.

︶ ̄淡然 2024-07-26 14:09:22

我会说 JasperReports - 这是 开源 - 是您最好的选择。 它允许您对报告进行一次编码,然后将其导出为您需要的各种格式。 它甚至支持将 HTML 直接流式传输到浏览器,因此它确实是一次编码、随处使用的类型。 它还可以通过 JasperServer 很好地扩展。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文