赞
踩
public static void createPointExcel(HttpServletRequest request, List<PointUtil> finalPointList) throws Exception {
XSSFWorkbook wb = null;
String excel = pathModel + "/point.xlsx";
File fi = new File(excel);
// 读取excel模板
wb = new XSSFWorkbook(new FileInputStream(fi));
// 读取了模板内所有sheet内容
XSSFSheet sheet = wb.getSheetAt(0);
// 在相应的单元格进行赋值 int rowIndex = 1; // int j = 1; for (PointUtil pointUtil : finalPointList) { XSSFRow row = sheet.getRow(rowIndex); if (null == row) { row = sheet.createRow(rowIndex); } for (int i = 1; i < 6; i++) { XSSFCell cell = row.getCell(i); if (null == cell) { cell = row.createCell(i); } switch (i) { case 1: //不可编辑
cell.setCellValue(pointUtil.getEQUIPMENT_CODE()); break; } } rowIndex++; } // 输出Excel文件 FileOutputStream output = new FileOutputStream(path + "/point" + System.nanoTime() + ".xlsx"); wb.write(output); output.flush(); }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。