Free Support Forum - aspose.com

Unable to 'open' a password protected XLSX with Aspose.Cells 7.0.1

I’m trying to open an encrypted XLSX file with an ‘open’ password with this code:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

LoadOptions loadOptions = new LoadOptions();

loadOptions.setPassword(inputPassword);

Workbook wb = new Workbook(inputFileName, loadOptions);

Aspose.Cells v7.0.1 Java. Code works fine with password-protected .xls.

I’m getting this error:

org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.

[junit] at org.dom4j.io.SAXReader.read(SAXReader.java:482)

[junit] at org.dom4j.io.SAXReader.read(SAXReader.java:343)

[junit] at com.aspose.cells.a.b.y.a(Unknown Source)

[junit] at com.aspose.cells.a.b.y.a(Unknown Source)

[junit] at com.aspose.cells.eW.(Unknown Source)

[junit] at com.aspose.cells.Workbook.a(Unknown Source)

[junit] at com.aspose.cells.Workbook.a(Unknown Source)

[junit] at com.aspose.cells.Workbook.(Unknown Source)

Question: is opening an encrypted XLSX document supported in Aspose.Cells v7.0.1 for Java? Where can a specification of the supported password/protection/encryption mechanisms be found?

Hi,


Please make sure that you have set all other dependencies jars (e.g., dom4j-1.6.1.jar, bcprov-jdk15-146.jar,woodstox-core-asl-4.0.8.jar, stax2-api-3.0.2, jsr173_1.0_api.jar) to class path. These jars are there in the release archive i.e. v7.0.1. Also for reference about all the JARs, see the “README_LIB.txt” file present in the release archive of v7.0.1:
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry329168.aspx

If you still find this issue, kindly give us your template XLSX file here, we need to test your case with your file.

Thank you.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We have verified that all the libraries are included. Test code is as follows:

//-----------------------------------------------------------------------------

import com.aspose.cells.LoadOptions;

import com.aspose.cells.Workbook;

//-----------------------------------------------------------------------------

public class TestAsposeCells {

public static void main(String[] args) throws Exception {

String infile = args[0];

String password = args[1];

LoadOptions loadOptions = new LoadOptions();

loadOptions.setPassword(password);

Workbook wb = new Workbook(infile, loadOptions);

}

}

//-----------------------------------------------------------------------------

This is run with the command:

java -cp aspose-cells-7.0.1.jar:dom4j-1.6.1.jar:bcprov-jdk16-146.jar:stax2-api-3.0.2.jar:woodstox-core-asl-4.0.8.jar:. TestAsposeCells encrypted-spreadsheet.xlsx password

The result is this:

Exception in thread "main" org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.

at org.dom4j.io.SAXReader.read(SAXReader.java:482)

at org.dom4j.io.SAXReader.read(SAXReader.java:343)

at com.aspose.cells.a.b.y.a(Unknown Source)

at com.aspose.cells.a.b.y.a(Unknown Source)

at com.aspose.cells.eW.(Unknown Source)

at com.aspose.cells.Workbook.a(Unknown Source)

at com.aspose.cells.Workbook.a(Unknown Source)

at com.aspose.cells.Workbook.(Unknown Source)

at TestAsposeCells.main(TestAsposeCells.java:15)

Nested exception:

org.xml.sax.SAXParseException: Content is not allowed in prolog.

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)

at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)

at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1039)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

at org.dom4j.io.SAXReader.read(SAXReader.java:465)

at org.dom4j.io.SAXReader.read(SAXReader.java:343)

at com.aspose.cells.a.b.y.a(Unknown Source)

at com.aspose.cells.a.b.y.a(Unknown Source)

at com.aspose.cells.eW.(Unknown Source)

at com.aspose.cells.Workbook.a(Unknown Source)

at com.aspose.cells.Workbook.a(Unknown Source)

at com.aspose.cells.Workbook.(Unknown Source)

at TestAsposeCells.main(TestAsposeCells.java:15)

I’ve attached the test document.

Thank you.

Hi,


Thanks for the file and sample code.

After an initial test, I can find the issue as you have mentioned using your template file with code. I have logged a ticket for the issue with an id: CELLSJAVA-30748. We will figure your issue soon.

Thank you.

Hi,

Please download: Aspose.Cells for Java v7.0.1.3

We have fixed the issue of reading encrypted xlsx files.

The issues you have found earlier (filed as 30748) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.