checking XSSFCell cellType is Date or not in Java Spring

I am trying to get data from an Excel file into my Spring(Java) web app. I am developing the system which should be suitable for both .xls and .xlsx Excel files. And I want to check whether the cellType of any cell is date, numeric, string, blank etc.
for .xls file, mycode is like that:

while (cells.hasNext()) {
                            HSSFCell cell = (HSSFCell);

                            if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) { 
                                if (HSSFDateUtil.isCellDateFormatted(cell)) { 
                                } else {
                                    int i = (int) cell.getNumericCellValue(); 

                            } else if (HSSFCell.CELL_TYPE_STRING == cell.getCellType()) {

                            } else if (HSSFCell.CELL_TYPE_BOOLEAN == cell.getCellType()) {
                                array.add(cell.getBooleanCellValue() + " ");

                            } else if (HSSFCell.CELL_TYPE_BLANK == cell.getCellType()) { 
                                array.add(" ");



Everythin is ok for .xls file. In .xls file

if (HSSFDateUtil.isCellDateFormatted(cell))

this code is checking whether the HSSFCell is date or not. And I want to do the same checking with .xlsx file. But I couldn’t find any such method. Is there any such method for XSSFCell? I couldn’t find
Thanks in advance

Source: java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.