I am getting the following exception while trying to write an .xlsx
file using Apache POI: org.apache.xmlbeans.impl.values.XmlValueDisconnectedException
I had the same problem too. Later, I tried another method and it solved.
In this case, we can move the code:
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
workbook.write(fileOut);
fileOut.close();
out of the method(int i), and then in the main method, we can use:
sc.method(1);
sc.method(2);
FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
workbook.write(fileOut);
fileOut.close();
Then, the workbook.write is only used for once. Also the data could be modified several times.