Java XSSF可以';不能解析为类型

Java XSSF可以';不能解析为类型,java,apache-poi,Java,Apache Poi,我在我的项目中添加了以下Maven依赖项,但当我尝试从Excel文件(.xlsx)读取数据时,它会抛出错误 a。XSSF工作簿无法解析为类型 BInvalidFormatException无法解析为类型 C无法将工作表解析为类型 D无法将单元格解析为类型 你能帮我解决这个错误吗。我已经阅读了几个块,添加了所有必要的依赖项,但仍然会弹出错误 <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <depend

我在我的项目中添加了以下Maven依赖项,但当我尝试从Excel文件(.xlsx)读取数据时,它会抛出错误

a。XSSF工作簿无法解析为类型 BInvalidFormatException无法解析为类型 C无法将工作表解析为类型 D无法将单元格解析为类型

你能帮我解决这个错误吗。我已经阅读了几个块,添加了所有必要的依赖项,但仍然会弹出错误

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.0</version>
</dependency>



<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml-schemas</artifactId>
    <version>4.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-scratchpad</artifactId>
    <version>4.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>ooxml-schemas</artifactId>
    <version>1.4</version>
</dependency>

<dependency>
    <groupId>org.apache.xmlbeans</groupId>
    <artifactId>xmlbeans</artifactId>
    <version>3.1.0</version>
</dependency>

<dependency>
                 <groupId>org.apache.poi</groupId>
                 <artifactId>openxml4j</artifactId>
                 <version>1.0-beta</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-math3</artifactId>
    <version>3.6.1</version>
</dependency>


<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
</dependency>




public  void readExcel()
        {

            DataFormatter dataFormatter = new DataFormatter();
            Date dateExcel  ;
            File fr = new File("C:\\Users\\shankar.manickam\\eclipse-workspace\\PQT Pricing New\\PQTPricing.xlsx");
            Workbook data = null;
            try {
                data = new XSSFWorkbook(fr);
            } catch (InvalidFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Sheet sheet = data.getSheetAt(0);
            int rowsize = sheet.getLastRowNum();



             Cell c1 = sheet.getRow(0).getCell(1);
             worldArea = c1.getStringCellValue();
             Cell c2 = sheet.getRow(1).getCell(1);
             double lcid1 = c2.getNumericCellValue();
             int lcid2 = (int)Math.round(lcid1);
             lcid = String.valueOf(lcid2);
             Cell c3 =sheet.getRow(2).getCell(1);
             currencyName = c3.getStringCellValue();
             Cell c4 = sheet.getRow(3).getCell(1);
             dateExcel = c4.getDateCellValue();
             date = new SimpleDateFormat("yyyy-MM-dd").format(dateExcel);
             Cell c5 = sheet.getRow(4).getCell(1);
             countryCode = dataFormatter.formatCellValue(c5);
             Cell c6 = sheet.getRow(5).getCell(1);
             repCode = dataFormatter.formatCellValue(c6);

             System.out.println(worldArea); 
             System.out.println(lcid);  
             System.out.println(currencyName);
             System.out.println(date);
             System.out.println(countryCode);
             System.out.println(repCode);
}

Errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    DataFormatter cannot be resolved to a type
    DataFormatter cannot be resolved to a type
    Workbook cannot be resolved to a type
    XSSFWorkbook cannot be resolved to a type
    InvalidFormatException cannot be resolved to a type
    Sheet cannot be resolved to a type
    Cell cannot be resolved to a type
    Cell cannot be resolved to a type
    Cell cannot be resolved to a type
    Cell cannot be resolved to a type
    Cell cannot be resolved to a type
    Cell cannot be resolved to a type

org.apache.poi
poi
4.1.0
org.apache.poi
poi ooxml
4.1.0
org.apache.poi
poi ooxml模式
4.1.0
org.apache.poi
poi草稿行
4.1.0
org.apache.poi
ooxml模式
1.4
org.apache.xmlbeans
xmlbeans
3.1.0
org.apache.poi
openxml4j
1.0-beta
org.apache.commons
commons-math3
3.6.1
公地io
公地io
2.6
公用记录
公用记录
1.2
public void readExcel()
{
DataFormatter DataFormatter=新的DataFormatter();
日期Excel;
File fr=new文件(“C:\\Users\\shankar.manickam\\eclipse workspace\\PQT Pricing new\\PQTPricing.xlsx”);
工作簿数据=null;
试一试{
数据=新的XSSF工作簿(fr);
}捕获(无效格式){
//TODO自动生成的捕捉块
e、 printStackTrace();
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
工作表=数据。getSheetAt(0);
int rowsize=sheet.getLastRowNum();
单元格c1=sheet.getRow(0).getCell(1);
worldArea=c1.getStringCellValue();
单元格c2=sheet.getRow(1).getCell(1);
double lcid1=c2.getNumericCellValue();
int lcid2=(int)数学圆(lcid1);
lcid=String.valueOf(lcid2);
单元格c3=sheet.getRow(2).getCell(1);
currencyName=c3.getStringCellValue();
单元格c4=sheet.getRow(3).getCell(1);
dateExcel=c4.getDateCellValue();
日期=新的简化格式(“yyyy-MM-dd”)。格式(日期Excel);
单元格c5=表.getRow(4).getCell(1);
countryCode=dataFormatter.formatCellValue(c5);
单元格c6=sheet.getRow(5).getCell(1);
repCode=dataFormatter.formatCellValue(c6);
系统输出打印LN(世界区域);
系统输出打印项次(lcid);
System.out.println(currencyName);
系统输出打印项次(日期);
System.out.println(国家代码);
System.out.println(repCode);
}
错误:
线程“main”java.lang中出现异常。错误:未解决的编译问题:
无法将DataFormatter解析为类型
无法将DataFormatter解析为类型
工作簿无法解析为类型
XSSF工作簿无法解析为类型
InvalidFormatException无法解析为类型
无法将工作表解析为类型
无法将单元格解析为类型
无法将单元格解析为类型
无法将单元格解析为类型
无法将单元格解析为类型
无法将单元格解析为类型
无法将单元格解析为类型

您使用的是什么Java
import
语句?下面是导入库。导入java.io.File;导入java.io.IOException;导入java.io.Serializable;导入java.sql.SQLException;导入java.util.ArrayList;导入java.util.array;导入java.util.Date;导入java.util.HashMap;导入java.util.List;好的,那么当您也决定导入ApachePOI类时会发生什么呢?我可以毫无问题地导入ApachePOI类。在代码中,我也可以在POI类中使用方法,但在运行时,我发现以下错误,线程“main”中的异常java.lang.Error:未解决的编译问题:DataFormatter无法解析为类型DataFormatter无法解析为类型工作簿无法解析为类型XSSF工作簿无法解析为类型InvalidFormatException无法解析为类型工作表无法解析为类型单元格无法解析为类型编辑在代码中显示导入时,似乎仍然导入了错误的ApachePOI类