我已经在项目构建路径中导入了apache poi的所有jar文件,但是仍然收到错误“xssfworkbook类型的getsheetat(int)方法引用了缺少的xssfsheet类型”
im使用版本-poi-bin-4.1.2-20200217
代码:
ackage ReadExcelData;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadExcel {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
File src = new File("C:\\Users\\Vishwa\\Desktop\\DeskTop\\Projects\\Automation Projects\\TestData.xlsx");
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
wb.getSheetAt(0); //Error here: The method getSheetAt(int) from the type XSSFWorkbook refers to
the missing type XSSFSheet ,
The type org.apache.poi.xssf.usermodel.XSSFSheet cannot be resolved. It is indirectly referenced from required .class files
}
1条答案
按热度按时间3mpgtkmj1#
你有
在pom.xml中,如果您使用的是maven?
或者加上这个jar如果你有lib的话
https://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/4.1.2/.
poi-ooxml-4.1.2.jar