Burn xlsx file using Apache POI

I get the following exception when trying to write .xlsx file using Apache POI

 NoClassDefFoundError: javax/xml/stream/XMLStreamException 

Here's a snippet of code: -

 XSSFWorkbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(); Row row = sheet.createRow(0); Cell cell = row.createCell(0); cell.setCellValue(100); FileOutputStream fileOut = new FileOutputStream("D:\\workspace\\April\\Excel Test\\workbook.xlsx"); wb.write(fileOut); fileOut.close(); 

I have the following banks included:

  • dom4j-1.6.1
  • poi-OOXML-3,5-FINAL
  • poi-3.6-20091214
  • XMLBeans-2.3.0
  • OOXML Schema-1.0

Please let me know what I'm doing wrong here, or I'm missing something.

+6
source share
1 answer

You are missing javascript

If you look at the POI Components page, you will see that the ooxml-schemas ATM depends on the STAX API banks (usually on stax-api-1.0.1.jar )

Look in the binary loading of the POI, and in the ooxml-lib directory you will see the jar that you need. In addition, if you use Maven, it will load you a dependency

+4
source

Source: https://habr.com/ru/post/897217/


All Articles