jxl.* jar File Not Found..

I have placed the jxl jar file in the following locatons:

IS\packages\packageName\code\jars
IS\packages\packageName\code\jars\static
IS\lib\jars

but i am getting the following Compiler Error Message:

C:\webMethods65\IntegrationServer\packages\Excel\code\source\Parsing.java:230: cannot resolve symbol
symbol : variable sheet
location: class Parsing
Cell c = sheet.getCell(col,lig);

C:\webMethods65\IntegrationServer\packages\Excel\code\source\BremerParsing.java:258: cannot resolve symbol
symbol : variable line
location: class Parsing
line.append(normalize(readCell(lig,col, replace, format)));

If anyone can tell me why the compiler can’t find this class I would be grateful and can help me resolve this problem.

In the tutorials for the JExcelApi, we have a demonstration and test programs contained in the package jxl.demo. This is accessed from the command line as follows

java -jar jxl.jar -xml -format spreadsheet.xls : This command line paramater reads spreadsheet.xls and writes out the corresponding cell data to the standard output as XML.

I want to know is there any way we can write a java service or flowservice for attaining the same functionality. ie.

  1. Reads A File from a location specified.
  2. Write a outputfile as an XML flat file.

Also i want to know as to how can i deploy this jxl.jar file in my IS so that it is read and recognized with the compiler.

thanks,
nightfox

Can you post your code? It looks likes the errors are complaining about variables in your code that haven’t been declared (sheet and line), not about missing classes.

hey thanks reamon,

I feel that i have not made the varaibles in the beow function visible to the shared code…!

the code goes a follows,

[highlight=java] public static void samparser(IData pipeline) throws service exception
//pipeling
IDataCursor idc = pipeline.getCursor();
String fileName = IDataUtil.getString(idc,“file_Name”);
ByteArrayInputStream donneesExcel;
Workbook workbook;
Sheet sheet;
StringBuffer line;
int maxLines ;
donneesExcel = new ByteArrayInputStream(fileData.getBytes());
IDataUtil.put(idc,“fileused”,fileName);
workbook = Workbook.getWorkbook(new File(fileName));
sheet = workbook.getSheet(0);
line = new StringBuffer() ;
maxLines = sheet.getRows() ;
String fileData = parseFileData(sheet,line,maxLine); - is this decleration correct.
return};

and the shared code is

