Lecture de valeurs numériques à partir d'Excel mais affichage incorrect de Java

Je souhaite pouvoir afficher les valeurs numériques telles qu'elles sont dans excel dans la console java. (sans décimales) p. ex. 1, 2, 3, mais je reçois ce qui suit: 1.0, 2.0, 3.0 Que dois-je append dans mon code?

package fyp.fyp;

import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class Read_Write { public static void main(Ssortingng[] args) throws IOException { // Location of the source file Ssortingng sourceFilePath = "C:\\Users\\Daveycol\\Desktop\\test.xlsx"; FileInputStream fileInputStream = null; // Array List to store the excel sheet data List excelSheetData = new ArrayList(); try { // FileInputStream to read the excel file fileInputStream = new FileInputStream(sourceFilePath); // Create an excel workbook XSSFWorkbook excelWorkBook = new XSSFWorkbook(fileInputStream); // Resortingeve the first sheet of the workbook. XSSFSheet excelSheet = excelWorkBook.getSheetAt(0); // Iterate through the sheet rows and cells. // Store the resortingeved data in an arrayList Iterator rows = excelSheet.rowIterator(); while (rows.hasNext()) { XSSFRow row = (XSSFRow) rows.next(); Iterator cells = row.cellIterator(); List cellData = new ArrayList(); while (cells.hasNext()) { XSSFCell cell = (XSSFCell) cells.next(); cellData.add(cell); } excelSheetData.add(cellData); } // Print resortingeved data to the console for (int rowNum = 0; rowNum < excelSheetData.size(); rowNum++) { List list = (List) excelSheetData.get(rowNum); for (int cellNum = 0; cellNum < list.size(); cellNum++) { XSSFCell cell = (XSSFCell) list.get(cellNum); if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) { System.out.print(cell.getRichSsortingngCellValue().getSsortingng() + " "); } else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) { System.out.print(cell.getNumericCellValue() + " "); } else if (cell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) { System.out.println(cell.getBooleanCellValue() + " "); } } System.out.println(""); } } catch (IOException e) { e.printStackTrace(); } finally { if (fileInputStream != null) { fileInputStream.close(); } } } } 

Si vous n'avez besoin que d'une partie entière, vous pouvez utiliser

 System.out.print((int) cell.getNumericCellValue() + " ")