Exception when writing to the xlsx document several times using apache poi 3.7

后端 未结 7 1695
夕颜
夕颜 2020-11-29 08:44

I am getting the following exception while trying to write an .xlsx file using Apache POI: org.apache.xmlbeans.impl.values.XmlValueDisconnectedException

相关标签:
7条回答
  • 2020-11-29 09:12

    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.

    0 讨论(0)
提交回复
热议问题