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

Free Support Forum - aspose.com

"CellsException: Shape to image Error" when saving special Xlsx but worked in 18.4

Hi everybody,

here we have a xlsx witch causes an error in aspose.cells when converting to PDF.

This worked in 18.4 but now in 19.1 it comes to the error.

Here the code to reproduce it:

import com.aspose.cells.PdfSaveOptions;
import com.aspose.cells.SaveOptions;
import com.aspose.cells.Workbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.UUID;

public class Main {

    private final ClassLoader classLoader = getClass().getClassLoader();

    private final File tmpFolder = new File(System.getProperty("java.io.tmpdir"));

    public static void main(String[] args) {

        try {
            System.out.println("Convert xlsx to PDF");
            new Main().createsPdfFromXlsx_onlyConvertToPdf();
            System.out.println("Success");

        } catch (Exception e) {
            System.out.println("Failed to convert xlsx to PDF ");
            e.printStackTrace();
        }
    }

    /**
     * This error does NOT occur with aspose.cells 18.4
     * 18.8, 19.1 and 19.2 tested - all causing an exception
     *
     * com.aspose.cells.CellsException: Shape to image Error!
     * 	at com.aspose.cells.zax.a(Unknown Source)
     * 	at com.aspose.cells.zax.a(Unknown Source)
     * 	at com.aspose.cells.zax.a(Unknown Source)
     * 	at com.aspose.cells.zax.a(Unknown Source)
     * 	at com.aspose.cells.zax.b(Unknown Source)
     * 	at com.aspose.cells.zax.c(Unknown Source)
     * 	at com.aspose.cells.zax.a(Unknown Source)
     * 	at com.aspose.cells.a.d.zfs.a(Unknown Source)
     * 	at com.aspose.cells.zcbk.a(Unknown Source)
     * 	at com.aspose.cells.zcbk.a(Unknown Source)
     * 	at com.aspose.cells.zcbk.a(Unknown Source)
     * 	at com.aspose.cells.zjk.a(Unknown Source)
     * 	at com.aspose.cells.Workbook.a(Unknown Source)
     * 	at com.aspose.cells.Workbook.save(Unknown Source)
     */
    public void createsPdfFromXlsx_onlyConvertToPdf() throws Exception {

        // Arrange
        final InputStream originalDocument = classLoader.getResourceAsStream("./DEV-14626_forAspose.xlsx");

        final File tempPdfFile = new File(tmpFolder.getAbsolutePath() + "/" + UUID.randomUUID().toString() + ".pdf");
        final FileOutputStream fileOutputStream = new FileOutputStream(tempPdfFile);

        Workbook doc = new Workbook(originalDocument);
        SaveOptions saveOptions = new PdfSaveOptions();

        // Act
        // -- this causes a CellsException
        doc.save(fileOutputStream, saveOptions);

        // Assert
        System.out.println("Saved pdf here: " + tempPdfFile.getAbsolutePath());
        // ...
    }
}

Here is the main-class to reproduce the issue with the xlsx-file.

MainAndXlsx.zip (222.9 KB)

We are using Java 1.8.

Can you tell us where the problem is?
If you need more information, just let me know.

Thank you and best regards

@orgavision,

I have tested this issue with version 19.1 and 19.3 both. It seems some issue with version 19.1 which is resolved in the latest version 19.3. Please check this sample code using latest version and provide your feedback.

1 Like

Thank you, it works again with the brand new version :slight_smile:

@orgavision,

Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Hi again,

the 19.3 works in our testcases and for unknown reason on our local Win10 develop machines. But in production we get still an exception but it differs.

java.lang.Exception: Unsupported clone for backed stream
	at com.aspose.cells.b.a.d.zm.k(Unknown Source)
	at com.aspose.cells.a.f.zg.c(Unknown Source)
	at com.aspose.cells.a.f.zj.a(Unknown Source)
	at com.aspose.cells.zrp.a(Unknown Source)
	at com.aspose.cells.zaoc.a(Unknown Source)
	at com.aspose.cells.zjj.a(Unknown Source)
	at com.aspose.cells.zjj.a(Unknown Source)
	at com.aspose.cells.Workbook.a(Unknown Source)
	at com.aspose.cells.Workbook.<init>(Unknown Source)

We found the problem in the combination of the aspose.cells 19.1+ and the jackrabbit behavior where the stream is wrapped.

I created a sample project that reproduces this issue (srcAndlib.zip (6.9 MB)
).

Here the relevant code snippet (that is what jackrabbit does):

final InputStream toUse = new AutoCloseInputStream(originalDocument) {
	@Override
	public void close() throws IOException {
		super.close();
		originalDocument.close();
	}
};

This error did not occur with aspose.cells 18.4.

Thanks a lot

@orgavision,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42871 - java.lang.Exception: Unsupported clone for backed stream while converting XLSX to PDF
1 Like

Hi again,

thank you.
As a workaround we wrap the wrapped stream and the error is gone:

private Workbook createAsposeDocument(final InputStream content) throws Exception {
	
	// This inputStream is only a workaround until the aspose.cells error is fixed
	// CELLSJAVA-42871
	try (InputStream io = new InputStream() {
	
		@Override
		public int read() throws IOException {
			return content.read();
		}
		
	}) {
		return new Workbook(io);
	}
}

Maybe this helps people experiencing the same issue :slight_smile:

@orgavision,

Thanks for the workaround. It will be helpful to others. Moreover, we will write back here as soon as any feedback is ready to share.

1 Like

@orgavision,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42871”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

1 Like

@orgavision,

Please try our latest version/fix: Aspose.Cells for Java v19.3.6:

aspose-cells-19.3.6.zip (6.5 MB)

Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-42871) have been fixed in Aspose.Cells for Java 19.4. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi