/** * 生成标准字段评审文档 * * @param wb excel工作页 * @param stdList 模型对象数组 */ public void standardFieldWriter(HSSFWorkbook wb, List<PDMStandardField> stdList) { HSSFSheet sheet = wb.getSheet(STD_SHEET); for (int i = 0; i < stdList.size(); i++) { HSSFRow row = sheet.createRow(i + 2); PDMStandardField std = stdList.get(i); // 1 HSSFCell cell = row.createCell(1); cell.setCellValue(std.getOldName()); cell.setCellStyle(getTextStyle(wb)); // 2 cell = row.createCell(2); cell.setCellValue(std.getOldChineseName()); cell.setCellStyle(getTextStyle(wb)); // 3 cell = row.createCell(3); cell.setCellValue(std.getOldBusType()); cell.setCellStyle(getTextStyle(wb)); // 4 cell = row.createCell(4); String tables = ""; for (int j = 0; j < std.getBelongTableList().size(); j++) { if (j != 0) { tables = tables + ","; } tables = tables + std.getBelongTableList().get(j); } cell.setCellValue(tables); cell.setCellStyle(getTextStyle(wb)); // 5 cell = row.createCell(5); String bolongSubSystem = ""; if (std.getBolongSubSystemList().size() > 0) { bolongSubSystem = std.getBolongSubSystemList().get(0); } cell.setCellValue(bolongSubSystem); cell.setCellStyle(getTextStyle(wb)); // 6 cell = row.createCell(6); cell.setCellValue(std.getGenName()); cell.setCellStyle(getTextStyle(wb)); // 7 cell = row.createCell(7); cell.setCellValue(std.getNewName()); cell.setCellStyle(getTextStyle(wb)); // 8 cell = row.createCell(8); cell.setCellValue(std.getNewChineseName()); cell.setCellStyle(getTextStyle(wb)); // 9 cell = row.createCell(9); cell.setCellValue(std.getGenBusType()); cell.setCellStyle(getTextStyle(wb)); // 10 cell = row.createCell(10); cell.setCellValue(std.getNewBusType()); cell.setCellStyle(getTextStyle(wb)); // 11 cell = row.createCell(11); cell.setCellValue(std.getOldComment()); cell.setCellStyle(getTextStyle(wb)); // 12 cell = row.createCell(12); cell.setCellValue(std.getNewComment()); cell.setCellStyle(getTextStyle(wb)); // 13 cell = row.createCell(13); cell.setCellValue(std.getDictId()); cell.setCellStyle(getTextStyle(wb)); // 14 cell = row.createCell(14); cell.setCellValue(std.getModefyDesc()); cell.setCellStyle(getTextStyle(wb)); // 15 cell = row.createCell(15); cell.setCellValue(std.getImportPath()); cell.setCellStyle(getTextStyle(wb)); } }
/** * 标准字段列表读取 * * @param is 需要读取的文件流 */ public List<PDMStandardField> standardFieldReader(HSSFWorkbook wb) { List<PDMStandardField> stdList = new ArrayList<PDMStandardField>(); HSSFSheet sheet = wb.getSheet(STD_SHEET); if (sheet == null) { return stdList; } HSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); for (int i = 2; i <= sheet.getLastRowNum(); i++) { HSSFRow row = sheet.getRow(i); PDMStandardField std = new PDMStandardField(); stdList.add(std); // 1 HSSFCell cell = row.getCell(1); std.setOldName(POIUtils.getCellStringValue(cell, evaluator)); // 2 cell = row.getCell(2); std.setOldChineseName(POIUtils.getCellStringValue(cell, evaluator)); // 3 cell = row.getCell(3); std.setOldBusType(POIUtils.getCellStringValue(cell, evaluator)); // 4 cell = row.getCell(4); String[] tableNameArray = StringUtils.split( StringUtils.defaultIfBlank(POIUtils.getCellStringValue(cell, evaluator), ""), ",,"); for (String tableName : tableNameArray) { std.getBelongTableList().add(tableName); } // 5 cell = row.getCell(5); std.getBolongSubSystemList().add((POIUtils.getCellStringValue(cell, evaluator))); // 6 cell = row.getCell(6); std.setGenName(POIUtils.getCellStringValue(cell, evaluator)); // 7 cell = row.getCell(7); std.setNewName(POIUtils.getCellStringValue(cell, evaluator)); // 8 cell = row.getCell(8); std.setNewChineseName(POIUtils.getCellStringValue(cell, evaluator)); // 9 cell = row.getCell(9); std.setGenBusType(POIUtils.getCellStringValue(cell, evaluator)); // 10 cell = row.getCell(10); std.setNewBusType(POIUtils.getCellStringValue(cell, evaluator)); // 11 cell = row.getCell(11); std.setOldComment(POIUtils.getCellStringValue(cell, evaluator)); // 12 cell = row.getCell(12); std.setNewComment(POIUtils.getCellStringValue(cell, evaluator)); // 13 cell = row.getCell(13); std.setDictId(POIUtils.getCellStringValue(cell, evaluator)); // 14 cell = row.getCell(14); std.setModefyDesc(POIUtils.getCellStringValue(cell, evaluator)); // 15 cell = row.getCell(15); std.setImportPath(POIUtils.getCellStringValue(cell, evaluator)); } return stdList; }