Can I use Java console application to read and write a string from an Excel file? -


i have excel file named boo on c:\users\harout\desktop\boo.xlsx a1 entry on file test , entry.

is there way read entry using java console app?

and can write test2 in cell b2?

please write answer in details , keep simple possible i'm new java in aspect.

i found similar question posted here on stackoverflow question , answers little complicated me. want keep simple, way more beneficial readers in future.

here sample you. tyr it:

try {      poifsfilesystem fs = new poifsfilesystem(new fileinputstream(file));     hssfworkbook wb = new hssfworkbook(fs);     hssfsheet sheet = wb.getsheetat(0);     hssfrow row;     hssfcell cell;      int rows; // no of rows     rows = sheet.getphysicalnumberofrows();      int cols = 0; // no of columns     int tmp = 0;      // trick ensures data if doesn't start first few rows     for(int = 0; < 10 || < rows; i++) {         row = sheet.getrow(i);         if(row != null) {             tmp = sheet.getrow(i).getphysicalnumberofcells();             if(tmp > cols) cols = tmp;         }     }      for(int r = 0; r < rows; r++) {         row = sheet.getrow(r);         if(row != null) {             for(int c = 0; c < cols; c++) {                 cell = row.getcell((short)c);                 if(cell != null) {                 // code here                 }             }         }     } } catch (exception ioe) {     ioe.printstacktrace(); } 

so can value of a1 following :

cell == sheet.getrow(0).getcell(0);     switch (cell.getcelltype()) {         case cell.cell_type_numeric:             system.out.print(cell.getnumericcellvalue() + "\t");             break;         case cell.cell_type_string:             system.out.print(cell.getstringcellvalue() + "\t");             break;    } 

Comments