- Code: Select all
import com.spire.xls.*;
public class toPDF {
public static void main(String[] args) {
String inputFile = "data/ExcelSampleN.xlsx";
String outputFile = "output/ToPDF_out.pdf";
//Create a workbook
Workbook workbook = new Workbook();
try
{
//Load a file
workbook.loadFromFile(inputFile);
//Fit to page
workbook.getConverterSetting().setSheetFitToPage(true);
//Save to PDF file
workbook.saveToFile(outputFile, FileFormat.PDF);
}finally {
workbook.dispose();
}
}
}
with jdk-17.0.2 (Open jdk)
I get the error bellow. The excel converter only works with sun jdk (oracle) ? if yes we have a problem of jdk license,
I ask because if I run with jdk 1.8 for example its works
Exception in thread "main" java.lang.IllegalAccessError: class com.spire.office.packages.sprjhi (in unnamed module @0x15ff3e9e) cannot access class sun.security.action.GetPropertyAction (in module java.base) because module java.base does not export sun.security.action to unnamed module @0x15ff3e9e
at com.spire.office.packages.sprjhi.spr▥┩(Unknown Source)
at com.spire.office.packages.sprjhi.spr┿┑(Unknown Source)
at com.spire.office.packages.sprjhi.<init>(Unknown Source)
at com.spire.office.packages.sprxgg.<init>(Unknown Source)
at com.spire.office.packages.sprzfg.<init>(Unknown Source)
at com.spire.xls.core.spreadsheet.XlsWorkbook.<init>(Unknown Source)
at com.spire.xls.Workbook.<init>(Unknown Source)
at br.com.siq.xlsToPDF.main(xlsToPDF.java:14)