'Error 500 when exporting to Excel with jett
When I export Excel with jett I get this error. I lost a few days because of it
Maven:
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.github.ozlerhakan</groupId>
<artifactId>poiji</artifactId>
<version>3.1.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.jett/jett-core -->
<dependency>
<groupId>net.sf.jett</groupId>
<artifactId>jett-core</artifactId>
<version>0.11.0</version>
</dependency>
Code:
public <S, T> void exportToExecl(HttpServletResponse response, List<S> listError, String template) {
try {
Map<String, Object> beans = new HashMap<>();
beans.put("excel",listError);
Resource resource = new ClassPathResource("/templates/" + template);
InputStream fileIn =new BufferedInputStream(resource.getInputStream());
ExcelTransformer transformer = new ExcelTransformer();
Workbook workbook = transformer.transform(fileIn, beans);
response.setHeader("Content-Disposition", "attachment; filename=Erorr_" + template);
ServletOutputStream out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
} catch (IOException e) {
throw new InfoCityException(e.getMessage());
} catch (InvalidFormatException e) {
throw new InfoCityException(e.getMessage());
}
}
Message Error:
{
"timestamp": "2022-04-22T03:44:01.120+00:00",
"status": 500,
"error": "Internal Server Error",
"message": "'int org.apache.poi.ss.usermodel.Cell.getCellType()'"
}
Solution 1:[1]
As you already mentioned in your comment, the problem is that you're using Apache POI 5.0 whereas JETT 0.11.0 requires POI 3.14 to run.
There was discussions on the JETT forum to fork it in order to support latest POI versions, but nothing happened as far as I know.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Etienne C |
