|
Thanks for the reply Shane,I copied the java program to the IFS where the POI is, did the CHGCURDIR but when I tried to compile it I got the following messages:
$
/excel/XLWorkBook.java:2: package org.apache.poi.poifs.filesystem does not exjavac /excel/XLWorkBook.java
ist
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
^
/excel/XLWorkBook.java:3: package org.apache.poi.hssf.usermodel does not
exis
t
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
^
/excel/XLWorkBook.java:5: cannot resolve symbol
symbol : class HSSFWorkbook
location: class XLWorkBook
static public HSSFWorkbook loadWB(String fileName) {
^
/excel/XLWorkBook.java:6: cannot resolve symbol
symbol : class POIFSFileSystem
location: class XLWorkBook
POIFSFileSystem fs = null;
^
/excel/XLWorkBook.java:7: cannot resolve symbol
symbol : class HSSFWorkbook
location: class XLWorkBook
HSSFWorkbook wb = null;
^
/excel/XLWorkBook.java:11: cannot resolve symbol
symbol : class POIFSFileSystem
location: class XLWorkBook
fs = new POIFSFileSystem(infile);
^
/excel/XLWorkBook.java:12: cannot resolve symbol
symbol : class HSSFWorkbook
location: class XLWorkBook
wb = new HSSFWorkbook(fs);
^
7 errors
Any ideas? Just started reading a book on Java for RPG programmers so I'm
new to this stuff but it doesn't look like it is finding the POI .jar file.
----Original Message Follows---- From: Shane_Cessna@xxxxxxxReply-To: Java Programming on and around the iSeries / AS400<java400-l@xxxxxxxxxxxx> To: Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx>
Subject: Re: HSSF error when reading an existing Excel spreadsheet
Date: Mon, 10 Oct 2005 07:59:29 -0500
Rich,
I was having the same problem a while back but was able to work my way
around it (thanks to David Hinselwood for the code)...
XLWorkBook.java
import java.io.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class XLWorkBook {
static public HSSFWorkbook loadWB(String fileName) {
POIFSFileSystem fs = null;
HSSFWorkbook wb = null;
FileInputStream infile = null;
try {
infile = new FileInputStream(fileName);
fs = new POIFSFileSystem(infile);
wb = new HSSFWorkbook(fs);
infile.close();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (infile != null) {
try {
infile.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
return wb;
}
}
place this java program in the same IFS folder as the Jakarta POI jar
files...change your current directory on the iSeries using CHGCURDIR
DIR('/QIBM/UserData/Java400/ext/')...or wherever your POI files are...then
compile the java program using STRQSH...in there, execute the following
command...javac /QIBM/UserData/Java400/ext/XLWorkBook.java...this will
create your class for use in your RPGLE programs...
then, in your RPGLE program:
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)
...
fileName = new_String('/home/scessna/excel/May05DailyLaborHours.xls');
book = openXL(fileName);
hope this helps...
Shane
"Rich Dotson" <rich_dotson@xxxxxxxxxxx>
Sent by: java400-l-bounces@xxxxxxxxxxxx
10/09/2005 04:57 PM
Please respond to
Java Programming on and around the iSeries / AS400
<java400-l@xxxxxxxxxxxx>
To
java400-l@xxxxxxxxxxxx
cc
Subject
HSSF error when reading an existing Excel spreadsheet
I've been working with the HSSF4 Java POI procedures that I downloaded
from
the links
previously listed on this mail list. I was able to get an RPG program to
write out
to a new Excel spreadsheet but I am having a problem getting a program to
read from
an existing Excel spreadsheet.
I've included the error message, section of code in the HSSF4 service
program where
the error is occuring and the entire RPG program that I am calling. This
program
is a version of the UPDDEMO RPG program that was part of the code in the
www.iseriesnetwork.com/noderesources/code/clubtechcode/ExcelCrtDemo.zip
examples.
Does anyone know why I am receiving the following error? The error is
occuring on
the following line in the RPG program:
book = hssf_open('/excel/BBNExpress.xls');
Thanks!
Here's the detailed message that I am receiving:
Message ID . . . . . . : RNX0301 Severity . . . . . . . : 50
Message . . . . : Java exception received when calling Java method.
Cause . . . . . : RPG procedure HSSF_OPEN in program CBSCUSTM/HSSFR4
received Java exception "java.lang.UnsatisfiedLinkError:" when calling
method "<ini" with signature "" in class
"org.apache.poi.hssf.usermodel.HSSFWorkbook".
Below is the section of the HSSFR4 service program where the error
occurred.
The error occurred on line 1266 / 126500.
Program: HSSFR4 Library: CBSCUSTM Module: HSSFR4
1262 126100 /free
1263 126200 wwStr = new_String(peFilename);
1264 126300 wwFile = new_FileInputStream(wwStr);
1265 126400 wwPOIFS = new_POIFSFileSystem(wwFile);
1266 126500 wwBook = new_HSSFWorkbookFromPOIFS(wwPOIFS); <---
Error
1267 126600
1268 126700 closeFile(wwFile);
Here is the entire RPG program. The HSSFR4 service program is part of the
OSBBNDDIR binding directory.
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')
* 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'); <--- Error
// Get the 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
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.
--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. _________________________________________________________________Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.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 on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.