进行信息表excel导出
@RequestMapping("exportExl") public ResponseEntity<byte[]> exportExl() throws Exception { List<Customer> clist = cs.getList(); HSSFWorkbook book = new HSSFWorkbook(); HSSFSheet sheet = book.createSheet("客户信息表"); sheet.setDefaultColumnWidth(15); //表头行创建 HSSFRow header = sheet.createRow(0); header.createCell(0).setCellValue("职工序号"); header.createCell(1).setCellValue("联系人姓名"); header.createCell(2).setCellValue("公司名称"); header.createCell(3).setCellValue("添加时间"); header.createCell(4).setCellValue("联系电话"); //clist数据写入单元格 for (int i = 0; i < clist.size(); i++) { Customer cus = clist.get(i); HSSFRow row = sheet.createRow(i + 1); row.createCell(0).setCellValue(cus.getId()); row.createCell(1).setCellValue(cus.getCompanyperson()); row.createCell(2).setCellValue(cus.getComname()); row.createCell(3).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(cus.getAddtime())); row.createCell(4).setCellValue(cus.getComphone()); |
原文地址:https://www.cnblogs.com/meani/p/12628354.html
时间: 2024-10-10 20:37:10