Read/Write huge excel files(1M rows)

hi,

This error is occurring when we load workbook object within our product flow exception and is not reproducible in a sample standalone. We have ensured that we are passing the right parameters (path etc.), however it is giving following error in logs.

Although the functionlaity is working fine. There are two options you can help us with here:

  1. In class “com/aspose/cells/a/f/zb” during initialization/loading of workbook object, what could be the reason behind “StringIndexOutOfBoundsException”. Is there any missing/wrong parameter?

  2. Suppress the logs error in following class com/aspose/cells/a/f/zb using log4j.properties file( or relevant log file)

jvm 1 | ERROR [Aj] com/aspose/cells/a/f/zb

jvm 1 | java.lang.StringIndexOutOfBoundsException: String index out of range: -1

jvm 1 | at java.lang.String.substring(String.java:1955) ~[na:1.8.0_45]

jvm 1 | at org.aspectj.weaver.bcel.BcelObjectType.getOuterClass(BcelObjectType.java:904) ~[a

spectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.AbstractReferenceTypeDelegate.getFormalTypeParametersFromOuter

Class(AbstractReferenceTypeDelegate.java:108) ~[aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectT

ype.java:772) ~[aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.bcel.BcelObjectType.getDeclaredInterfaces(BcelObjectType.java:

  1. ~[aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.ReferenceType.getDeclaredInterfaces(ReferenceType.java:707) ~[

aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.ResolvedType.getDirectSupertypes(ResolvedType.java:82) ~[aspec

tjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.patterns.TypePattern.matchesSubtypes(TypePattern.java:178) ~[a

spectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.patterns.TypePattern.matchesStatically(TypePattern.java:130) ~

[aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.accept(ClassLoaderWeavingAd

aptor.java:861) ~[aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:337) ~[asp

ectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:121) ~[aspectjweaver-1.8.6.jar:

1.8.6]

jvm 1 | at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProce

ssorAgentAdapter.java:54) [aspectjweaver-1.8.6.jar:1.8.6]

jvm 1 | at sun.instrument.TransformerManager.transform(TransformerManager.java:188) [na:1.8.

0_45]

jvm 1 | at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) [na:1.

8.0_45]

jvm 1 | at java.lang.ClassLoader.defineClass1(Native Method) [na:1.8.0_45]

jvm 1 | at java.lang.ClassLoader.defineClass(ClassLoader.java:760) [na:1.8.0_45]

jvm 1 | at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [na:1.8.0

_45]

jvm 1 | at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) [na:1.8.0_45]

jvm 1 | at java.net.URLClassLoader.access$100(URLClassLoader.java:73) [na:1.8.0_45]

jvm 1 | at java.net.URLClassLoader$1.run(URLClassLoader.java:368) [na:1.8.0_45]

jvm 1 | at java.net.URLClassLoader$1.run(URLClassLoader.java:362) [na:1.8.0_45]

jvm 1 | at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_45]

jvm 1 | at java.net.URLClassLoader.findClass(URLClassLoader.java:361) [na:1.8.0_45]

jvm 1 | at com.pb.spectrum.platform.server.common.deploy.car.CarClassLoader.loadClass(CarCla

ssLoader.java:84) [spectrum-server-common-deploy-car-0-SNAPSHOT.jar:0-SNAPSHOT]

jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [na:1.8.0_45]

jvm 1 | at com.aspose.cells.a.f.za.b(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.aspose.cells.a.f.zi.iterator(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.aspose.cells.zajx.e(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.aspose.cells.zajx.a(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.aspose.cells.zajw.a(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.aspose.cells.Workbook.a(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.aspose.cells.Workbook.(Unknown Source) [aspose-cells-8.6.0.jar:8.6.0.0]

jvm 1 | at com.pb.spectrum.edi.spreadsheet.impl.SpreadsheetWorkbookAsposeFactory.createWorkb

ook(SpreadsheetWorkbookAsposeFactory.java:42) [edi-0-SNAPSHOT.jar:0-SNAPSHOT]

jvm 1 | at com.pb.spectrum.edi.spreadsheet.impl.SpreadsheetDataSourceRuntimeManagerAsposeImp

l.getWorkbookInfo(SpreadsheetDataSourceRuntimeManagerAsposeImpl.java:158) [edi-0-SNAPSHOT.jar:0-SNAP

SHOT]

We have a critical delivery next week and looking for some quick solution. If required, let us discuss this on call.

Hi,


Thanks for providing us further details.

Well, from the stack trace of the exception you pasted, it seems the issue occurred when reading a zip file (e.g XLSX etc.). So, could you give us your template file so we can test and investigate whether we can find the issue on our end or not.

Thank you.


hi,

Thanks for the lead in this issue.
I have attached the file which we are using.

Hi,


I have tested your issue with your template file using following sample code with our latest version i.e. Aspose.Cells for Java v8.6.3 (you may get it from Downloads module or maven rep.), it works fine and I do not get any exception or stack/trace (logs).
e.g
Sample code:

String filePath = “test33.xlsx”;

Workbook wb = new Workbook(filePath);
wb.save(filePath + “.out1.xlsx”);


Since you are using older version v8.6.0, so we highly recommend you to kindly try our latest (official) Aspose.Cells for Java v8.6.3 if it makes any difference.

Thank you.

hi,

We have tried using the latest version but the issue still persists. We are using stream instead of path while loading the workbook object.

Also we have purchased the library with 1 year support.

So could you please suppress the logs in aspose jar in that particular class and provide us with that jar.

Hi,


Well, I am afraid, we are not able to reproduce the issue (using your provided file) on our end, so we cannot provide much help to sort your issue out. Neither we provide any means (via API attributes) to suppress the logs you are facing as we do not face such errors.

We appreciate if you could provide us a separate executable console application (JAVA program) to reproduce the issue on our end, so we could log it into our database and figure it out as soon as possible.

Thank you.

hi,

Thanx for reply.
We are looking into our issue meanwhile could you guide us in following issue

We are using inputstream to load workbook oject but if inputstream is empty then aspose freezes for 100 sec and our system hangs.

Could you provide a way so that it throws an exception is inputstream is empty.

Hi,


Well, if inputstream is null, Aspose.Cells would throw NullPointerException. Also, I have tested your scenario using v8.6.3.x with an empty stream, it works efficiently and fine. I think you may try to use FileInputStream.available() method to check if the stream is empty or not, so you should not load empty stream into Workbook object. See the sample code below for your reference:
e.g
Sample code:

FileInputStream fis = new FileInputStream(new File(“abc.txt”));
int empty =fis.available();
if(empty==0)
{
System.out.println("!!File is empty!!");
}

Workbook workbook = new Workbook(fis); //It also works instantly.

System.out.println(“Done!”);

Thank you.