We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Xls and xml conversion to PDF using Aspose Cells


Can you please help me with the right way to convert xsl and xml files to PDF.

I have used the following approach but it doesnot work.

For xml:

Pdf pdf = new Pdf();

pdf = Pdf.bindXML(new FileInputStream(fileName));

//Filename is the name of the xsl file

//Create the PDF document by calling its save method

pdf.save(new FileOutputStream(fileName.substring(0,


+ "\\" + fileName.substring(fileName.lastIndexOf("\\")+1,fileName.lastIndexOf('.')) + ".pdf"));

and for xsl: Dont know what to do...

This message was posted using Page2Forum from Aspose.Cells for Java - Documentation


Please see the following documentation link for XLS2PDF conversion. It contains the latest code and details for XLS2PDF conversion which you may try as per your scenario.


Thank You & Best Regards,


Thanks for your response. I tried the same. But i get the following exception.

com.aspose.pdf.exception.AsposeBaseException: null

at com.aspose.pdf.elements.Section.a(Unknown Source)

at com.aspose.pdf.elements.Pdf.if(Unknown Source)

at com.aspose.pdf.elements.Pdf.a(Unknown Source)

at com.aspose.pdf.elements.Pdf.save(Unknown Source)

at com.unica.ConvertXLSToPDF.convert(ConvertXLSToPDF.java:33)

at com.unica.SampleController.main(SampleController.java:21)

The conversion code is as follows:

public boolean convert(String fileName){

//Instantiate the Workbook object

Workbook workbook = new Workbook();

try {


workbook.save("C:\\Aspose\\Aspose_Input\\sheet.xml", FileFormatType.ASPOSE_PDF);

Pdf pdf = new Pdf();

pdf = Pdf.bindXML(new FileInputStream("C:\\Aspose\\Aspose_Input\\sheet.xml"));

pdf.save(new FileOutputStream("C:\\Aspose\\Aspose_Input\\sheet.pdf"));

}catch (Exception e) {


return false;


return true;


Also PFA the xls file that i am trying to convert to PDF.


Which version of Aspose.Pdf for Java you are using? Please try latest version for Aspose.Pdf for Java v2.5 as the API structures is changed a bit in it. I am using Aspose.Cells for Java v2.1.2.x and Aspose.Pdf for Java v2.5 and it works fine.

Here is my sample code, kindly check it (see the package import section too). I have also attached my output pdf file here when running sample code with you excel file.

Sample Program:

import java.io.;
import com.aspose.cells.
import aspose.pdf.*;

public class Pdf1 {

public static void main(String[] args) throws Exception

//Instantiate the Workbook object
Workbook workbook = new Workbook();
//Save the document in Aspose.Pdf.Xml format
workbook.save(“d:\files\Mail_Format.xml”, FileFormatType.ASPOSE_PDF);
//Bind the XML file (containing spreadsheet data) with the Pdf object
Pdf pdf = new Pdf();
pdf.bindXML(“d:\files\Mail_Format.xml”, null);
//Create the PDF document by calling its save method



Kindly let us know if you still find any issue.

Thank you.