从Excel文件中读取内容

时间:2012-07-04 09:15:30

标签: java jxl jxls

package jexcel.jxl.nimit;

import java.io.*;  

import jxl.Cell;  
import jxl.Sheet;  
import jxl.Workbook;  
import jxl.read.biff.BiffException;  
import jxl.read.biff.File;  

public class ExampleJxl {  

    /**
     * @param args
     */
    public static void main(String[] args)throws IOException, BiffException {
        ExampleJxl.ExcelFile("D:/nimit.xls");
    }

public static String ExcelFile(String path){    

    Workbook workbook = Workbook.getWorkbook(File(path));
    Sheet sheet = workbook.getSheet(0); 
    Cell a1 = sheet.getCell(0,0);
    Cell a2 = sheet.getCell(0,1);
    String s1=a1.getContents();
    String s2=a2.getContents();
    System.out.println("My name is"+a1+"\t"+a2);
     }  
}

我不明白为什么文件(路径)显示错误方法File(String)未定义类型ExampleJxl   我正在尝试打印在excel文件中输入的姓名。

1 个答案:

答案 0 :(得分:2)

来自

的代码
Workbook workbook = Workbook.getWorkbook(File(path));

Workbook workbook = Workbook.getWorkbook(new java.io.File(path));