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

Free Support Forum - aspose.com

Aspose.Cells throws exception when input filename is not abosolute path

Hi,

I am using the following simple java program to convert from html to excel:

import com.aspose.cells.License;
import com.aspose.cells.HTMLLoadOptions;
import com.aspose.cells.LoadFormat;
import com.aspose.cells.SaveFormat;
import com.aspose.cells.Workbook;

public class asposeConvert {

public static void main(String[] args) {

License license = new License();
license.setLicense("Aspose.Cells.lic");

if ( !License.isLicenseSet()) {
System.err.println("License is not set");
} else {
Workbook book;
int format = SaveFormat.XLSX;

WorkBook book = new Workbook(args[0]);
book.save(args[1], format);
}
}

}

If the input filename is a relative path like

java -classpath "aspose-cells-8.6.1.6.jar:." asposeConvert Test1.html Test1.xlsx

the program throws exception like the following:

ava.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1954)
at com.aspose.cells.zafc.b(Unknown Source)
at com.aspose.cells.zafc.a(Unknown Source)
at com.aspose.cells.zafi.o(Unknown Source)
at com.aspose.cells.zafi.l(Unknown Source)
at com.aspose.cells.zafj.a(Unknown Source)
at com.aspose.cells.zafj.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)
at asposeConvert.main(asposeConvert.java:20)

If I use a fullpath name, like,

java -classpath "aspose-cells-8.6.1.6.jar:." asposeConvert /data/fullpath/Test1.html Test1.xlsx

then the java program runs fine.

-fastPitch

Hi,


Thanks for your query.

This is not an issue with the product. Aspose.Cells needs valid file path as it uses Java.IO APIs on the back end. You may even test and confirm the issue, you may read the file by using Java.IO APIs only and excluding Aspose.Cells APIs and you will get similar behavior. By the way, where is your class/Java file, it looks like it is not in the “…asposeConvert /data/fullpath/Test1.html”, so you have to provide full path to access the file.

Thank you.