如果假设excel在任何列中都具有日期值格式,那么我需要将整个列更改为日期格式,并在date列的空记录中插入“ N / A”值。有人,请帮助我解决这个问题。

最佳答案

private void processExcelFromLocal() {

        FileInputStream fis = null;
        try {
            fis = new FileInputStream(
                    new File("/home/rajat/Downloads/excelFile.xlsx"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();

        }

        if (fis != null) {

            @SuppressWarnings("resource")
            XSSFWorkbook workbook = null;
            try {
                workbook = new XSSFWorkbook(fis);
            } catch (IOException e) {
                e.printStackTrace();

            }

            XSSFSheet spreadsheet = workbook.getSheetAt(0);

            for (int i = 0; i <= spreadsheet.getLastRowNum(); i++) {
                XSSFRow row = spreadsheet.getRow(i);
                String value = row.getCell().getStringCellValue();
            }
        }

        try {
            fis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

09-11 17:52