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.
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).
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.
It's different in each case.
Excel: use JExcelAPI or Apache POI;
PDF: use iText;
Word: Apache POI again.
As for creating reports, I would instead use a dedicated reporting tool, specifically Jasper Reports.
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.
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
If your spreadsheet is very simple then exporting as CSV is acceptable; its quick and easy to code.
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.
Related
I want to edit html pages using java. is it possible. ( it is required for my project, if I automate the test cases using selenium when it passes then the result comes in the company provided HTML sheet)
If you use JavaFX as GUI you can use its built in HTML editor.
Well there are a lot of differnt ways to edit html.
If you want to parse HTML code and manipulate it, http://jsoup.org/ is a very good solution.
is it possible to fill a predefined template file via birt reporting?
.xls for exmaple: The template should have defined the column headers (nicly formatted) and some other stuff like the date of creation, the user, some legal notice, ...
.pdf on the other hand should define id-fields that are to be filled with data
.ppt as the last and may be trickiest one should ideally be also be useable as .pdf but as far as I know .ppt itself does not provide IDs for its fields and therefore a workaround must be used to identify the places to be filled
Are there alternatives to birt that might be able to do that?
I'm very curious about the answers :-)
Thanks a lot!
Templater supports docx and xlsx. From there we are generating PDFs using LibreOffice.
Being author of the tool, I highly recommend it :)
There are plenty of examples on site if you are interested.
It could be very challenging to hit a predifined Excle format with the native BIRT Excel emitter, there are several after market Excel emitters that might help you get there.
The easier way is to set up your BIRT report to export with the format you want, then save report and use it as foundation for recreating the next report. You can use grids, and master pages to get just the layout you want, then plug in report pieces.
You can also use the library to save grids, tables & data sets that you use over and over.
The Spudsoft XLS Emitter for BIRT (which is builtin with BIRT 4.3.1) supports this for XLS.
We are using this feature and it works like a charm.
However, BIRT does not support "filling" doc or ppt docs.
Templating engines usually have difficulties to support master-detail (or master-detail-detail) relationships. This is due to the somewhat stupid implementation of tables in MS Word.
How can I merge individual selected PDF files into one PDF upon download?
I want to achieve the following:
http://annualreport2010.landsecurities.com/create-your-own-report.aspx
Do I require an ASP website, or could I do something similar using a static HTML site?
Static HTML won't do it.
You need something on the server side. The other answers have options that would work, I just wanted to also mention pdftk, which you could then call from the server side. Be sure to escape all file names and such, though, because you would have to use system calls.
pdftk is really easy. The very first example from their documentation shows how to merge several PDFs, named 1.pdf, 2.pdf and 3.pdf, into one PDF called 123.pdf:
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
For PHP, there even is pdftk-php, if you want to look into that.
I think that the Apache PDFBox project can be good for you.
In particular, take a look at the PDFMerger class.
You can also use iText but in my opinion it's less easy to use.
See if itext can help in merging. A quick search gives many links - like Java: Merging multiple PDFs into a single PDF using iText.
There is a Java PDF merging software at http://codesforus.blogspot.com/.
p.s. They link to this download page: http://messiahpsychoanalyst.org/Documents/Downloads.html#part1
You can find Source code for PDF split and Merge Source forge PDF SAM
Is there any way to create PDF dynamically against receiving texts and images?
You can use the iText library.
If you're generating reports then JasperReports can generate PDF output.
iText and JasperReports are great to create pdf reports via Java.
With iReport you can easily create the jasper files needed for this. Very easy to use tool and helped me a lot when I needed to create some pdf reports.
We use Flying Saucer.
There are several libraries for working with PDF in Java, for example iText and Apache PDFBox.
There's a ton of ways to generate PDFs on the fly.
In Java, you can use the iText library. If you wanted to use Jython, you could use reStructuredText and possibly rst2pdf. Or you could just generate LaTeX files on the fly and make a system call to LaTeX.
A bit late but maybe useful to other searchers. Docmosis can populate templates and produce documents on the fly. Assuming you mean you need to include images and text, Docmosis can populate these on the fly from Java objects, text/image files, database queries etc. Java and Openoffice are required server-side.
I work with Apache FOP and it works amazingly well. It's well supported and it's based on the XSL-FO standard.
If you're doing reports based on for example SQL queries then iReport is a good choice although it's sometimes a bit heavyweight. On the other hand if you're going to produce something that's more about presentation and design, like a product sheet or a brochure then my experience is that it's alot easier to first generate html and css and then use it to generate a PDF.
Web app I'm working on generates HTML using Velocity templates. Problem is that using whitespace in velocity templates and other formatting results in butt-ugly HTML (excessive whitespace, misalignment, etc.)
Looking for a nice (single jar packaging would be nice) Java-based HTML prettifier to run over the generated HTML right before we dump it to the servlet response to make the source nicer to look at.
Third party integrators would like to be able to glance at the HTML and know which templates are causing problems. The first step to this is having the HTML formatted nicely.
Thanks in advance for any guidance you can provide!
JTidy has a JTidyFilter. Just define it in web.xml and the respone HTML will be prettified.
JTidy could be what you're searching for.
I know it's not helping right now, but I think the ideal solution would be for Velocity in first place to support a "better whitespace generation and control" :).
If many users would request and vote such a feature, maybe the Velocity team would include it. Running jTidy or other parsers over the output all the time (e.g. for live requests) consumes quite a few resources, so I'm not sure if it's the best approach especially for dynamic content where caching of that cleaned output doesn't bring much.
There are many HTML parsers here: Open Source HTML Parsers in Java