Check actual versions of your dependencies, please (e.g. with mvn dependency:tree).
I see nothing wrong with poi 3.17 and itextpdf 5.5.13.
Unit test with pom below get passed.
package stackoverflow.q59892610;
import org.junit.Rule;
import org.junit.Test;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.rules.TemporaryFolder;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.UUID;
import static org.apache.poi.xssf.usermodel.XSSFWorkbookType.XLSX;
import static org.junit.Assert.*;
public class PoiTest
{
@Rule
public TemporaryFolder folder= new TemporaryFolder(new File("target"));
@Test
public void xlsTest() throws Exception
{
File file = new File(folder.getRoot(), UUID.randomUUID() + ".xlxs");
String cellValue = UUID.randomUUID().toString();
try (XSSFWorkbook xls = new XSSFWorkbook(XLSX)) {
xls.createSheet("new sheet").createRow(0).createCell(0).setCellValue(cellValue);
try(OutputStream out = new FileOutputStream(file)) {xls.write(out);}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XSSFWorkbook xls = new XSSFWorkbook(file);
XSSFSheet worksheet = xls.getSheetAt(0);
assertEquals("cell value mismatch", cellValue, worksheet.getRow(0).getCell(0).getStringCellValue());
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>stackoverflow</groupId>
<artifactId>poi-logger</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>poi-logger</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<poi-version>3.17</poi-version>
<itextpdf-version>5.5.13</itextpdf-version>
<junit-version>4.13</junit-version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi-version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itextpdf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
poi-3.17*.jarand anotherpoi-?*.jarfrom another version in class path.org.apache.poi.util.POILoggercomes from.