Reputation: 45
Because I have used JXL api
for excel but now I want to convert it to Pdf file so please tell me how to change my code to convert excel
to pdf
?
Upvotes: 3
Views: 20568
Reputation: 1688
You could use iText to create a pdf file in java and use Apache POI to access the data in the MS-EXCEL file. If you combine both, you could convert your excel file.
A raw example is given here
Also, there is this new API: You can try Aspose.Cells for Java which allows you to convert Excel file to PDF in Java applications. It doesn't require MS Office/OpenOffice etc to be installed on your development or deployment machine. It also works on both Windows and Linux platforms. The code is very simple as shown 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: 4