Ahoi there,
I am trying to set the CellType of an XSSFCell. Basically I want to have just on set of methods to export a HSSF and a XSSFWorkbook and according to the API it SHOULD work.
Workbook workbook = new XSSFWorkbook(); //Alternatively HSSFWorkbook
Sheet sheet = workbook.createSheet();
Row headerRow = sheet.createRow(0);
for (int x = 0; x < exportColumns.size(); x++) {
Cell createCell = headerRow.createCell(x);
//Exception
createCell.setCellType(CellType.STRING);
//
createCell.setCellValue(exportColumns.get(x));
}
But I get the following NetBeans runtime hint when using an XSSFWorkbook (HSSF works fine):
createCell.setCellType(CellType.STRING) = >None of the "setCellType" methods in class "org.apache.poi.xssf.usermodel.XSSFCell" takes parameters of types "(org.apache.poi.ss.usermodel.CellType)".<
Problem is, that in the official API Doc the exactly some method shows up and I am using the latest Version. (April '17) https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFCell.html#setCellType(org.apache.poi.ss.usermodel.CellType)
Anyone has some ideas to this? I dont want to have totally redundant code, just because I have to duplicate everything because of the CellTypes...
Update:
Version 3.1.6 from https://mvnrepository.com/artifact/org.apache.poi/poi.
Basically that is a runtime NetBeans Hint. The actual Exception is:
Caused by: java.lang.AbstractMethodError: org.apache.poi.xssf.usermodel.XSSFCell.setCellType(Lorg/apache/poi/ss/usermodel/CellType;)V
at de.htwk.leipzig.maxsolutions.service.ExportService.exportToExcel(ExportService.java:134)
at de.htwk.leipzig.maxsolutions.service.ExportService.exportFile(ExportService.java:91)
at de.htwk.leipzig.maxsolutions.controller.ExcelExportViewController.startExport(ExcelExportViewController.java:185)
at de.htwk.leipzig.maxsolutions.controller.ExcelExportViewController.handleSaveAction(ExcelExportViewController.java:105)
... 58 more