Aspose Cells exception while converting XLS files

Hi,
I am getting exception while converting few excel files.
I have tried both the jars Aspose Cells 23.1 & 23.2.

@rutuja.mahajan,

I did test your scenario/case using our latest version/fix: Aspose.Cells for Java v23.2 to convert both your files to PDF, it works fine and the output PDFs are fine tuned. Here is the sample code that I am using;
e.g.
Sample code:

Workbook workbook1 = new Workbook("f:\\files\\PRV-MM-TQ-00015.xls");
workbook1.save("f:\\files\\out1.pdf");

Workbook workbook2 = new Workbook("f:\\files\\PRV-MM-TQ-00019.xls");
workbook2.save("f:\\files\\out2.pdf");

Please find attached the output PDFs for your reference.
out1.pdf (99.5 KB)
out2.pdf (275.9 KB)

Could you please share your sample code segment that you are using. Also, give us your environment (OS, JDK version, CPU, RAM, etc.) details.

Hi,
I am using Windows 10 and JDK 1.8
This is my sample code,
String[] fontFolders = {asposeFontDir};
FontConfigs.setFontFolders(fontFolders, true);

	  Workbook workbook = new Workbook(inputFile);
	  
	  WorksheetCollection col = workbook.getWorksheets();
	  PdfSaveOptions opt = new PdfSaveOptions();
	  opt.setOnePagePerSheet(true);
	  opt.setWarningCallback(new AsposeCellsCallback());
	  for (int i=0; i<col.getCount(); i++) {
		  Worksheet sheet = workbook.getWorksheets().get(i); 
		  sheet.autoFitRows(true);
	  }
	  OutputStream outStream = new ByteArrayOutputStream();
	  workbook.save(outStream, opt);

@rutuja.mahajan

No exception occurs with your code on our side. Please share us a runnable code to reproduce the issue(e.g. the implement of AsposeCellsCallback in your code.)

Also, share us the exception stack info on your side.

Here is source code with callback implementation SourceCode.zip (833 Bytes)

Not getting any callback warning in logs, just getting this exception " java.lang.Exception"

@rutuja.mahajan

We are not getting exceptions for your two source files with your code.
Please share us which version of Aspose.Cells you are using, and share us the full exception stack info.

Hi,
I am using Aspose Cells 23.3
Not getting any other exceptions except ‘java.lang.expection’

@rutuja.mahajan

You got exception java.lang.Exception for the two files with Aspose.Cells 23.3? If yes, please share us the full exception stack info.

Hi,
I have tried resaving the file to latest xlsx version,
also disabled all the macros from trust center, still getting same exception.

Aspose Cells Version: 23.3.0 (this is printed through CellsHelper.getVersion())
com.aspose.cells.CellsException
at com.aspose.cells.g6w.a(Unknown Source)
at com.aspose.cells.b6p.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)

@rutuja.mahajan,

Thank you for the detail of the exception. We will investigate further and provide feedback soon.

@rutuja.mahajan

It turns out that the exception occurs in your code AsposeCellsCallback:

public class AsposeCellsCallback implements IWarningCallback{
	private static final Log LOG = LogFactory.getLog(AsposePDFConvertorAppService.class);
	
	@Override
	public void warning(WarningInfo info) {
		LOG.error("Aspose Cells >> Error Object: "+info.getErrorObject().toString()+ " Corrected Object: "+ info.getCorrectedObject()
				+ " Warning Type: "+info.getWarningType() + " Description: "+info.getDescription());
	}
}

info.getErrorObject().toString() will throw exception in case that info.getErrorObject() is null.
Please change info.getErrorObject().toString() to info.getErrorObject().

1 Like

Thanks a lot, this is resolved. We can close this topic.

@rutuja.mahajan,
I’m glad your issue has been solved. If you have any questions, please feel free to contact us.

1 Like