下图是现在要生产的excel截图:
[url]http://blog.csdn.net/beming/gallery/p_w_picpath/3437.aspx[/url]
if(!excel.exists()){
excel.createNewFile();
}
WritableWorkbook wwb = Workbook.createWorkbook(excel);
WritableSheet ws = wwb.createSheet("testexcel",0);
Label lable = null;
//对中文的支持非常好
lable = new Label(0,0,"我的中国心");
ws.addCell(lable);
//可以定义模板格式化你的cell
WritableFont wf = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
WritableCellFormat wcf = new WritableCellFormat(wf);
wcf.setBackground(Colour.WHITE);
lable = new Label(0,1,"fdsl",wcf);
ws.addCell(lable);
wf = new WritableFont(WritableFont.TIMES,18,WritableFont.BOLD,true);
wcf = new WritableCellFormat(wf);
lable = new Label(0,2,"aming",wcf);
ws.addCell(lable);
//cell的类型同样可以定义为数字类型
Number nb = new Number(0,3,21.4321321);
ws.addCell(nb);
//支持格式化你的数字串
NumberFormat nf = new NumberFormat("#.###");
wcf = new WritableCellFormat(nf);
nb = new Number(0,4,21.43254354354354,wcf);
ws.addCell(nb);
Boolean bl = new Boolean(0,5,true);
ws.addCell(bl);
DateTime dt = new DateTime(0,6,new Date());
ws.addCell(dt);
DateFormat df = new DateFormat("MM dd yyyy hh:mm:ss");
wcf = new WritableCellFormat(df);
dt = new DateTime(0,7,new Date(),wcf);
ws.addCell(dt);
//开始写文件了
wwb.write();
wwb.close();
上面的下载地址无法打开.
下载请到:[url]http://prdownloads.sourceforge.net/jexcelapi[/url]