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(path) 显示错误 The method File(String) is undefined for the type ExampleJxl
我正在尝试打印我在 excel 文件中输入的名字。

最佳答案

Workbook workbook = Workbook.getWorkbook(File(path));
更改您的代码
Workbook workbook = Workbook.getWorkbook(new java.io.File(path));

关于java - 从 Excel 文件中读取内容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11326031/

10-14 13:31