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

    一、代码如下

    package com.wujianbo.five;
    
    import java.awt.HeadlessException;
    import java.awt.Label;
    import java.io.File;
    import java.io.IOException;
    
    import jxl.Workbook;
    import jxl.read.biff.BiffException;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    import jxl.write.WriteException;
    import jxl.write.biff.RowsExceededException;
    
    public class Demo07 {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		Demo07 demo07= new Demo07();
    		demo07.modifyExcelByJxl();
    	}
    	
    	private void modifyExcelByJxl() {
    		// TODO Auto-generated method stub
    		String fileName= System.getProperty("user.dir") + "\data\Students.xls";
    		try {
    			Workbook wb= Workbook.getWorkbook(new File(fileName));
    			WritableWorkbook book= Workbook.createWorkbook(new File(fileName), wb);
    			WritableSheet sheet= book.getSheet(0);
    			sheet.addCell(new jxl.write.Label(5, 3, "研究生"));
    			//sheet.addCell(new Label(5, 3, "研究生"));
    			
    			book.write();
    			book.close();
    		} catch (RowsExceededException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (HeadlessException 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 (WriteException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		
    	}
    
    }
    

    package com.wujianbo.five;

     

    import java.awt.HeadlessException;

    import java.awt.Label;

    import java.io.File;

    import java.io.IOException;

     

    import jxl.Workbook;

    import jxl.read.biff.BiffException;

    import jxl.write.WritableSheet;

    import jxl.write.WritableWorkbook;

    import jxl.write.WriteException;

    import jxl.write.biff.RowsExceededException;

     

    public class Demo07 {

     

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    Demo07 demo07= new Demo07();

    demo07.modifyExcelByJxl();

    }

     

    private void modifyExcelByJxl() {

    // TODO Auto-generated method stub

    String fileName= System.getProperty("user.dir") + "\data\Students.xls";

    try {

    Workbook wb= Workbook.getWorkbook(new File(fileName));

    WritableWorkbook book= Workbook.createWorkbook(new File(fileName), wb);

    WritableSheet sheet= book.getSheet(0);

    sheet.addCell(new jxl.write.Label(5, 3, "研究生"));

    //sheet.addCell(new Label(5, 3, "研究生"));

     

    book.write();

    book.close();

    } catch (RowsExceededException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    } catch (HeadlessException 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 (WriteException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

     

    }

     

    }

  • 相关阅读:
    模块
    关于使用 jBox 对话框的提交问题
    Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical
    Julia语言:让高性能科学计算人人可用
    [ASP.NET Web API]如何Host定义在独立程序集中的Controller
    ASHX呼叫ASPX.cs的方法
    robotlegs2.0框架实例源码带注释
    指针指向一块内存,它的内容是所指内存的地址;而引用则是某块内存的别名(转)
    老板该如何正确的犒赏程序员(转)
    Jass 技能模型定义(转)
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7492194.html
Copyright © 2011-2022 走看看