In your projects you may need to convert XLS files to PDF . The presentation below will try to guide you how to do it.
XLS to PDF with Java :
You can use OpenOffice.org(must be available on the same computer or in your network) for document conversion.
Besides XLS to PDF ,there are also possible other conversions:
doc-->pdf,html,txt,rtf
xls-->pdf,html,csv
ppt-->pdf,swf
html-->pdf
There is a project ,POI to read and write DOC and XLS files with Java . There is also an existing package ,iText to write new_PDFs with java. You could use POI to read your DOC and XLS files into a Java program ,extracting the relevant pieces of text,then writing them out again in PDF format.
Code example:
import officetools.OfficeFile;
.....
FileInputStream fis = new FileInputStream(new File("testing.xls"));
FileOutputStream fos = new FileOutputStream(new File("testing.pdf"));
//suppose OpenOffice.org runs on localhost. port 8800
OfficeFile f = new OfficeFile(fis,"localhost","8800",false);
f.convert(fos,"pdf");
.....
The above is a small example just to illustrate the way you can use the code to convert XLS to PDF using Java .
XLS to PDF with Java :
You can use OpenOffice.org(must be available on the same computer or in your network) for document conversion.
Besides XLS to PDF ,there are also possible other conversions:
doc-->pdf,html,txt,rtf
xls-->pdf,html,csv
ppt-->pdf,swf
html-->pdf
There is a project ,POI to read and write DOC and XLS files with Java . There is also an existing package ,iText to write new_PDFs with java. You could use POI to read your DOC and XLS files into a Java program ,extracting the relevant pieces of text,then writing them out again in PDF format.
Code example:
import officetools.OfficeFile;
.....
FileInputStream fis = new FileInputStream(new File("testing.xls"));
FileOutputStream fos = new FileOutputStream(new File("testing.pdf"));
//suppose OpenOffice.org runs on localhost. port 8800
OfficeFile f = new OfficeFile(fis,"localhost","8800",false);
f.convert(fos,"pdf");
.....
The above is a small example just to illustrate the way you can use the code to convert XLS to PDF using Java .
1 comment:
Hi,
Can you please help with the officetools.jar
Kindly email to rameshs24@gmail.com
Thanks & Regards,
S Ramesh
Post a Comment