从Excel文件中读取内容(Reading content from an Excel file)

2019-07-30 06:19发布

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);
     }  
}

我不明白为什么文件(路径)显示了错误的方法文件(字符串)是未定义ExampleJxl我想打印在Excel文件中输入我的名字类型

Answer 1:

从长安代码

Workbook workbook = Workbook.getWorkbook(File(path));

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


文章来源: Reading content from an Excel file
标签: java jxl jxls