title: Reading numeric values from Excel but displaying them wrong in Java
body: <p>I want to be able to output the numeric values as they are in excel to the java console. (with no decimal places) e.g 1, 2, 3, but i'm getting the following: 1.0, 2.0, 3.0
  What do I need to add into my code?</p>
  
  <p>package fyp.fyp;</p>
  
  <pre><code>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(String[] args) throws IOException {
  
          // Location of the source file
          String 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);
  
              // Retrieve the first sheet of the workbook.
              XSSFSheet excelSheet = excelWorkBook.getSheetAt(0);
  
              // Iterate through the sheet rows and cells. 
              // Store the retrieved 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 retrieved data to the console
              for (int rowNum = 0; rowNum &lt; excelSheetData.size(); rowNum++) {
  
                  List list = (List) excelSheetData.get(rowNum);
  
                  for (int cellNum = 0; cellNum &lt; list.size(); cellNum++) {
  
                      XSSFCell cell = (XSSFCell) list.get(cellNum);
  
                      if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
                          System.out.print(cell.getRichStringCellValue().getString() + " ");
                      } 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();
              }
          }
      }
  }
  </code></pre>