i'm create a method to write and read work book from file but when i call this method second time. error occure : org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
public XSSFWorkbook GetUpdatedResult(XSSFWorkbook vmworkbookhelper) throws Exception
{
this.vmWorkbookHelper2 = vmworkbookhelper;
String tempName = UUID.randomUUID().toString()+".xlsx";
File tempFile = new File(tempName);
fileOut = new FileOutputStream(tempFile);
this.vmWorkbookHelper2.write(fileOut);
fileOut.close();
vmworkbookhelper = new XSSFWorkbook(tempFile);
if(tempFile.exists())
tempFile.delete();
return vmworkbookhelper;
}
Agree with Akokskis, writing twice causing problem, but you can try reloading again the workbook after writing, then it will perfectly work. For example
FileOutputStream fileOut = new FileOutputStream("Workbook.xlsx");
wb.write(fileOut);
fileOut.close();
wb = new XSSFWorkbook(new FileInputStream("Workbook.xlsx"));
Writing twice to the same XSSFWorkbook
can produce that error - it's a known bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With