Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

poi and protected excel book

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i can read cell values from an excel book; yet, if i try it on this particular protected sheet (from another book) i get an exception
the abc9 works fine, even if protected; abc10 is another file with lots and lots of formulas:


Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at org.apache.poi.hssf.usermodel.HSSFRow.<init>(HSSFRow.java:51)
at org.apache.poi.hssf.usermodel.HSSFSheet.createRowFromRecord(HSSFSheet.java:207)
at org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet(HSSFSheet.java:139)
at org.apache.poi.hssf.usermodel.HSSFSheet.<init>(HSSFSheet.java:120)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:224)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:257)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:238)
at util.ExcelUtil.leCapital(ExcelUtil.java:24)



i tried protecting both cells and sheet on the first book yet i can read it from java...
what could it be?
(my office version is 2000 and i'm using java 6)
thanks in advance
 
Marshal
Posts: 27900
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Out Of Memory means exactly what it says: your program has used up all the available memory. So before you start working on radical theories involving spreadsheet protection, first try the obvious things like giving your program more memory to run in.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Out Of Memory means exactly what it says: your program has used up all the available memory. So before you start working on radical theories involving spreadsheet protection, first try the obvious things like giving your program more memory to run in.


in the meanwhile i worked a bit: inserted that method inside a new thread - no effect - and also googled for expanding java memory, but could not find the exact command for doing it

can you help me please?
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i just nearly quadriplicated eclipse's memory from 256 to 1000:
C:\eclipse\eclipse.exe -vmargs -Xms256m -Xmx1000m, but still the same

EDIT:
i just did the same in the java console in control panel (-Xms256m -Xmx1000m), with still no result...
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, i guess i already gave more memory to my program to run in; still, i keep getting that error message

does anyone have any idea about solving this?

thanks in advance
 
Paul Clapham
Marshal
Posts: 27900
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You didn't say how you are running your program, so how can we tell you how to change that to use more memory?

Changing the memory available to Eclipse doesn't make that memory available to any other programs. The Java console's entries apply to applets, I think.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:You didn't say how you are running your program, so how can we tell you how to change that to use more memory?

Changing the memory available to Eclipse doesn't make that memory available to any other programs. The Java console's entries apply to applets, I think.


thank you for your reply
my application is a standalone, swing database connected application, usually run from eclipse or ant
below i post the messages from ant, and also my class
i also attach an image of the java console, where i increased memory size
if you know any way of increasing the memory size, or have any hint on how i would search further, please let me know


run:
[java] Exception in thread "AWT-EventQueue-0" org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
[java] at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:191)
[java] at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:115)
[java] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:205)
[java] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:257)
[java] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:238)
[java] at util.ExcelUtil.leCapital(Unknown Source)
[java] at util.VariosUtil.inicializa(Unknown Source)
[java] at gui.Mercados.getJFrame(Unknown Source)
[java] at gui.Mercados$6.run(Unknown Source)
[java] at java.awt.event.InvocationEvent.dispatch(Unknown Source)
[java] at java.awt.EventQueue.dispatchEvent(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[java] at java.awt.EventDispatchThread.run(Unknown Source)
[java] Caused by: java.lang.reflect.InvocationTargetException
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
[java] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
[java] at java.lang.reflect.Constructor.newInstance(Unknown Source)
[java] at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:179)
[java] ... 16 more
[java] Caused by: java.lang.IllegalArgumentException: Illegal length
[java] at org.apache.poi.hssf.record.RecordInputStream.readCompressedUnicode(RecordInputStream.java:246)
[java] at org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:736)
[java] at org.apache.poi.hssf.record.Record.<init>(Record.java:56)
[java] at org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:143)
[java] ... 21 more
BUILD SUCCESSFUL


java-console.JPG
[Thumbnail for java-console.JPG]
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to pass the -Xms256m -Xmx1000m to the java process that starts your stand alone process. Where are you starting it from? Eclipse? Also the error message you posted doesn't seem to be an OOM, it's something else...
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply
how do i pass that information (-Xms256m -Xmx1000m ) to the java process?
the first error messages were generated when running from eclipse; these last ones are from ant
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the meanwhile i almost solved my problem
i did increment memory size for java, when running from comandline:

C:\proj\bin>java -Xms256m -Xmx1000m


running this way i get it all fine
i did the same in eclipse.ini, but still get the OOM exception:


*** Date: Tue Jan 12 19:23:35 GMT 2010

*** Platform Details:

*** System properties:
awt.toolkit=sun.awt.windows.WToolkit
eclipse.buildId=M20060629-1905
eclipse.commands=-os
win32
-ws
win32
-arch
x86
-launcher
C:\eclipse\eclipse.exe
-name
(...)
C:\WINDOWS\system32\javaw.exe
(...)
eclipse.vmargs=-Xms256m
-Xmx1000m
(...)


though i, in a sense, solved my problem, still have one: its unacceptable to compile and run from command line
does anyone have any ideas about incrementing heap size for eclipse?
or should i post directly at IDEs forum?

thanks in advance
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is more of an eclipse question, but it's OK to answer it here. Basically when you run java programs inside eclipse you have a run configuration for each of them. Take a look at Run menu in Eclipse and follow your nose...
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic