MIDRANGE dot COM Mailing List Archive



Home » JAVA400-L » October 2005

Re: HSSF error when reading an existing Excel spreadsheet



fixed

Shane,

I changed the CLASSPATH and was able to compile the XLWorkBook.java program. I added the openXL procedure to my RPG program just as you described in the previous email. Now when I run the RPG program I get the following error:

Message ID . . . . . . :   RNX0301       Severity . . . . . . . :   50
Message type . . . . . :   Diagnostic
Date sent  . . . . . . :   10/11/05      Time sent  . . . . . . :   09:00:30

Message . . . . :   Java exception received when calling Java method.
Cause . . . . . :   RPG procedure XLSOPEN in program U28871/XLSOPEN received
Java exception "java.lang.UnsatisfiedLinkError:" when calling method "load"
  with signature "" in class "XLWorkBook".

The error occurred on line 50 below:

49         fileName = new_String('/excel/BBNExpress.xls');
50         book = openXL(fileName);


Thanks for all the help....


Here's the new version of the RPG program:

H DFTACTGRP(*NO)
H OPTION(*SRCSTMT: *NODEBUGIO: *NOSHOWCPY)
H THREAD(*SERIALIZE)
H BNDDIR('OSBBNDDIR' : 'QC2LE')

/copy qOSBCPYSRC,hssf_h

D book            s                   like(HSSFWorkbook)
D sheet           s                   like(HSSFSheet)
D row             s                   like(HSSFRow)
D cell            s                   like(HSSFCell)
D TempStr         s                   like(jString)
D StrVal          s             52A   varying
D NumVal          s              8F
D type            s             10I 0

D String_getBytes...
D                 pr          1024A   varying
D                                     extproc(*JAVA:
D                                     'java.lang.String':
D                                     'getBytes')

d openXL          pr              o   extproc(*JAVA
d                                     :'XLWorkBook'
d                                     :'loadWB')
d                                     CLASS(*JAVA:
d                                     'org.apache.poi.hssf.usermodel-
d                                     .HSSFWorkbook')
d                                     static
d  fileName                           like(jString)

d fileName        s                   like(jString)

* Put environment variable
D PutEnv          pr            10i 0 ExtProc('putenv')
D  EnvVar                         *   value options(*string)

D rc              s             10i 0
/free

 // set CLASSPATH environment
 rc = putenv('CLASSPATH=/excel/POI-2.0.jar');

 hssf_begin_object_group(100);

 // Load the BBN Express Spreadsheet into memory
 // --->book = hssf_open('/excel/BBNExpress.xls');

 fileName = new_String('/excel/BBNExpress.xls');
 book = openXL(fileName);

// Get the first cell
sheet = hssf_getSheet(book: 'Sept 20');
row   = HSSFSheet_getRow(sheet: 2);
cell = HSSFRow_GetCell(row: 2);
type = HSSFCell_getCellType(cell);
StrVal = 'Cell B2 = ';

 select;
 when type = CELL_TYPE_STRING;
    StrVal +=
      String_getBytes(HSSFCell_getStringCellValue(cell));
 when type = CELL_TYPE_FORMULA;
    StrVal += String_getBytes(HSSFCell_getCellFormula(cell));
 when type = CELL_TYPE_NUMERIC;
    NumVal = HSSFCell_getNumericCellValue(cell);
    StrVal += %char(%dech(NumVal:15:2));
  endsl;

  dsply StrVal;

  hssf_save(book: '/excel/BBNExpress.xls');
  hssf_end_object_group();

  *inlr = *on;

/end-free

_________________________________________________________________
Don?t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact