Java read data using excel

excelOperation2 Package; 

Import java.io.File; 
Import java.io.FileNotFoundException; 
Import java.util.Scanner; 

Import jxl.Cell; 
Import jxl.Sheet; 
Import jxl.Workbook; 

public class the testMain { 

    public static void main (String [ ] args) { 
        // TODO Auto-Generated Stub Method, 
        the try { 
            file file = new new file ( "Myres // a.xls"); // create a file object 
            Workbook wb = Workbook.getWorkbook (file); // from the file stream obtaining Excel workspace object (WorkBook) 
            Sheet Sheet wb.getSheet = (0); // acquired page (Sheet) from the work area   
            for (int i = 0; i <sheet.getRows (); i ++) {// print cycle Excel table content   
                for (int j = 0; j   <sheet.getColumns (); j ++) { 
                    Cell cell = sheet.getCell (j, i   );
                    System.out.printf(cell.getContents()+" ");
                }  
                System.out.println();  
            }  
        } catch (Exception e) {
            e.printStackTrace(); 
        }
    }

}

  

Guess you like

Origin www.cnblogs.com/qinyios/p/11121629.html