Olá, eu estou recebendo uma exceção ao tentar escrever escrever em um arquivo xlsx com a biblioteca Apache POI 3.16.
@FXML public void export() throws IOException{
FileChooser fileChooser = new FileChooser();
InputStream inp = new FileInputStream(fileChooser.showOpenDialog(this.getWindow()));
FileOutputStream out = new FileOutputStream("C:\\Users\\Thallysson\\Desktop\\workbook.xlsx");
POIFSFileSystem fs = new POIFSFileSystem(inp);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet s = wb.createSheet();
Row r = null;
org.apache.poi.ss.usermodel.Cell c = null;
r = s.getRow(0);
c = r.getCell(11);
c.setCellValue("Thallysson");
wb.write(out);
out.close();
}
Exceção:
Caused by: org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:152)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:140)
at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:302)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:85)
at controller.Controller.export(Controller.java:283)
... 53 more
Controller.java:283:
POIFSFileSystem fs = new POIFSFileSystem(inp);
Alguém sabe me explicar o que se passa por aqui?