public static void exportExcel( OutputStream os){
try {
WritableWorkbook workbook = Workbook.createWorkbook(os);
WritableSheet sheet = workbook.createSheet("Sheet", 0);
jxl.SheetSettings sheetSet = sheet.getSettings();
sheetSet.setProtected(false);
WritableFont NormalFont = new WritableFont(WritableFont.ARIAL,10);
WritableFont BoldFont = new WritableFont(WritableFont.ARIAL,10,WritableFont.BOLD);
WritableCellFormat wcf_center = new WritableCellFormat(BoldFont);
wcf_center.setBorder(Border.ALL, BorderLineStyle.THIN);
wcf_center.setVerticalAlignment(VerticalAlignment.CENTRE);
wcf_center.setAlignment(Alignment.CENTRE);
wcf_center.setWrap(false);
WritableCellFormat wcf_left = new WritableCellFormat(NormalFont);
wcf_left.setBorder(Border.NONE, BorderLineStyle.THIN);
wcf_left.setVerticalAlignment(VerticalAlignment.CENTRE);
wcf_left.setAlignment(Alignment.LEFT);
wcf_left.setWrap(false);
ArrayList<String> title = new ArrayList<>();
title.add("标题1");
for(int i=0;i<codeNames.length;i++){
title.add(codeNames[i]);
}
title.add("标题2");
for(int i=0;i<title.size();i++){
sheet.addCell(new Label(i,0,title.get(i),wcf_center));
}
for(int i=0;i<3);i++){
sheet.addCell(new Label(0,i+1,"标题1内容"+i,wcf_left));
sheet.addCell(new Label(0,i+1,"标题2内容"+i,wcf_left));
}
workbook.write();
workbook.close();
Log.d("", "exportExcel: 成功");
} catch (Exception e) {
Log.d("", "exportExcel: 失败: "+e.toString());
}
}