I've been doing a test class to create .xlsx files using a simple example I found. I'm not using a Maven project because the project where I'm going to implement it it's not a Maven project.
The problem is that every time I run the test program I get an error saying that there's a class missing. After look for the jar that contains the missing class and implement it, I run the program again and get the same error but missing another different class. I've already added 4 jars to the program, but every time I keep getting different missing classes. Any leads in how to make this work or if there is a more effective way to create .xlsx files using Apache POI or any other API?
Here's the code I used for the test:
public static void main(String[] args) throws FileNotFoundException, IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Java Books");
Object[][] bookData = {{"Head First Java", "Kathy Serria", 79}, {"Effective Java", "Joshua Bloch", 36}, {"Clean Code", "Robert martin", 42}, {"Thinking in Java", "Bruce Eckel", 35}};
int rowCount = 0;
for (Object[] aBook : bookData) {
Row row = sheet.createRow(++rowCount);
int columnCount = 0;
for (Object field : aBook) {
Cell cell = row.createCell(++columnCount);
if (field instanceof String) {
cell.setCellValue((String) field);
} else if (field instanceof Integer) {
cell.setCellValue((Integer) field);
}
}
}
try (FileOutputStream outputStream = new FileOutputStream("JavaBooks.xlsx")) {
workbook.write(outputStream);
}
}
These are the jars and exceptions that I've been getting:
Added these jars, but the last exception (the one above) keeps appearing. I added the jar poi-ooxml-schemas-3.9.jar because it was supposed to be the jar that contained the missing class, but the exception persisted.
These are all the jars that I'm using: https://drive.google.com/open?id=1jFovTLN_wpCwPFL6q_HbPciU7a6wnmuv