Hi,
When I was working with Aspose cells 7.0.0, I came across a weird behavior when I use Worksheet.autoFitColumns() which throws java.awt.HeadlessException
"Exception in thread “main” java.awt.HeadlessExceptionBut, this happens only when I create multiple workbook in the same JVM context and if the “java.awt.headless” system property is set to “true”. otherwise this issue doesn’t occur.
at sun.awt.HeadlessToolkit.getScreenResolution(HeadlessToolkit.java:189)"
when “java.awt.headless” is set to true
If Worksheet.autoFitColumns() is used and when one workbook is created, it works fine
If Worksheet.autoFitColumns() is used and when multiple workbook is created, it fails
In either of the other case [set java.awt.headless - false or comment Worksheet.autoFitColumns()], creating multiple workbook works properly.
System.setProperty(“java.awt.headless”, “true”);
int MAX_BOOKS = 2;
for (int i = 0; i < MAX_BOOKS; i++) {
System.out.println("Creating workbook " + (i + 1));
Workbook workbook = new Workbook();
Worksheet dataSheet = workbook.getWorksheets().add(“Data”);
Cells cells = dataSheet.getCells();
cells.get(“A1”).setValue(“Column 1”);
cells.get(“B1”).setValue(“Column 2”);
cells.get(“A2”).setValue(“Column 3”);
dataSheet.autoFitColumns();
workbook.save(“Test” + i + “.xls”);
System.out.println(“workbook " + (i + 1) + " Created”);
}
I have attached the java code along with this.
Is this a known issue? What alternate can be used for this issue to get resolved, when java.awt.headless is set to true.
Regards
Sundhar
Aspose OEM License Holder