wcf_name_center = new WritableCellFormat(wf_key);
wcf_name_center.setAlignment(Alignment.CENTRE);
jxl.write.NumberFormat wf_percent_float = new jxl.write.NumberFormat("0.00");
wcf_percent_float= new jxl.write.WritableCellFormat(wf_value,wf_percent_float);
wcf_percent_float.setAlignment(jxl.format.Alignment.CENTRE);
wcf_percent_float.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
wcf_percent_float.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
//WritableFont wf_title = new WritableFont(WritableFont.ARIAL,14,WritableFont.BOLD);
WritableFont wf_title = new jxl.write.WritableFont(WritableFont.createFont("微软雅黑"), 14,WritableFont.BOLD);
wcf_title = new WritableCellFormat(wf_title);
wcf_title.setAlignment(Alignment.CENTRE);
} catch (WriteException e) {
e.printStackTrace();
}
}
//生成Excel文件
public void genarateExcel(File file)throws Exception{
WritableWorkbook wb = Workbook.createWorkbook(file);
WritableSheet ws = wb.createSheet("数据报表",0);
int startRowNum=0;//起始行
int startColNum=0;//起始列
int maxColSize = 7;//最大列数
//设置列宽
ws.setColumnView(0, 18);
ws.setColumnView(2, 19);
ws.setColumnView(3, 14);
ws.setColumnView(4, 13);
ws.setColumnView(5, 11);
ws.setColumnView(6, 18);
ws.addCell(new Label(startColNum,startRowNum,"学生信息报表",wcf_title));
ws.mergeCells(startColNum,startRowNum, startColNum+maxColSize-1,startRowNum);
startColNum=0;
startRowNum++;
ws.addCell(new Label(startColNum,startRowNum, "2011年04月08日",wcf_name_right));
ws.mergeCells(startColNum,startRowNum, startColNum+maxColSize-1,startRowNum);
startColNum=0;
startRowNum++;
generateCells(ws,startRowNum++,startColNum,1,MAXCOLS);
ws.addCell(new Label(startColNum,startRowNum,"姓名",wcf_key));
ws.mergeCells(startColNum, startRowNum, startColNum+1, startRowNum);
startColNum=startColNum+2;
ws.addCell(new Label(startColNum,startRowNum,"性别",wcf_key));
ws.mergeCells(startColNum, startRowNum, startColNum+1, startRowNum);
startColNum=startColNum+2;
ws.addCell(new Label(startColNum,startRowNum,"年龄",wcf_key));
ws.mergeCells(startColNum, startRowNum, startColNum+1, startRowNum);
startColNum=startColNum+2;
ws.addCell(new Label(startColNum,startRowNum,"住址",wcf_key));
startRowNum++;
startColNum=0;
for(int i=0;i<10;i++){
int rowIndx = startRowNum+i;
ws.addCell(new Label(startColNum,rowIndx,"姓名"+i,wcf_value));
ws.mergeCells(startColNum, rowIndx, startColNum