java 导出excel windows和linux服务器 通用
来源:互联网 发布:vector 数据是否连续 编辑:程序博客网 时间:2024/06/09 15:31
public boolean exportClassChargeExcel(List<ReceptionLog> costManageList) {
HttpServletResponse response = ServletActionContext.getResponse();
OutputStream os = null;
try {
os = response.getOutputStream();
} catch (IOException e1) {
}
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String curDatetime = sdf.format(cal.getTime());
response.reset();
response.setHeader("Content-disposition",
"attachment; filename=CategoryKeyWords" + curDatetime + ".xls");
response.setContentType("application/msexcel");
WritableWorkbook wwb = null;
WritableSheet ws = null;
try {
wwb = Workbook.createWorkbook(os);
ws = wwb.createSheet("访问统计日志", 0);
ws.getSettings().setDefaultColumnWidth(15); // 创建表头
WritableFont wfc = new WritableFont(WritableFont.ARIAL, 10,WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.ORANGE);
WritableCellFormat wcfFC = new WritableCellFormat(wfc);
Label lId2HeadLabel = new Label(0, 0, "序号", wcfFC);
Label strKeyWordHeadLabel = new Label(1, 0, "操作时间", wcfFC);
Label strCategoryConfigHeadLabel = new Label(2, 0, "栏目", wcfFC);
Label dtModifyTimeHeadLabel = new Label(3, 0, "机顶盒卡", wcfFC);
ws.addCell(lId2HeadLabel);
ws.addCell(strKeyWordHeadLabel);
ws.addCell(strCategoryConfigHeadLabel);
ws.addCell(dtModifyTimeHeadLabel);
Label semesterNameLabel = null;
Label projectNameLabel = null;
Label childNameLabel = null;
Label startDateLabel = null;
for (int i = 0; i <costManageList.size(); i++) {
String className = ""+costManageList.get(i).getId(); // ID
String childNum= costManageList.get(i).getOpertingtime();
String sk=costManageList.get(i).getColumnname();
String tk=costManageList.get(i).getBoxcard();
semesterNameLabel = new Label(0, i+1, className);
projectNameLabel = new Label(1, i+1, ""+childNum);
childNameLabel = new Label(2, i+1, ""+sk);
startDateLabel = new Label(3, i+1, ""+tk);
ws.addCell(semesterNameLabel);
ws.addCell(projectNameLabel);
ws.addCell(childNameLabel);
ws.addCell(startDateLabel);
}
} catch (Exception e) {
return false;
} finally {
try {
wwb.write();
wwb.close();
os.close();
} catch (WriteException e) {
} catch (IOException e) {
}
}
return true;
}
HttpServletResponse response = ServletActionContext.getResponse();
OutputStream os = null;
try {
os = response.getOutputStream();
} catch (IOException e1) {
}
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String curDatetime = sdf.format(cal.getTime());
response.reset();
response.setHeader("Content-disposition",
"attachment; filename=CategoryKeyWords" + curDatetime + ".xls");
response.setContentType("application/msexcel");
WritableWorkbook wwb = null;
WritableSheet ws = null;
try {
wwb = Workbook.createWorkbook(os);
ws = wwb.createSheet("访问统计日志", 0);
ws.getSettings().setDefaultColumnWidth(15); // 创建表头
WritableFont wfc = new WritableFont(WritableFont.ARIAL, 10,WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.ORANGE);
WritableCellFormat wcfFC = new WritableCellFormat(wfc);
Label lId2HeadLabel = new Label(0, 0, "序号", wcfFC);
Label strKeyWordHeadLabel = new Label(1, 0, "操作时间", wcfFC);
Label strCategoryConfigHeadLabel = new Label(2, 0, "栏目", wcfFC);
Label dtModifyTimeHeadLabel = new Label(3, 0, "机顶盒卡", wcfFC);
ws.addCell(lId2HeadLabel);
ws.addCell(strKeyWordHeadLabel);
ws.addCell(strCategoryConfigHeadLabel);
ws.addCell(dtModifyTimeHeadLabel);
Label semesterNameLabel = null;
Label projectNameLabel = null;
Label childNameLabel = null;
Label startDateLabel = null;
for (int i = 0; i <costManageList.size(); i++) {
String className = ""+costManageList.get(i).getId(); // ID
String childNum= costManageList.get(i).getOpertingtime();
String sk=costManageList.get(i).getColumnname();
String tk=costManageList.get(i).getBoxcard();
semesterNameLabel = new Label(0, i+1, className);
projectNameLabel = new Label(1, i+1, ""+childNum);
childNameLabel = new Label(2, i+1, ""+sk);
startDateLabel = new Label(3, i+1, ""+tk);
ws.addCell(semesterNameLabel);
ws.addCell(projectNameLabel);
ws.addCell(childNameLabel);
ws.addCell(startDateLabel);
}
} catch (Exception e) {
return false;
} finally {
try {
wwb.write();
wwb.close();
os.close();
} catch (WriteException e) {
} catch (IOException e) {
}
}
return true;
}
0 0
- java 导出excel windows和linux服务器 通用
- Java Excel 通用导出
- JAVA导出Excel通用类
- java导出excel通用类
- java导出Excel通用方法
- Java poi Excel 通用导出
- java导出Excel通用方法
- java 通用导出一个excel
- java导出Excel通用方法
- java导出Excel通用方法
- java导出Excel通用方法
- java导出Excel通用方法
- java导出Excel通用方法
- java导出excel通用方法
- 导入和导出Excel通用方法
- 通用 Excel 导出方法
- 通用excel导入导出
- 通用EXCEL导入导出
- 商标授权确权案呈现“三高”特点
- ios 音频播放循环次数(numberofloops)
- spring autowire mode
- Android 蓝牙知识
- 协同与多线程区别
- java 导出excel windows和linux服务器 通用
- 知识产权战略助燃“创新驱动”
- 简洁JS 日历控件 支持日期和月份选择
- 《算法竞赛入门经典》习题2-6 调和级数(harmony)
- DrawMeshNow用法
- mysql c连接失败的处理方法
- MeanShift算法(二)之运动目标跟踪
- 黑马程序员-java网络编程
- Android开发环境搭建教程