JAVA编译时找不到符号
用jxl编写了一个很简短的程序,是从Excel文件读取数据表,用javac编译时说:
符号: 变量rwb
位置:Sheet rs = rwb.getSheet(0);
^
import java.io.*;
import jxl.*;
import jxl.write.*;
public class Readingxls{
public static void main(String[] args){
try
{
InputStream is=new FileInputStream("d:/Book1.xls");
jxl.Workbook rwb = Workbook.getWorkbook(is);
}
catch(Exception e){e.printStackTrace();}
Sheet rs = rwb.getSheet(0);//获取第一张Sheet表
Cell c00=rs.getCell(0,0);//获取第一行,第一列的值
String strc00=c00.getContents();
System.out.println("Cell(0,0)"+"value:"+strc00);
}
}
请问这是什么问题?
------解决方案--------------------
Java code
try
{
InputStream is=new FileInputStream("d:/Book1.xls");
jxl.Workbook rwb = Workbook.getWorkbook(is);
}
//改成
jxl.Workbook rwb = null;
try
{
InputStream is=new FileInputStream("d:/Book1.xls");
rwb = Workbook.getWorkbook(is);
}