public void Bug51158a() { // create a workbook XSSFWorkbook workbook = new XSSFWorkbook(); workbook.CreateSheet("Test Sheet"); XSSFSheet sheetBack = workbook.GetSheetAt(0) as XSSFSheet; // Committing twice did add the XML twice without Clearing the part in between sheetBack.Commit(); // ensure that a memory based package part does not have lingering data from previous Commit() calls if (sheetBack.GetPackagePart() is MemoryPackagePart) { ((MemoryPackagePart)sheetBack.GetPackagePart()).Clear(); } sheetBack.Commit(); String str = Encoding.UTF8.GetString(IOUtils.ToByteArray(sheetBack.GetPackagePart().GetInputStream())); //System.out.Println(str); Assert.AreEqual(1, countMatches(str, "<worksheet")); }