MS Excel 2003 xls to pdf conversion

Hello Aspose,

I’m evaluating aspose-cells-7.2.0.jar.

I’m trying to convert a MS 2003 xls to pdf format but I’m facing the following error during conversion:

Exception in thread “main” com.aspose.cells.CellsException: End of file reached.
at com.aspose.cells.yC.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at AsposeXLS.main(AsposeXLS.java:26)

Here’s the relevant java code:

Workbook workbook = new Workbook(“c:\temp\aspose\Book1.xls”);
workbook.save(“c:\temp\aspose\Book1.pdf”);

Please see the attached xls file.
Could you help with this problem?

Hi,


Thank you for using Aspose.Cells for Java

Please have a look at the following line of code to save an Excel file as PDF:

Workbook workbook = new Workbook(“E://book1.xls”);
workbook.save(“E://out.pdf”, SaveFormat.PDF);

I have used Aspose.Cells for Java Version 7.2.0 and it is working fine. I hope you have added all the jar files, found in the lib folder, to your java project.

You can also find the Aspose.Cells for Java documentation online by clicking this link .

Thanks & Best Regards,

Hello,

I tried:

import com.aspose.words.*;
import com.aspose.cells.Workbook;

public class AsposeXLS
{
public static void main(String[] args)
throws Exception
{
Workbook workbook = new Workbook(“C://temp//book1.xls”);
workbook.save(“C://temp//out.pdf”, SaveFormat.PDF);
}
}

but I’m getting the following:

Exception in thread “main” java.lang.IllegalStateException: End of file reached.
at java.lang.Throwable.(Throwable.java:67)
at com.aspose.cells.b.a.d.a.a(Unknown Source)
at com.aspose.cells.b.a.d.a.q(Unknown Source)
at com.aspose.cells.a.d.v.b(Unknown Source)
at com.aspose.cells.a.d.co.c(Unknown Source)
at com.aspose.cells.a.d.co.g(Unknown Source)
at com.aspose.cells.a.d.co.p(Unknown Source)
at com.aspose.cells.a.d.co.(Unknown Source)
at com.aspose.cells.rd.a(Unknown Source)
at com.aspose.cells.Worksheet.autoFitRow(Unknown Source)
at com.aspose.cells.lY.a(Unknown Source)
at com.aspose.cells.gr.a(Unknown Source)
at com.aspose.cells.gr.C(Unknown Source)
at com.aspose.cells.gr.a(Unknown Source)
at com.aspose.cells.gq.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at AsposeXLS.main(AsposeXLS.java:29)

Please note also that I’m using IBM JDK 1.6 (since the target application server is WebSphere v7).
java version "1.6.0"
Java™ SE Runtime Environment (build pwi3260sr5ifix-20090623_01(SR5+151659+151951+151086+151619+151750+152177+152017+1
52507))
IBM J9 VM (build 2.4, J2RE 1.6.0 IBM J9 2.4 Windows XP x86-32 jvmwi3260sr5ifx-20090612_37149 (JIT enabled, AOT enabled)
J9VM - 20090612_037149_lHdSMr
JIT - r9_20090518_2017
GC - 20090417_AA)
JCL - 20090623_01

Please note that I succesfully tested Aspose.Words to convert DOC to PDF on my environment.
Problem happens only when using Aspose.Cells


Do you have any ideas?

Hi,


Have you added the following jar files to your project?

- aspose-cells-7.2.0.jar
- bcprov-jdk16-146.jar
- dom4j-1.6.1.jar
- stax2-api-3.0.2.jar
- woodstox-core-asl-4.1.1…jar

You can find these in \aspose-cells-7.2.0-java\JDK 1.6\lib folder. I have used NetBeans IDE 7.0.1 to write the following code and it is working fine:

import com.aspose.cells.*;
public class App1 {

public static void main(String[] args) {
// TODO code application logic here
try
{
Workbook workbook = new Workbook(“E://book1.xls”);
workbook.save(“E://out.pdf”, SaveFormat.PDF);
}
catch(Exception e)
{}
}
}

Please let us know if we can be of any additional help to you.

Thank you for using Aspose.Cells

Hello,

to exclude the JVM version I downloaded SUN JDK and made a test from outside Eclipse.
I tested everything from the command line.
I attached the full content of my test directory along with the batch file I use to compile and run the program. Aspose packages are included too. Here’s my output:


CLASSPATH
.;C:\Aspose\aspose-cells-7.2.0.jar;C:\Aspose\Aspose.Words.jdk16.jar;C:\Aspose\bcprov-jdk16-146.jar;C:\Aspose\dom4j-1.6.1
.jar;C:\Aspose\stax2-api-3.0.2.jar;C:\Aspose\woodstox-core-asl-4.1.1.jar

javac -version
javac 1.6.0_32

java -version
java version "1.6.0_32"
Java™ SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot™ Client VM (build 20.7-b02, mixed mode, sharing)
com.aspose.cells.CellsException: End of file reached.
at com.aspose.cells.yC.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at AsposeXLS.main(AsposeXLS.java:11)

Could you perform the same test on your machine from the command line?
Please see the attached archive.
Thx.

Hello,

there must be something strange on my Windows machine.
I tried the code on the target Linux machine and it works.

Please close the issue.

Hello,


I think its something related to the path of java at your windows system. At my pc, i used the following commands to compile and execute the java file (I kept all your files in D:/Aspose folder) and it compiled and executed all very fine:

Compile Command:
javac.exe -encoding utf8 -d “D:\Aspose\classes” -sourcepath “D:\Aspose”; -classpath “D:\Aspose\classes”;“D:\Aspose\aspose-cells-7.2.0.jar”;“D:\Aspose\bcprov-jdk16-146.jar”;“D:\Aspose\dom4j-1.6.1.jar”;“D
:\Aspose\stax2-api-3.0.2.jar”;“D:\Aspose\woodstox-core-asl-4.1.1.jar”;“C:\Program Files\Java\jdk1.6.0_25\jre\lib\rt.jar”; D:\Aspose\AsposeXLS.java

Execution Command:
java -classpath “D:\Aspose\classes”;“D:\Aspose\aspose-cells-7.2.0.jar”;“D:\Aspose\bcprov-jdk16-146.jar”;“D:\Aspose\dom4j-1.6.1.jar”;“D:\Aspose\stax2-api-3.0.2.jar”;“D:\Aspose\woodstox-core-asl-4.1.1.jar
”;“C:\Program Files\Java\jdk1.6.0_25\jre\lib\rt.jar”; AsposeXLS

Thanks and Best Regards