英文:
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.*;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论