• 【自动化__持续集成】___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();
    		}
    	}
    
    }
    
  • 相关阅读:
    MySQL的语句执行顺序
    linux 常用命令
    scala 样例类转json字符串
    Hadoop之——HDFS的RPC机制
    Hadoop之——机架感知配置
    hadoop-2.6.0-cdh5.14.0 集群高可用搭建
    spark 运行在YARN上参数配置
    日志框架SLF4J和log4j以及logback的联系和区别
    spark的rdd.saveastextfile可以追加写入hdfs同一个文件吗?
    ojdbc14-10.2.0.1.0 jar包下载
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7492185.html
Copyright © 2020-2023  润新知