3

Apaches POI has a ExcelToFoConverter class that allows to convert xls files to XSL-FO. Since I use XLSX files, I am worried that I will have data loss when I use this converter. POI does not offer an explicit converter for xlsx files. However, I saw that someone used the ExcelToFoConverter for xlsx files.

  1. Can I just use the mentioned converter class for xlsx files?
  2. If I can't, what are other options?
  3. Or is there a much better solution for converting XLST files to PDF without(!) having a program like LibreOffice or OpenOffice on the server?
yemerra
  • 1,352
  • 4
  • 19
  • 44

3 Answers3

2

If you can get from XLSX > HTML:

https://poi.apache.org/apidocs/org/apache/poi/hssf/converter/ExcelToHtmlConverter.html

http://allstarnix.blogspot.co.uk/2013/05/use-java-to-convert-excel-to-html.html

then you can use easily get from HTML > PDF using FlyingSaucer.

https://github.com/flyingsaucerproject/flyingsaucer

Commercial solutions would include Aspose Cells for Java:

http://www.aspose.com/java/excel-component.aspx

Alan Hay
  • 22,665
  • 4
  • 56
  • 110
  • XSL-FO has limitations (read wiki page). It is better off to use CSS3-paged (html) as Alan points – Yoi Jun 28 '16 at 06:23
  • Thank you for the hint regarding FlyingSaucer. I Just gave it a try and it works pretty well. – Sky Sep 30 '16 at 13:06
  • 2
    According to javadoc of class ExcelToHtmlConverter: "Converts xls files (97-2007) to HTML file". So, ExcelToHtmlConverter can not convert xlsx files to html. – Jackson Cassimiro Jan 31 '19 at 13:00
0

For option 3 I have used iText to create PDF files. See the answers to this question for more info.

Community
  • 1
  • 1
ozOli
  • 1,414
  • 1
  • 18
  • 26
0

I wrote an xsl sometime ago that did Excel XML format conversion to XSL FO. It is available in the Cool tools section of the RenderX website.

http://www.renderx.com/files/demos/cooltools/Excel2FO.zip

Kevin Brown
  • 8,805
  • 2
  • 20
  • 38