码迷,mamicode.com
首页 > 编程语言 > 详细

【自动化__持续集成】___java___excel__jxl改

时间:2017-09-07 23:06:04      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:logs   size   file   text   pre   get   class   line   elb   

一、代码如下

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();

}

 

}

 

}

【自动化__持续集成】___java___excel__jxl改

标签:logs   size   file   text   pre   get   class   line   elb   

原文地址:http://www.cnblogs.com/wujianbo123/p/7492194.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!