Accessing Excel Sheets in Java using Apache POI with Eclipse IDE -


am new bee apache poi , eclipse ide.. in need work excel files have generate new spread sheets , need read contents of excel sheet. have stated sample code can generate excel sheet. based on requirements have added poi-2.5.1.jar external .jar file project.. here code,

import org.apache.poi.hssf.usermodel.hssfsheet; import org.apache.poi.hssf.usermodel.hssfworkbook;  import org.apache.poi.ss.usermodel.row; import org.apache.poi.ss.usermodel.cell; import java.io.*; import java.util.*;    public class ex1 {  //public ex1() { } public static void main(string[] a) {     //public ex1() { }     try {            fileinputstream file = new fileinputstream(new file("c:\\test.xls"));          //get workbook instance xls file          hssfworkbook workbook = new hssfworkbook(file);          //get first sheet workbook         hssfsheet sheet = workbook.getsheetat(0);          //iterate through each rows first sheet         iterator<row> rowiterator = sheet.iterator();         while(rowiterator.hasnext()) {             row row = rowiterator.next();              //for each row, iterate through each columns             iterator<cell> celliterator = row.celliterator();             while(celliterator.hasnext()) {                                   cell cell = celliterator.next();                  switch(cell.getcelltype()) {                     case cell.cell_type_boolean:                         system.out.print(cell.getbooleancellvalue() + "\t\t");                         break;                     case cell.cell_type_numeric:                         system.out.print(cell.getnumericcellvalue() + "\t\t");                         break;                     case cell.cell_type_string:                         system.out.print(cell.getstringcellvalue() + "\t\t");                         break;                 }             }             system.out.println("");         }         file.close();         fileoutputstream out =              new fileoutputstream(new file("c:\\test.xls"));         workbook.write(out);         out.close();      } catch (filenotfoundexception e) {      } catch (ioexception e) {          e.printstacktrace();     }      // todo auto-generated constructor stub }   } 

now receiving "could not find main class. program exit" pop error msg while attempt run. mistakes. please me. in advance...

can please try

right click on file -> run -> java application


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -