1

wierd displaying

Check out excel file

Yellow colored cells does not return values as it displayed. It seems that the value is integer in excel, but actual value in POI is a double number. There's no formula, displaying options in the cell at all.

Here's the code that verifies acutal value.

<dependency>
   <groupId>org.apache.poi</groupId>
   <artifactId>poi-ooxml</artifactId>
   <version>4.1.2</version>
</dependency>
File file = new File("newSCIS.xlsx");
Workbook workbook = WorkbookFactory.create(file);
Sheet sheet = workbook.getSheetAt(0);

for (int i = 1; i <= 6; i++) {
    Row row = sheet.getRow(i);
    Cell cell = row.getCell(1);
    cell.setCellType(CellType.STRING);
    String value = cell.getStringCellValue();

    System.out.printf("%20s \n", value);
}

Why is this happening?

kimchoky
  • 162
  • 1
  • 10

1 Answers1

0

If you are getting a decimal number you can simply parse it to an int using

Math.round(floatNum);
acornTime
  • 278
  • 1
  • 15