java - org.apache.xmlbeans.impl.values.XmlValueDisconnectedException when write workbook twice -
this question has answer here:
i'm create method write , read work book file when call 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 akokskis, writing twice causing problem, can try reloading again workbook after writing, work. example
fileoutputstream fileout = new fileoutputstream("workbook.xlsx"); wb.write(fileout); fileout.close(); wb = new xssfworkbook(new fileinputstream("workbook.xlsx"));
Comments
Post a Comment