Please Help, POI and Excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan

    Please Help, POI and Excel

    Hello,

    I am trying to read and write to an Excel file via my Java applet. I
    have done so successfully on several simple Excel files that simply
    had data cells without many complicated equations or any other Excel
    extras. However, now is the time to get the complicated ones to work.
    I didn't think that there would be a difference, but there is. At
    first, I was beginning to think that it was a file size problem, but
    now I am unsure. Does anyone know if there are any restrictions on
    POI? How about some good reference info, asside from the java doc?

    Here is some more info. Currently, the excel file is 6 sheets with
    many complicated formulas as well as a few add ins including a fairly
    complex solver. There will be more added to it later, which worries
    me even more. It will also interact with some VB in the future.

    However, I can not load the file at all. When I run the following
    lines:

    POIFSFileSystem fs = new POIFSFileSystem (new FileInputStream (file));
    HSSFWorkbook wb = new HSSFWorkbook(fs , false);

    I get the following exception on the second line:

    [WARNING] Unknown Ptg 3c (60)
    [WARNING] Unknown Ptg 3c (60)
    [WARNING] Unknown Ptg 3c (60)
    [WARNING] Unknown Ptg 3c (60)

    java.lang.refle ct.InvocationTa rgetException:
    java.lang.Array IndexOutOfBound sException
    at org.apache.poi. util.LittleEndi an.getNumber(Li ttleEndian.java :557)
    at org.apache.poi. util.LittleEndi an.getShort(Lit tleEndian.java: 90)
    at org.apache.poi. hssf.record.for mula.NamePtg.<i nit>(NamePtg.ja va:100)
    at org.apache.poi. hssf.record.for mula.Ptg.create Ptg(Ptg.java:25 9)
    at org.apache.poi. hssf.record.For mulaRecord.getP arsedExpression Tokens(FormulaR ecord.java:171)
    at org.apache.poi. hssf.record.For mulaRecord.fill Fields(FormulaR ecord.java:147)
    at org.apache.poi. hssf.record.Rec ord.fillFields( Record.java:143 )
    at org.apache.poi. hssf.record.Rec ord.<init>(Reco rd.java:105)
    at org.apache.poi. hssf.record.For mulaRecord.<ini t>(FormulaRecor d.java:118)
    at java.lang.refle ct.Constructor. newInstance(Nat ive Method)
    at org.apache.poi. hssf.record.Rec ordFactory.crea teRecord(Record Factory.java:25 4)
    at org.apache.poi. hssf.record.Rec ordFactory.crea teRecords(Recor dFactory.java:1 92)
    at org.apache.poi. hssf.usermodel. HSSFWorkbook.<i nit>(HSSFWorkbo ok.java:191)
    at scheduling.util .ExcelSheet.loa dExcel(ExcelShe et.java:174)

    I found the sheet that causes the problem, however I have no idea why.
    When I delete all the cells in the sheet, it passes through this
    part, but crashes further down the line. I tried deleting cells in
    groups, trying to determine which cell or cells are causing the
    problem, but it doesn't work because, in my opinion, the equations
    rely on cells that I deleted.

    Is there a way to run a debugger to determine where it is having a
    problem? What about in the future, how will I be able to figure out
    the next hurdle? There must be some good resources on this subject, I
    just can't find any ... anyone know of any?

    If you wish, please feel free to contact me via email at
    zgolo@planitusa .com. I have figured out how to use POI in a
    relatively simple manner, but now I am at a loss. Please Help.

    Dan
  • Mark Voorberg

    #2
    Re: Please Help, POI and Excel

    Hi Dan,

    I tried using the POI for a similar thing but ran into some serious
    roadblocks regarding complex formulas.
    The POI as it currently exists can only evaluate formulas that return
    numeric values. There are other limitations on the POI site that are
    clearly documented on their website.

    If you really need to open a Micro$oft file, there's no better way than to
    use a Micro$oft development environment.
    Also consider that an applet cannot (without some security hassles) open
    files on a file system other than where the applet was loaded from. So
    unless your Excel file is on the webserver where a user will load the web
    page containing the applet, you're out of luck. I have seen examples on the
    microsoft site (and written some of my own) using JScript to manipulate
    Excel file on the user's local workstation. I don't know your particular
    requirements, but it may be an option.

    Cheers,

    Mark Voorberg




    "Dan" <zhanngol@yahoo .com> wrote in message
    news:75c66504.0 308081218.14b3e [email protected] gle.com...[color=blue]
    > Hello,
    >
    > I am trying to read and write to an Excel file via my Java applet. I
    > have done so successfully on several simple Excel files that simply
    > had data cells without many complicated equations or any other Excel
    > extras. However, now is the time to get the complicated ones to work.
    > I didn't think that there would be a difference, but there is. At
    > first, I was beginning to think that it was a file size problem, but
    > now I am unsure. Does anyone know if there are any restrictions on
    > POI? How about some good reference info, asside from the java doc?
    >
    > Here is some more info. Currently, the excel file is 6 sheets with
    > many complicated formulas as well as a few add ins including a fairly
    > complex solver. There will be more added to it later, which worries
    > me even more. It will also interact with some VB in the future.
    >
    > However, I can not load the file at all. When I run the following
    > lines:
    >
    > POIFSFileSystem fs = new POIFSFileSystem (new FileInputStream (file));
    > HSSFWorkbook wb = new HSSFWorkbook(fs , false);
    >
    > I get the following exception on the second line:
    >
    > [WARNING] Unknown Ptg 3c (60)
    > [WARNING] Unknown Ptg 3c (60)
    > [WARNING] Unknown Ptg 3c (60)
    > [WARNING] Unknown Ptg 3c (60)
    >
    > java.lang.refle ct.InvocationTa rgetException:
    > java.lang.Array IndexOutOfBound sException
    > at org.apache.poi. util.LittleEndi an.getNumber(Li ttleEndian.java :557)
    > at org.apache.poi. util.LittleEndi an.getShort(Lit tleEndian.java: 90)
    > at org.apache.poi. hssf.record.for mula.NamePtg.<i nit>(NamePtg.ja va:100)
    > at org.apache.poi. hssf.record.for mula.Ptg.create Ptg(Ptg.java:25 9)
    > at[/color]
    org.apache.poi. hssf.record.For mulaRecord.getP arsedExpression Tokens(FormulaR e
    cord.java:171)[color=blue]
    > at[/color]
    org.apache.poi. hssf.record.For mulaRecord.fill Fields(FormulaR ecord.java:147)[color=blue]
    > at org.apache.poi. hssf.record.Rec ord.fillFields( Record.java:143 )
    > at org.apache.poi. hssf.record.Rec ord.<init>(Reco rd.java:105)
    > at org.apache.poi. hssf.record.For mulaRecord.<ini t>(FormulaRecor d.java:118)
    > at java.lang.refle ct.Constructor. newInstance(Nat ive Method)
    > at[/color]
    org.apache.poi. hssf.record.Rec ordFactory.crea teRecord(Record Factory.java:25 4
    )[color=blue]
    > at[/color]
    org.apache.poi. hssf.record.Rec ordFactory.crea teRecords(Recor dFactory.java:1 9
    2)[color=blue]
    > at[/color]
    org.apache.poi. hssf.usermodel. HSSFWorkbook.<i nit>(HSSFWorkbo ok.java:191)[color=blue]
    > at scheduling.util .ExcelSheet.loa dExcel(ExcelShe et.java:174)
    >
    > I found the sheet that causes the problem, however I have no idea why.
    > When I delete all the cells in the sheet, it passes through this
    > part, but crashes further down the line. I tried deleting cells in
    > groups, trying to determine which cell or cells are causing the
    > problem, but it doesn't work because, in my opinion, the equations
    > rely on cells that I deleted.
    >
    > Is there a way to run a debugger to determine where it is having a
    > problem? What about in the future, how will I be able to figure out
    > the next hurdle? There must be some good resources on this subject, I
    > just can't find any ... anyone know of any?
    >
    > If you wish, please feel free to contact me via email at
    > zgolo@planitusa .com. I have figured out how to use POI in a
    > relatively simple manner, but now I am at a loss. Please Help.
    >
    > Dan[/color]


    Comment

    Working...