簡體   English   中英

來自 XSSFWorkbook 類型的方法 getSheetAt(int) 指的是缺少的類型 XSSFSheet

[英]The method getSheetAt(int) from the type XSSFWorkbook refers to the missing type XSSFSheet

我已經在項目構建路徑中導入了 apache poi 的所有 jar 文件,但我仍然收到錯誤“來自 XSSFWorkbook 類型的方法 getSheetAt(int) 指的是缺少的類型 XSSFSheet”。 '

我正在使用版本- 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
        
        
    }

你有

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.2</version>
</dependency>

如果您使用的是 maven,在您的 pom.xml 中?

或者添加這個 jar 如果你有一個庫

https://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/4.1.2/

poi-ooxml-4.1.2.jar

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM