如何解决XSSFWorkbook无法解析为一种类型

huangapple go评论46阅读模式
英文:

How to resolve XSSFWorkbook cannot be resolved to a type

问题

Code outline of Test annotation:

void test() throws Exception {
String filePath = System.setProperty("user.dir", "https://d.docs.live.net/12e57c5f83beb2a2/Documents/Book1.xlsx");
FileInputStream fileStream = new FileInputStream(filePath);

XSSFWorkbook workbook = new XSSFWorkbook(fileStream);
XSSFSheet sheet = workbook.getSheet("Sheet1");
int rowCount = sheet.getLastRowNum() - sheet.getFirstRowNum();

}


I'm trying to read the data from an xlsx file, and when I'm trying to create an instance of the XSSFWorkbook, the compiler says 

"- XSSFWorkbook cannot be resolved to a type"

Please help me how to solve this issue. It would be really helpful.
英文:

Code outline of Test annotation:

void test() throws Exception{
		String filePath = System.setProperty("user.dir", "https://d.docs.live.net/12e57c5f83beb2a2/Documents/Book1.xlsx");
		FileInputStream fileStream = new FileInputStream(filePath);
		
		XSSFWorkbook workbook = new XSSFWorkbook(fileStream);
		XSSFSheet sheet = workbook.getSheet("Sheet1");
		int rowCount = sheet.getLastRowNum() - sheet.getFirstRowNum();
				
	}

I'm trying to read the data from an xlsx file and that when I'm trying to create an Instance of the XSSFWorkbook, the compiler says

"- XSSFWorkbook cannot be resolved to a type"

Please help me how to solve this issue. It Would be really helpful.

答案1

得分: 1

导入以下内容,将解决您的问题。

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
英文:

Imported the below, will solve your issue.

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;

huangapple
  • 本文由 发表于 2023年2月16日 18:29:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75470932.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定