hi,
Hi,
workbook.getSettings().setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
Cells cells = wb.getWorksheets().get(0).getCells();
cells.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
Let us know if you still have any issue or confusion.
Thank you.
Hi,
Adding more to my previous reply. Please note the following for your requirements:
1) Because the memory issue may be caused when loading the template file into memory completely, so user might have no chance to use Cells.setMemorySettings() for the large workbook. Instead, kindly use LoadOptions.setMemorySettings() to load/build the workbook in MEMORY_PREFERENCE mode. When the workbook was loaded in MEMORY_PREFERENCE mode, then all its worksheets will use this mode as the default to build cells model. You should try this way firstly to test whether it can solve your memory issue.
2) If MEMORY_PREFERENCE mode cannot solve the issue, you may consider the usage of LightCells. However, I think it is very complicated, and even impossible for users to implement all the logic by themselves if there are other things which need to be changed when inserting rows, such as formulas, named ranges, …etc. To achieve the goal of reducing memory cost for large workbook in template file, you need to combine the usage of LightCellsDataHandler and LightCellsDataProvider. That is, you should load the template file in light cells mode too. your implementation of LightCellsDataProvider will use cells data provided by LightCellsDataHandler to fill the workbook accordingly. It needs two threads to work together, like pipe stream, the loading process provides data and the saving process consumes data. And because you need to insert rows, then he should handle the row index modification too in LightCellsDataProvider, such as, if you insert one row before the third row (A3, B3, the row index is 2), for all row/cells got from LightCellsDataHandler, when their row index is greater than 2, you should fill them into the next row in LightCellsDataProvider(row index 2 becomes 3, 3 becomes 4, …).
Hope, this helps as well.
Thank you.
hi,
Hi,
hi,
Hi,
hi,
I have now checked for the latest jar you mentioned but I am still getting an error.
Hi,
hi,
Hi,
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:
-
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?
-
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:
- ~[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,
hi,
Hi,
hi,
Hi,
hi,
Hi,