WritableWorkbook 生成excel

package com;
import java.io.File;
import java.io.IOException;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class Test 
{
	public static void main(String args[]) throws IOException, RowsExceededException, WriteException
	{
		File f = new File("D:\\内部通讯录.xls");

		f.createNewFile();
					

		WritableWorkbook wwb = null;
		wwb = Workbook.createWorkbook(f);   


		//创建Excel工作表 
		WritableSheet ws = wwb.createSheet("通讯录", 0);//创建sheet
		
		ws.mergeCells(0, 0, 5, 1);//合并单元格(左列,左行,右列,右行)从第1行第1列到第2行第3列
		Label header = new Label(0, 0, "内部通讯录"); 
		ws.addCell(header);//写入头
		Label l = new Label(0, 2, "姓名");//第3行
		ws.addCell(l);
		l = new Label(1, 2, "单位");
		ws.addCell(l);
		l = new Label(2, 2, "手机");
		ws.addCell(l);
		l = new Label(3, 2, "电话");
		ws.addCell(l);
		l = new Label(4, 2, "QQ");
		ws.addCell(l);
		l = new Label(5, 2, "邮箱");
		ws.addCell(l); 
		
		l = new Label(0, 3, "Realname");
		ws.addCell(l);
		l = new Label(1, 3, "UserDepart");
		ws.addCell(l);
		l = new Label(2, 3, "Hand_tel");
		ws.addCell(l);
		l = new Label(3, 3, "Telephone");
		ws.addCell(l);
		l = new Label(4, 3, "QQnumber");
		ws.addCell(l);
		l = new Label(5, 3, "E_mail");
		ws.addCell(l);
			 
				
				
		wwb.write();


		wwb.close();	
	}
				
}

 

展开阅读全文
©️2020 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值