private static String parseFileData(Sheet sheet,StringBuffer line, int maxLines) throws Exception {
List tab = new ArrayList() ;
int curRec = 1 ;
String curLine = “” ;
boolean endLoop = false ;
boolean hrcl = false ;
String cellVal = “” ;
if ( readCell(0,6,false,false).toLowerCase().indexOf(“quality”) >= 0 ) {
hrcl = true ;
} else {
hrcl = false ;
}
while ( !endLoop & curRec < maxLines) {
if ( readCell(curRec,0,false,false).equals(“”) )
endLoop = true ;
else {
line =new StringBuffer();
line.append(“”);
parseCell(“SerialNumber”, curRec,0,false,false ) ;
parseCell(“MaterialID”, curRec,1,false,false ) ;
String dateRes = dateFormat(readCell(curRec,4,false,false));
parseTag(“SwbDate”, dateRes);
String productiondate = dateFormat(readCell(curRec,5,false,false));
parseTag(“ProductionDate”, productiondate);
parseTag(“Date_identification”,productiondate);
if ( hrcl ) {
// HRCL
parseCell(“AnalyseB”, curRec,26,true,true ) ;
parseCell(“AnalyseNb”, curRec,27,true,true) ;
parseCell(“AnalyseV”, curRec,28,true,true ) ;
parseCell(“AnalyseTi”, curRec,29,true,true ) ;
parseCell(“AnalyseN”, curRec,49,true,true);
String flag = uFormat(readCell(curRec,57,false,false));
parseTag(“Comet1Flag”, flag);
} else {
// HDCL
parseCell(“SwbStatus”, curRec,6,false,false ) ;
parseCell(“ShlStatus”, curRec,7,false,false) ;
String flag = uFormat(readCell(curRec,65,false,false));
parseTag(“Comet1Flag”, flag);
//parseCell(“Comet1Flag”, curRec,65,false,false);
}
line.append(“”);
tab.add(line.toString());
curRec ++;
}

}

return (String) tab.toArray( new String[tab.size()] );

}
private static String readCell(int lig, int col, boolean replace, boolean format) throws Exception {
String val ;
Cell c = sheet.getCell(col,lig);
val = ( String ) c.getContents().trim();

if(val != null && replace)
val = val.replace(‘,’, ‘.’);

if (!“”.equals(val) && format)
{try {
java.text.DecimalFormat df = new java.text.DecimalFormat(“######.###”);
if (val.indexOf(“.”) == 0)
val=“0”+val;
val=df.format(val);
}
catch (Throwable e)
{
val=val;
}
}

//if(“”.equals(val) && replace) {
// val = “0”;
//}
return val ;
}
private static void parseCell(String tag,int lig, int col, boolean replace, boolean format) throws Exception {
line.append(“<”+tag+“>”) ;
line.append(normalize(readCell(lig,col, replace, format)));
line.append(“</”+tag+“>”) ;
}

private static String dateFormat(String dateAFormater) throws Exception {
String dateCal = “”;
if(dateAFormater.trim().length() > 0) {
String jour = dateAFormater.substring(0, 2);
String mois = dateAFormater.substring(3, 5);
String annee = dateAFormater.substring(6, 10);
dateCal=annee+mois+jour;
}
return dateCal ;
}
private static String dateHeureFormat(String dateAFormater) throws Exception {
String dateCal = “”;
if(dateAFormater.trim().length() > 0) {

String jour = dateAFormater.substring(0, 2);
String mois = dateAFormater.substring(3, 5);
String annee = dateAFormater.substring(6, 10);
String heure = dateAFormater.substring(11, 20);
dateCal=mois+“/”+jour+“/”+annee+" “+heure ;
}
return dateCal ;
}
private static void parseTag(String tag, String dateRes ) throws Exception {
line.append(”<“+tag+”>“);
line.append(dateRes);
line.append(”</“+tag+”>");
}
private static String uFormat(String flagAFormater) throws Exception {
String flagMAJ = “”;
if(flagAFormater.trim().length() > 0) {
flagMAJ= flagAFormater.toUpperCase();

}

return flagMAJ; }
private static String normalize(String s) throws Exception {
StringBuffer str = new StringBuffer();
int len = (s != null) ? s.length() : 0;
for (int i = 0; i < len; i++) {
char ch = s.charAt(i);
switch (ch) {
case ‘<’ :
{
str.append(“<”);
break;
}
case ‘>’ :
{
str.append(“>”);
break;
}
case ‘&’ :
{
str.append(“&”);
break;
}
case ‘"’ :
{
str.append(“"”);
break;
}
case ‘'’ :
{
str.append(“'”);
break;
}
case ‘\r’ :
case ‘\n’ :
default :
{
str.append(ch);
}
}
}
return str.toString();
}[/highlight]


private static String readCell(int lig, int col, boolean replace, boolean format) throws Exception {
String val ;
Cell c = sheet.getCell(col,lig);
val = ( String ) c.getContents().trim();

private static void parseCell(String tag,int lig, int col, boolean replace, boolean format) throws Exception {
line.append(“<”+tag+“>”) ;

The error here is that there are no variables named sheet nor line that are visible in these methods. It looks to me that you’ve taken a class from somewhere and in “converting” it to run in IS you’ve simply turned the methods into private static methods. Not a terrible approach but that means any instance variables (such as sheet and line) are not available and must be passed around.

As an alternative, you might consider keeping the class you ported intact and instantiate an instance of that class and then call the appropriate entry method.

HTH