I am writing a project, and the results should be saved to Excel file ( .xlsx
). I added the following dependencies in pom.xml
:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8-beta3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16-beta1</version>
</dependency>
All the imported libraries are working properly, such as:
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
except the one related to cells. It must have the following imported statement:
import org.apache.poi.ss.usermodel.Cell;
But it does not work. I do not know what is the problem.
As per this Apache POI FAQ entry - Mixing POI jars between releases is not supported .
You should change your pom to refer to the same, latest version of Apache POI for everything, eg
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16-beta1</version>
</dependency>
With that in place, you'll be able to access the Cell class without issues
如果下载了此 jar(即在pom.xml中指定的jar),则将看到Cell
类存在,因此问题必须出在其他地方,例如IDE缓存(对于IntelliJ,请尝试重新导入maven项目,对于Eclipse – Don不幸的是不知道)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.