我怎样才能把循环中的工作簿内容写入同一个excel文件?

我试图将工作簿内容添加到fos在每一个循环,但我得到一个错误org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException,如果我写循环以外的工作簿,它只写在我的循环中的最后一个工作簿。 任何解决scheme 这是我的代码,谢谢。

public static void main(String[] args) throws InvalidFormatException, IOException, ParseException { String [] listefichiers; String chemin="D:\\part"; FileOutputStream fos=new FileOutputStream("D:\\saisonedit3.xlsx"); FichierExcel fG_gares=new FichierExcel("D:\\Traitement aristote\\","Parametres_MP_java.xlsx","Gares"); File repertoire = new File(chemin); listefichiers=repertoire.list(); XSSFWorkbook workbook=null; for(int i=0;i<listefichiers.length;i++){ FileInputStream fis = new FileInputStream(chemin+"\\"+listefichiers[i]); System.out.println("nom fic "+listefichiers[i]); workbook = new XSSFWorkbook(fis); XSSFSheet sheet = workbook.getSheetAt(0); workbook.write(fos); } fos.close(); } }