用jxl可以很方便的生成excel文件,下面記錄使用中的一些方法:
1、對文本格式化:
WritableFont wf = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE); //粗體10號字
WritableCellFormat wcf = new WritableCellFormat(wf);
wcf.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); //設(shè)置邊框
2、數(shù)字格式化:
jxl.write.NumberFormat nf = new jxl.write.NumberFormat("#.##"); //小數(shù)位如果為0不顯示
jxl.write.NumberFormat nf = new jxl.write.NumberFormat("#.00"); //小數(shù)位不足用0補齊