zoukankan      html  css  js  c++  java
  • 【自动化__持续集成】___java___excel__jxl读

    一、代码如下

    package com.wujianbo.five;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    
    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.demo.Demo;
    import jxl.read.biff.BiffException;
    
    public class Demo05 {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		Demo05 demo05= new Demo05();
    		demo05.readExcelByJxl();
    
    	}
    	
    	public void readExcelByJxl() {
    		String path= System.getProperty("user.dir");
    		path= path + "\data\Students.xls";
    		//System.out.println(path);
    		try {
    			File file= new File(path);
    			FileInputStream fis= new FileInputStream(file);
    			jxl.Workbook rwb= Workbook.getWorkbook(fis);
    			
    			Sheet[] sheet= rwb.getSheets();
    			for(int i=0; i<sheet.length; i++) {
    				Sheet rs= rwb.getSheet(i);
    				for(int j=0; j<rs.getRows(); j++) {
    					Cell[] cells= rs.getRow(j);
    					for(int k=0;k<cells.length; k++) {
    						System.out.print(cells[k].getContents());
    						System.out.print("	");
    						
    					}
    					System.out.println();
    					
    				}
    			}
    			fis.close();
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (BiffException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IndexOutOfBoundsException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	}
    
    }
    
  • 相关阅读:
    洛谷 P1195 口袋的天空
    洛谷 P3144 [USACO16OPEN]关闭农场Closing the Farm_Silver
    Bzoj3277 串
    Bzoj1312 / POJ3155 Neerc2006 Hard Life
    Bzoj2655 calc
    51Nod 1228 序列求和
    洛谷P2901 [USACO08MAR]牛慢跑Cow Jogging
    Bzoj1042 [HAOI2008]硬币购物
    Bzoj3884 上帝与集合的正确用法
    Bzoj4161 Shlw loves matrixI
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7492185.html
Copyright © 2011-2022 走看看