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

Free Support Forum - aspose.com

XLSX conversion failures and XLS signing failures

Hi

I have two issues with the following version of the Apose.Cells. Please help me!

I loaded the aspose-cells-7.4.3.1-java and tried to convert the attached xlsx (Workbook1.xlsx) but I get the following error:

Exception in thread “AWT-EventQueue-1” java.lang.NoClassDefFoundError: com/ctc/wstx/stax/WstxInputFactory
at com.aspose.cells.b.a.h.k.b(Unknown Source)
at com.aspose.cells.b.a.h.k.a(Unknown Source)
at com.aspose.cells.b.a.h.k.a(Unknown Source)
at com.aspose.cells.b.a.h.k.(Unknown Source)
at com.aspose.cells.b.a.h.k.(Unknown Source)
at com.aspose.cells.a.c.z.a(Unknown Source)
at com.aspose.cells.ajv.a(Unknown Source)
at com.aspose.cells.zu.a(Unknown Source)
at com.aspose.cells.zu.k(Unknown Source)
at com.aspose.cells.zu.a(Unknown Source)
at com.aspose.cells.zt.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

I have attached the xlsx document and here is the code I am using to invoke the process.

inputStream = new ByteArrayInputStream(inputDocument);

LoadOptions loadOptions = new LoadOptions(excelSpecType);

Workbook workbook = new Workbook(inputStream, loadOptions);
//Workbook workbook = new Workbook(inputStream);

for (byte count = 0; count < workbook.getWorksheets().getCount(); count++)
{
Worksheet sheet = workbook.getWorksheets().get(count);

com.aspose.cells.PageSetup pageSetup = sheet.getPageSetup();
// Setting the orientation to Portrait
pageSetup.setOrientation(PageOrientationType.PORTRAIT);
// pageSetup.setFitToPagesTall(1);
pageSetup.setFitToPagesWide(1);
// pageSetup.
pageSetup.setPaperSize(PaperSizeType.PAPER_A_4);
}

// Setting the paper size to A4
workbook.save(tmpFile.getAbsolutePath(), FileFormatType.PDF);

My second issue is with signing an XLS document attached as Workbook1.xls.

Here is my code I am using to sign the document:

DigitalSignatureCollection ds = new DigitalSignatureCollection();

CertificateSigningBean bean = easyScanUtil.getCertificate();

arrayInputStream = new ByteArrayInputStream(bean.getSigningCertificate());

KeyStore inputKeyStore = KeyStore.getInstance(“PKCS12”);

inputKeyStore.load(arrayInputStream, bean.getSigningPassword().toCharArray());

DigitalSignature d = new DigitalSignature(inputKeyStore, bean.getSigningPassword(), “test for sign”, com.aspose.cells.DateTime.getNow());
ds.add(d);
Workbook workbook = new Workbook(documentIn.getAbsolutePath());
workbook.setDigitalSignature(ds);
workbook.save(documentIn.getAbsolutePath());

This code executes without errors but when I open the xlsx in microsft office there is no indication that the document is signed. So because of this I then used the following code to validate the digital signature:

Workbook workbook = new Workbook("/Users/dylan.randall/Desktop/Workbook1.xls");
DigitalSignatureCollection ds = workbook.getDigitalSignature();

for(DigitalSignature d : (Iterable)ds)
{
System.out.print(d.isValid());
}

which then returned this error

Exception in thread “main” java.lang.NullPointerException
at com.aspose.cells.Workbook.getDigitalSignature(Unknown Source)


I have also attached the certificate (kvarsen.txt) I am using to sign the document with, please rename to .p12. the password is password.

Please can you help me in determining the cause and possible fixes for the errors above.

Thanks

Dylan

Hi,


1) I have tested your code with our latest version/fix v7.4.3, it works fine. The file is generated fine too.
As your exception denotes the error is due to interdependency jar(s) file. Please make sure that you have put/set all required libraries into your classpath. From the exception stack trace, it seems at least “woodstox-core-asl-4.1.1.jar” is absent from the classpath.

