Monday, 15 September 2014

java - Writing data to cell in existing excel through hssf/xssf. -



java - Writing data to cell in existing excel through hssf/xssf. -

i in dilemna. have been trying write info existing excel file through hssf/xssf in java. have no errors still when run can't alter made excel sheet. can help me out this? code is:

try { fileinputstream inp = new fileinputstream("c:/users/training/desktop/saurav.xlsx"); workbook wb = null; seek { wb = workbookfactory.create(inp); } grab (invalidformatexception e) { e.printstacktrace(); } sheet sheet = wb.getsheetat(0); row row = sheet.getrow(3); cell cell = row.getcell(4); if (cell == null) cell = row.createcell(4); cell.setcelltype(cell.cell_type_string); cell.setcellvalue("a test"); // write output file fileoutputstream fileout = new fileoutputstream("c:/users/training/desktop/saurav.xlsx"); wb.write(fileout); fileout.close(); } grab (filenotfoundexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); }

someone please help me out this.trying out since lastly 2 days.

instead of utilize this, working in system.

try { fileinputstream inp = new fileinputstream("c:/users/training/desktop/saurav.xlsx"); workbook wb = null; seek { wb = workbookfactory.create(inp); } grab (invalidformatexception e) { e.printstacktrace(); } sheet sheet = wb.getsheetat(0); row row = sheet.getrow(3); cell cell = row.getcell(4); cell = row.createcell(4); cell.setcelltype(cell.cell_type_string); cell.setcellvalue("a test"); // write output file fileoutputstream fileout = new fileoutputstream("c:/users/training/desktop/saurav.xlsx"); wb.write(fileout); fileout.close(); } grab (filenotfoundexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); }

also create sure refresh excel file after every run.

java eclipse eclipse-plugin

No comments:

Post a Comment