Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java API to convert from Excel to PDF?

 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need a Java API where I can feed an existing Excel spreadsheet file to a method and have it create a PDF version. The Excel was generated using POI.

I looked at a few commercial API's., most notable Adobe. But Adobe appears to use a Session Bean, which I cannot use since no EJB server is available in my environment. I need a plain POJO implementation, not calling any outside service.

I also looked at iText. They talk about converting from PDF to Excel, but not the other way around. Maybe it does, but I can�t find any reference to it.

Any ideas?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of any library that does this, apart from OpenOffice - it can open XLS files, create PDF files, and has a Java API that you could use to drive this process. That has a steep learning curve, though.

I'd probably create the PDF at the same as the XLS file, using the iText API. Or, if it's not feasible to do it at the same time, use POI to open it later, and then use iText to create the PDF.

(By the way, can you point to where the iText docs talk about PDF-to-XLS conversion? I'd be interested in that.)
 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw it on a forum, but now I can't find it. But I do remember people suggesting using Apache POI rather than iText to generate Excel.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, OK. I've used iText extensively, and have never encountered anything that suggests it might be useful for creating XLS files.
 
zett ucu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a team in my comp is using this on a project:

import officetools.OfficeFile;
...
FileInputStream fis = new FileInputStream(new File("test.xls"));
FileOutputStream fos = new FileOutputStream(new File("test.pdf"));
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");

All possible convertions:
xls --> pdf, html, csv
doc --> pdf, html, txt, rtf
ppt --> pdf, swf
html --> pdf
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also check out the JODConverter library (which uses OpenOffice behind the scenes).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic