java - How to append cell (String) value from Excel file to JTextArea? -
This is my problem:
I try to add value from cell loop to excel file . I use this part of the code:
workbook workbook = new HSSFWorkbook (new file inputstream (file chooser.gate selected file)); Sheet Sheet = Workbook. Gadgetsite (0); (Iterator & Lt; Row & gt; rit = sheet.rowIterator (); rit.hasNext ();) {line line = rit.next (); (Iterator & lt; cell & gt; cit = row.cellIterator (); cit.hasNext ();) {cell cell = cit.next (); Cell.setCellType (Cell.CELL_TYPE_STRING); While (cit.hasNext ()) {notatnik.append (String.valueOf (cell.getSheet). ToString ()) "" \ n "); } System.out.print (cell.getStringCellValue () + "\ t"); } System.out.println (); }
But it has only got value back "1" or "org.apache.poi.hssf.usermodel.HSSFSheet@6325a3ee". I have the value for example in Excel: 1 SP 25 KP 5 6.5 etc.
What should I do to get this value back to JTextArea from Excel?
PS I use the PoI 3.10 library.
You're a little messy with the itater ...
The Iterator Should be used by:
iterator & lt; Cell & gt; Cit = row.cellIterator (); // You receive an itater ... while (cit.hasNext ()) {// cell cell cell = cit.next () does not go to cell; Println (cell.getStringCellValue ()); }
Not sure why you are printing cell.getSheet ()
because this value is always the same (you are in the same sheet) ... Maybe you are looking for cell.getValue ()
... or something similar
Comments
Post a Comment