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

一、代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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();

}

 

}

 

}



如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
posted @   18513757531  阅读(164)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示