0

I am creating xls with apache-poi version 4.1.2. when I do with junit it is working correctly but if I use tomee with container then the generated file is showing an error like

Screen shot while open xls

The file format and extension of <filename>.xls don't match

  • Java version 1.8

  • tomee-plus 1.7.5

  • K8s docker container

  • Using HSSFWorkbook

    File outputFile = new File(dir, fileParameter.getFileName()); if (outputFile.exists() && !FileUtils.deleteFile(outputFile)) { LOG.warn("Cannot delete"); } try (final HSSFWorkbook workbook = new HSSFWorkbook()) { final HSSFSheet sheet = workbook.createSheet(SUMMARY_SHEET_NAME); //Header Row int rowNum = 0; int cellNum = 0; HSSFRow row = sheet.createRow(rowNum++); row.createCell(cellNum++).setCellValue("TEST1"); row.createCell(cellNum++).setCellValue("TEST2"); row.createCell(cellNum++).setCellValue("TEST3"); row.createCell(cellNum++).setCellValue("TEST4"); row.createCell(cellNum++).setCellValue("TEST5");

      try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile)) {
          workbook.write(fileOutputStream);
      }
    

    }

rzo1
  • 5,561
  • 3
  • 25
  • 64

0 Answers0