如何解决“ XSSFWorkbook无法解析为类型”的问题?

时间:2018-09-14 06:53:30

标签: java apache-poi classpath

我的代码是:

public class ReadExcelFile {
  public static void main(String[] args) throws IOException {
     FileInputStream fis = new FileInputStream("D:\\Hero Moneykit.xlsx");
     XSSFWorkbook workbook = new XSSFWorkbook(fis);
     XSSFSheet sheet = workbook.getSheetAt(0);          
     Row row = sheet.getRow(0);
     Cell cell = row.getCell(0);
     System.out.println(cell);
     System.out.println(sheet.getRow(0).getCell(0));
     } 
}

我遇到错误

  

:线程“ main”中的异常java.lang.Error:未解决的编译问题:XSSFWorkbook无法解析为类型

1 个答案:

答案 0 :(得分:0)

我认为您应该没有空格输入您的地址

public class ReadExcelFile {
public static void main(String[] args) throws IOException {
 FileInputStream fis = new FileInputStream("D:\\HeroMoneykit.xlsx");
 XSSFWorkbook workbook = new XSSFWorkbook(fis);
 XSSFSheet sheet = workbook.getSheetAt(0);          
 Row row = sheet.getRow(0);
 Cell cell = row.getCell(0);
 System.out.println(cell);
 System.out.println(sheet.getRow(0).getCell(0));
 } }