Ejemplo n.º 1
0
 /**
  * 业务数据类型生成
  *
  * @param wb excel工作页
  * @param btList 模型对象数组
  */
 public void BusTypeWriter(HSSFWorkbook wb, List<PDMBusinessDataType> btList) {
   HSSFSheet sheet = wb.getSheet(BT_SHEET);
   for (int i = 0; i < btList.size(); i++) {
     HSSFRow row = sheet.createRow(i + 2);
     PDMBusinessDataType bt = btList.get(i);
     // 1
     HSSFCell cell = row.createCell(1);
     cell.setCellValue(bt.getTypeName());
     cell.setCellStyle(getTextStyle(wb));
     // 2
     cell = row.createCell(2);
     cell.setCellValue(bt.getTypeChineseName());
     cell.setCellStyle(getTextStyle(wb));
     // 3
     cell = row.createCell(3);
     cell.setCellValue(bt.getStandardTypeName());
     cell.setCellStyle(getTextStyle(wb));
     // 4
     cell = row.createCell(4);
     cell.setCellValue(bt.getLength());
     cell.setCellStyle(getTextStyle(wb));
     // 5
     cell = row.createCell(5);
     cell.setCellValue(bt.getPrecision());
     cell.setCellStyle(getTextStyle(wb));
     // 6
     cell = row.createCell(6);
     cell.setCellValue(bt.getDefaultValue());
     cell.setCellStyle(getTextStyle(wb));
     // 7
     cell = row.createCell(7);
     cell.setCellValue(bt.getComment());
     cell.setCellStyle(getTextStyle(wb));
   }
 }
Ejemplo n.º 2
0
  /**
   * 业务数据类型页读取
   *
   * @param is 需要读取的文件流
   */
  public List<PDMBusinessDataType> BusTypeReader(HSSFWorkbook wb) {
    List<PDMBusinessDataType> btList = new ArrayList<PDMBusinessDataType>();
    HSSFSheet sheet = wb.getSheet(BT_SHEET);
    if (sheet == null) {
      return btList;
    }
    HSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
    for (int i = 2; i <= sheet.getLastRowNum(); i++) {

      HSSFRow row = sheet.getRow(i);
      PDMBusinessDataType bt = new PDMBusinessDataType();
      // 1
      HSSFCell cell = row.getCell(1);
      bt.setTypeName(POIUtils.getCellStringValue(cell, evaluator));
      // 2
      cell = row.getCell(2);
      bt.setTypeChineseName(POIUtils.getCellStringValue(cell, evaluator));
      // 3
      cell = row.getCell(3);
      bt.setStandardTypeName(POIUtils.getCellStringValue(cell, evaluator));
      // 4
      cell = row.getCell(4);
      bt.setLength(POIUtils.getCellStringValue(cell, evaluator));
      // 5
      cell = row.getCell(5);
      bt.setPrecision(POIUtils.getCellStringValue(cell, evaluator));
      // 6
      cell = row.getCell(6);
      bt.setDefaultValue(POIUtils.getCellStringValue(cell, evaluator));
      // 7
      cell = row.getCell(7);
      bt.setComment(POIUtils.getCellStringValue(cell, evaluator));
      btList.add(bt);
    }
    return btList;
  }