感觉比POI简单请口味多了
public void exportPvDetail(List list,
OutputStream sos, HttpServletRequest request)throws Exception{
WritableWorkbook wwb = Workbook.createWorkbook(sos);
WritableSheet ws = wwb.createSheet("sheet1", 0);
// 标题样式
WritableFont font = new WritableFont(WritableFont.TAHOMA, 9, WritableFont.BOLD);// 定义字体
font.setColour(Colour.BLACK);// 字体颜色
WritableCellFormat wc = new WritableCellFormat(font);
wc.setAlignment(Alignment.CENTRE); // 设置左对齐
wc.setBorder(Border.ALL, BorderLineStyle.THIN); // 设置边框线
wc.setBackground(jxl.format.Colour.YELLOW); // 设置单元格的背景颜色
WritableFont font2 = new WritableFont(WritableFont.TAHOMA, 9, WritableFont.NO_BOLD);// 定义字体
WritableCellFormat wc2 = new WritableCellFormat(font2);
wc2.setBorder(Border.ALL, BorderLineStyle.THIN); // 设置边框线
ws.addCell(new Label(0, 0, "abc",wc));
ws.addCell(new Label(1, 0, "efg",wc));
ws.addCell(new Label(2, 0, "",wc));
int colCount = 2;// 列数
int rowCount = list != null ? list.size() : 0;// 行数
for (int i = 0; i <rowCount; i++) {
ws.addCell(new Label(0, i+1,(String)((Object[])list.get(i))[0],wc2)); //列-行-值
ws.addCell(new Label(1, i+1,(String)((Object[])list.get(i))[1],wc2)); //列-行-值
ws.addCell(new Label(2, i+1,(String)((Object[])list.get(i))[2],wc2)); //列-行-值
ws.setColumnView(0, 15);// 设置列宽2
}
wwb.write();
wwb.close();
}
健忘者的脑图,步骤: