jexcel读excel时报错
源码如下:
static final String workFielUrl = "c:/jxlrwtest.xls ";
/**
* @param argsb
*/
public static void main(String[] args) {
java.io.OutputStream fou = null;
java.io.InputStream fin = null;
jxl.write.WritableSheet writeSheet = null;
jxl.write.WritableWorkbook writeWB = null;
jxl.Workbook wb = null;
// TODO Auto-generated method stub
try {
fou = new FileOutputStream(workFielUrl);
fin = new FileInputStream(workFielUrl);
File f=new File(workFielUrl);
wb=jxl.Workbook.getWorkbook(fin);
jxl.write.WritableWorkbook copywb=jxl.Workbook.createWorkbook(new File(workFielUrl), wb);
jxl.write.WritableSheet wsheet=copywb.createSheet( "abc ", 5);
copywb.write();
copywb.close();
在 wb=jxl.Workbook.getWorkbook(fin);时报错
异常如下:
jxl.read.biff.BiffException: The input file was not found
at jxl.read.biff.File. <init> (File.java:124)
at jxl.Workbook.getWorkbook(Workbook.java:268)
at jxl.Workbook.getWorkbook(Workbook.java:253)
at jexcel.JExcelUtil.main(JExcelUtil.java:27)
------解决方案--------------------文件路径不对~~~~~~~~~
------解决方案--------------------文件不存在。
你可以试试。
File file=new File( "d:\\template3333.xls ");
if(file.exists()){
System.out.println( " file.exists is "+file.exists());
}else{
System.out.println( " file.exists is "+file.exists());
}
能创建File并不是说file已经存在,只是创建了一个File实例而已。
------解决方案--------------------还没有高手能解决吗?