user2950329
user2950329

Reputation: 55

Java save xls file as PDF

I have a simple java program that creates .xls file (open office excel file), and I want to save it as pdf. I saw some answers here but none of them worked for me. Is there a simple and free way to do so? The file contains only 1 page of .xls

Thanks

Upvotes: 0

Views: 10281

Answers (2)

Abdel Wadoud
Abdel Wadoud

Reputation: 19

I have published a library that saves files, and handles everything with one line of code only, you can find it here along with its documentation

Github repository

and the answer to your question is so easy

String path = FileSaver
        .get()
        .save(fileXls,"file.pdf");

Upvotes: 0

mhasan
mhasan

Reputation: 3709

Not sure, please provide more details , share code so that the answer can be more precise, but for code perspective it can be achieved via Apache POI.something like below ....

 //Instantiate a new workbook with excel file path
Workbook workbook = new Workbook("F:\\FileTemp\\Book1.xls");

//Save the document in Pdf format
workbook.save("F:\\FileTemp\\MyPdfFile.pdf", FileFormatType.PDF);

Upvotes: 3

Related Questions