You may find all the jars with the main component’s jar in the release archive at your installation/unzipped location/folder / subfolders, e.g
aspose-cells-7.4.3.jar
bcprov-jdk16-146.jar
dom4j-1.6.1.jar
stax2-api-3.0.2.jar
woodstox-core-asl-4.1.1.jar
etc.



2) Thanks for providing us the files excluding certificate file. I have logged a ticket with an id “CELLSJAVA-40513” for your issue. We will look into it and figure it out soon.


Thank you.

Hi,


2) We have evaluated your issue a bit. I am afraid, this is not a bug/issue rather, currently, Aspose.Cells for Java only supports to sign digital signatures on OOXML (XLSX, XLSM).

Thanks for your understanding!

Good Day

I have added the library files as requested but I now get the following error when trying to sign an XLSX file.

java.lang.NullPointerException
at com.aspose.cells.DigitalSignature.a(Unknown Source)
at com.aspose.cells.agv.a(Unknown Source)
at com.aspose.cells.agv.a(Unknown Source)
at com.aspose.cells.agv.b(Unknown Source)
at com.aspose.cells.agv.b(Unknown Source)
at com.aspose.cells.agv.a(Unknown Source)
at com.aspose.cells.Workbook.b(Unknown Source)
at com.aspose.cells.oq.a(Unknown Source)
at com.aspose.cells.op.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)

I have attached the file I am using to this post.

Thank you.

Dylan


Hi,


Thanks for the sample XLSX file.

Could you please also create a sample console JAVA program (runnable) and certificate file etc., you may zip all the files and attach the archive here, we will evaluate your issue soon.

Thank you.

Hi

Sample files attached.

Thanks

Hi,


Thanks for the files archive.

I can observe the issue as you mentioned by using your sample code with your provided certificate file. I used your code to assign a digital signature (after installing the certificate), the code compiles fine but when I run the code it gives an error as mentioned below. Also it produces the file without signing the document.


Exception in thread “main” java.lang.NullPointerException
at com.aspose.cells.DigitalSignature.a(Unknown Source)
at com.aspose.cells.agv.a(Unknown Source)
at com.aspose.cells.agv.a(Unknown Source)
at com.aspose.cells.agv.b(Unknown Source)
at com.aspose.cells.agv.b(Unknown Source)
at com.aspose.cells.agv.a(Unknown Source)
at com.aspose.cells.Workbook.b(Unknown Source)
at com.aspose.cells.oq.a(Unknown Source)
at com.aspose.cells.op.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at SignatureTest1.main(SignatureTest1.java:34)


I have logged a ticket with an id “CELLSJAVA-40525” for your issue. We will look into your issue soon.

Once we have any update on it, we will let you know here.

Thank you.
Hi,

We have evaluated your issue further. We found your certificate has a key with md5RSA algorithm, but Excel uses sha1RSA certificate to sign. So, your issue cannot be fixed. Please use correct certificate /key.

Thank you.

Hi

Thanks for the feedback. How is this possible as I can use the same certificate to sign doc and docx files on the latest version of Aspose.Words? When my application goes live I cannot restrict my users to use certificates that have a specific algorithm?

Thanks

Hi,


Could you try to use your certificate/key to sign your workbook manually in MS Excel if it is possible. If you accomplish the task, give us the signed workbook here, we will check it soon.

Thank you.

Hi

Please find attached the signed XLSX file using the certificate in this thread.

Thanks

Hi,


Thanks for providing signed Workbook.

I have logged it against your issue id “CELLSJAVA-40525”. Our concerned developer will look into it and we will get back to you soon.

Thank you.

Hi,


We have analyzed your issue a bit. Well, you provide only the public key of your certificate, MS Excel will use the private part of certificate to sign an Excel file, so, we suggest you to port full version of your certificate with (public and private parts) to pfx, then use this certificate to sign the document.

Thank you.

Thanks

I will get back to you with an answer.

Dylan