Examples of ExcelExportEntity


Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   * @throws Exception
   */
  private static int createCells(Drawing patriarch, int index, Object t,
      List<ExcelExportEntity> excelParams, Sheet sheet, Workbook workbook)
      throws Exception {
    ExcelExportEntity entity;
    Row row = sheet.createRow(index);
    row.setHeight((short) 350);
    int maxHeight = 1, cellNum = 0;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
      entity = excelParams.get(k);
      if (entity.getList() != null) {
        Collection<?> list = (Collection<?>) entity.getGetMethod()
            .invoke(t, new Object[] {});
        int listC = 0;
        for (Object obj : list) {
          createListCells(patriarch, index + listC, cellNum, obj,
              entity.getList(), sheet, workbook);
          listC++;
        }
        cellNum += entity.getList().size();
        if (list != null && list.size() > maxHeight) {
          maxHeight = list.size();
        }
      } else {
        Object value = getCellValue(entity, t);
        if (entity.getType() != 2) {
          createStringCell(row, cellNum++, value.toString(), entity,
              workbook);
        } else {
          createImageCell(patriarch, entity, row, cellNum++,
              value == null ? "" : value.toString(), t, workbook);
        }
      }
    }
    // 合并需要合并的单元格
    cellNum = 0;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
      entity = excelParams.get(k);
      if (entity.getList() != null) {
        cellNum += entity.getList().size();
      } else if (entity.isNeedMerge()) {
        sheet.addMergedRegion(new CellRangeAddress(index, index
            + maxHeight - 1, cellNum, cellNum));
        cellNum++;
      }
    }
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   * @param styles
   */
  private static void createListCells(Drawing patriarch, int index,
      int cellNum, Object obj, List<ExcelExportEntity> excelParams,
      Sheet sheet, Workbook workbook) throws Exception {
    ExcelExportEntity entity;
    Row row;
    if (sheet.getRow(index) == null) {
      row = sheet.createRow(index);
      row.setHeight((short) 350);
    } else {
      row = sheet.getRow(index);
    }
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
      entity = excelParams.get(k);
      Object value = getCellValue(entity, obj);
      if (entity.getType() != 2) {
        createStringCell(row, cellNum++,
            value == null ? "" : value.toString(), entity, workbook);
      } else {
        createImageCell(patriarch, entity, row, cellNum++,
            value == null ? "" : value.toString(), obj, workbook);
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   */
  private static void getAllExcelField(String targetId, Field[] fields,
      List<ExcelExportEntity> excelParams, Class<?> pojoClass,
      List<Method> getMethods) throws Exception {
    // 遍历整个filed
    ExcelExportEntity excelEntity;
    for (int i = 0; i < fields.length; i++) {
      Field field = fields[i];
      // 先判断是不是collection,在判断是不是java自带对象,之后就是我们自己的对象了
      if (ExcelPublicUtil.isNotUserExcelUserThis(field, targetId)) {
        continue;
      }
      if (ExcelPublicUtil.isCollection(field.getType())) {
        ExcelCollection excel = field
            .getAnnotation(ExcelCollection.class);
        ParameterizedType pt = (ParameterizedType) field
            .getGenericType();
        Class<?> clz = (Class<?>) pt.getActualTypeArguments()[0];
        List<ExcelExportEntity> list = new ArrayList<ExcelExportEntity>();
        getExcelFieldList(targetId,
            ExcelPublicUtil.getClassFields(clz), clz, list, null);
        excelEntity = new ExcelExportEntity();
        excelEntity.setName(getExcelName(excel.exportName(), targetId));
        excelEntity
            .setOrderNum(getCellOrder(excel.orderNum(), targetId));
        excelEntity.setGetMethod(ExcelPublicUtil.getMethod(
            field.getName(), pojoClass));
        excelEntity.setList(list);
        excelParams.add(excelEntity);
      } else if (ExcelPublicUtil.isJavaClass(field)) {
        Excel excel = field.getAnnotation(Excel.class);
        excelEntity = new ExcelExportEntity();
        excelEntity.setType(excel.exportType());
        getExcelField(targetId, field, excelEntity, excel, pojoClass);
        if (getMethods != null) {
          List<Method> newMethods = new ArrayList<Method>();
          newMethods.addAll(getMethods);
          newMethods.add(excelEntity.getGetMethod());
          excelEntity.setGetMethods(newMethods);
        }
        excelParams.add(excelEntity);
      } else {
        List<Method> newMethods = new ArrayList<Method>();
        if (getMethods != null) {
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   * @throws Exception
   */
  private static void getExcelFieldList(String targetId, Field[] fields,
      Class<?> pojoClass, List<ExcelExportEntity> list,
      List<Method> getMethods) throws Exception {
    ExcelExportEntity excelEntity;
    for (int i = 0; i < fields.length; i++) {
      Field field = fields[i];
      if (ExcelPublicUtil.isNotUserExcelUserThis(field, targetId)) {
        continue;
      }
      if (ExcelPublicUtil.isJavaClass(field)) {
        Excel excel = field.getAnnotation(Excel.class);
        excelEntity = new ExcelExportEntity();
        getExcelField(targetId, field, excelEntity, excel, pojoClass);
        if (getMethods != null) {
          List<Method> newMethods = new ArrayList<Method>();
          newMethods.addAll(getMethods);
          newMethods.add(excelEntity.getGetMethod());
          excelEntity.setGetMethods(newMethods);
        }
        list.add(excelEntity);
      } else {
        List<Method> newMethods = new ArrayList<Method>();
        if (getMethods != null) {
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   * @throws Exception
   */
  private static int createCells(Drawing patriarch, int index, Object t,
      List<ExcelExportEntity> excelParams, Sheet sheet,
      HSSFWorkbook workbook, Map<String, HSSFCellStyle> styles) throws Exception {
    ExcelExportEntity entity;
    Row row = sheet.createRow(index);
    row.setHeight((short) 350);
    int maxHeight = 1, cellNum = 0;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
      entity = excelParams.get(k);
      if (entity.getList() != null) {
        Collection<?> list = (Collection<?>) entity.getGetMethod()
            .invoke(t, new Object[] {});
        int listC = 0;
        for (Object obj : list) {
          createListCells(patriarch,index + listC, cellNum, obj,
              entity.getList(), sheet, workbook,styles);
          listC++;
        }
        cellNum += entity.getList().size();
        if (list!=null&&list.size() > maxHeight) {
          maxHeight = list.size();
        }
      } else {
        Object value = getCellValue(entity,t);
        if (entity.getType() == 1) {
          createStringCell(row, cellNum++,
              value == null ? "" : value.toString(),
              index % 2 == 0 ? getStyles(styles, false, entity.isWrap())
                  : getStyles(styles, true, entity.isWrap()),entity);
        } else {
          createImageCell(patriarch,entity, row, cellNum++, value == null ? ""
              : value.toString(),t);
        }
      }
    }
    //合并需要合并的单元格
    cellNum = 0;
    for(int k = 0, paramSize = excelParams.size(); k < paramSize; k++){
      entity = excelParams.get(k);
      if (entity.getList() != null) {
        cellNum += entity.getList().size();
      }else if (entity.isNeedMerge()) {
        sheet.addMergedRegion(new CellRangeAddress(index, index + maxHeight-1, cellNum,
            cellNum));
        cellNum++;
      }
    }
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   * @param styles
   */
  private static void createListCells(Drawing patriarch, int index, int cellNum, Object obj,
      List<ExcelExportEntity> excelParams, Sheet sheet,
      HSSFWorkbook workbook, Map<String, HSSFCellStyle> styles) throws Exception {
    ExcelExportEntity entity;
    Row row;
    if(sheet.getRow(index)==null){
      row = sheet.createRow(index);
      row.setHeight((short) 350);
    }else{
      row = sheet.getRow(index);
    }
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
      entity = excelParams.get(k);
      Object value = getCellValue(entity,obj);
      if (entity.getType() == 1) {
        createStringCell(row, cellNum++,
            value == null ? "" : value.toString(),
                row.getRowNum() % 2 == 0 ?  getStyles(styles, false, entity.isWrap())
                    : getStyles(styles,true, entity.isWrap()),entity);
      }else {
        createImageCell(patriarch,entity, row, cellNum++, value == null ? ""
            : value.toString(),obj);
      }
    }
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

    Row row1 = sheet.createRow(index + 1);
    row.setHeight((short) 450);
    int cellIndex = 0;
    CellStyle titleStyle = getTitleStyle(workbook,title);
    for (int i = 0, exportFieldTitleSize = excelParams.size(); i < exportFieldTitleSize; i++) {
      ExcelExportEntity entity = excelParams.get(i);
      createStringCell(row, cellIndex, entity.getName(), titleStyle,entity);
      if (entity.getList() != null) {
        List<ExcelExportEntity> sTitel = entity.getList();
        sheet.addMergedRegion(new CellRangeAddress(index, index,cellIndex,cellIndex
            + sTitel.size() - 1));
        for (int j = 0, size = sTitel.size(); j < size; j++) {
          createStringCell(row1, cellIndex, sTitel.get(j).getName(),
              titleStyle,entity);
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

   */
  private static void getAllExcelField(String targetId, Field[] fields,
      List<ExcelExportEntity> excelParams, Class<?> pojoClass,
      List<Method> getMethods) throws Exception {
    // 遍历整个filed
    ExcelExportEntity excelEntity;
    for (int i = 0; i < fields.length; i++) {
      Field field = fields[i];
      // 先判断是不是collection,在判断是不是java自带对象,之后就是我们自己的对象了
      if(ExcelPublicUtil.isNotUserExcelUserThis(field, targetId)){continue;}
      if (ExcelPublicUtil.isCollection(field.getType())) {
        ExcelCollection excel = field
            .getAnnotation(ExcelCollection.class);
        ParameterizedType pt = (ParameterizedType) field
            .getGenericType();
        Class<?> clz = (Class<?>) pt.getActualTypeArguments()[0];
        List<ExcelExportEntity> list = new ArrayList<ExcelExportEntity>();
        getExcelFieldList(targetId, ExcelPublicUtil.getClassFields(clz), clz,
            list, null);
        excelEntity = new ExcelExportEntity();
        excelEntity.setName(getExcelName(excel.exportName(),
            targetId));
        excelEntity.setOrderNum(getCellOrder(excel.orderNum(), targetId));
        excelEntity.setGetMethod(ExcelPublicUtil.getMethod(field.getName(),
            pojoClass));
        excelEntity.setList(list);
        excelParams.add(excelEntity);
      } else if (ExcelPublicUtil.isJavaClass(field)) {
        Excel excel = field.getAnnotation(Excel.class);
        excelEntity = new ExcelExportEntity();
        excelEntity.setType(excel.exportType());
        getExcelField(targetId, field, excelEntity, excel,
            pojoClass);
        if (getMethods != null) {
          List<Method> newMethods = new ArrayList<Method>();
          newMethods.addAll(getMethods);
          newMethods.add(excelEntity.getGetMethod());
          excelEntity.setGetMethods(newMethods);
        }
        excelParams.add(excelEntity);
      } else {
        List<Method> newMethods = new ArrayList<Method>();
        if (getMethods != null) {
View Full Code Here

Examples of org.jeecgframework.poi.excel.entity.ExcelExportEntity

     * @throws Exception
     */
  private static void getExcelFieldList(String targetId, Field[] fields,
      Class<?> pojoClass, List<ExcelExportEntity> list,
      List<Method> getMethods) throws Exception {
    ExcelExportEntity excelEntity;
    for (int i = 0; i < fields.length; i++) {
      Field field = fields[i];
      if(ExcelPublicUtil.isNotUserExcelUserThis(field, targetId)){continue;}
      if (ExcelPublicUtil.isJavaClass(field)) {
        Excel excel = field.getAnnotation(Excel.class);
        excelEntity = new ExcelExportEntity();
        getExcelField(targetId, field, excelEntity, excel,
            pojoClass);
        excelEntity.setType(excel.exportType());
        if (getMethods != null) {
          List<Method> newMethods = new ArrayList<Method>();
          newMethods.addAll(getMethods);
          newMethods.add(excelEntity.getGetMethod());
          excelEntity.setGetMethods(newMethods);
        }
        list.add(excelEntity);
      } else {
        List<Method> newMethods = new ArrayList<Method>();
        if (getMethods != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.