public static void exportNewExcelByPathXls(HSSFWorkbook targetExcel,String resultPath ) throws FileNotFoundException, IOException { FileOutputStream fileOutputStream = new FileOutputStream(resultPath); targetExcel.write(fileOutputStream); fileOutputStream.flush(); fileOutputStream.close(); targetExcel.close(); } public static void exportNewExcelByPathXlsx( XSSFWorkbook targetExcel,String resultPath) throws FileNotFoundException, IOException { FileOutputStream fileOutputStream = new FileOutputStream(resultPath); targetExcel.write(fileOutputStream); fileOutputStream.flush(); fileOutputStream.close(); targetExcel.close(); }