日期:2014-05-18 浏览次数:20660 次
OutputStream os=response.getOutputStream();
//String fileName = "c:\\aaa.xls";//
WritableWorkbook wbook = Workbook.createWorkbook(os);
// WritableWorkbook wbook = Workbook.createWorkbook(os); //
// 建立excel文件
WritableSheet wsheet = wbook.createSheet("固定资产表", 0); // 工作表名称
// 设置Excel字体
WritableFont wfont = new WritableFont(WritableFont.ARIAL, 10,
WritableFont.BOLD, false,
jxl.format.UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);
WritableCellFormat titleFormat = new WritableCellFormat(wfont);
String[] title = {"资产编号","部门组织","审批单号","请购单号","设备类别","资产类型","品牌","型号","用户",
"序列号","主机名","IP地址","网卡MAC地址" ,"CPU型号","显示器","显示器序列号","内存","硬盘","操作系统",
"大区/BU","省办/加工厂","存放地","安装的商用软件","备注","状态","购买日期"};
// 设置Excel表头
for (int i = 0; i < title.length; i++) {
Label excelTitle = new Label(i, 0, title[i], titleFormat);
wsheet.addCell(excelTitle);
}
int c = 1; // 用于循环时Excel的行号
for(AssetsPO temp:lsPO){
Label content1 = new Label(0, c, temp.getAssets().getAssetNo());
Label content2 = new Label(1 , c, temp.getAssets().getDeptFullName());
Label content3 = new Label(2 , c, temp.getAssets().getApprovalId());
Label content4 = new Label(3 , c, temp.getAssets().getRequistionId());
Label content5 = new Label(4 , c, temp.getDeviceName());
Label content6 = new Label(5 , c, temp.getAssetsTypeName());