java - Is it possible to first read and then write into same spreadsheet file? -


i.e. reading cell(0) , row(0) value , write new text on same place in same file.

is possible same?

this how apache-poi. code works both xls , xlsx workbooks.

//load workbook memory fileinputstream fis = new fileinputstream("filename_of_your_workbook"); workbook workbook = workbookfactory.create(fis);  //modify workbook wish //as example, override first cell of first row in first sheet (0-based indices) workbook.getsheetat(0).getrow(0).getcell(0).setcellvalue("new value a1");   //you have close input stream first before writing same file. fis.close() ;  //save changes same file. workbook.write(new fileoutputstream("filename_of_your_workbook"));  workbook.close(); 

note when create workbook object existing document apache-poi, load document model memory , changes temporary unless persist filesystem. if provide same filename while calling workbook.write(), saving changes same file.


Comments