Search in sources :

Example 1 with ExcelHeader

use of com.bc.pmpheep.annotation.ExcelHeader in project pmph by BCSquad.

the class ExcelHelper method fromBusinessObjectList.

/**
 * 根据业务对象(BO)集合创建工作簿
 *
 * @param dataSource
 *            业务对象(BO)集合
 * @param sheetName
 *            要生成的Excel表名(非文件名)
 * @return Excel工作簿
 */
public Workbook fromBusinessObjectList(List dataSource, String sheetName) throws CheckedServiceException, IllegalArgumentException, IllegalAccessException {
    if (null == dataSource || dataSource.isEmpty()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用于导出Excel的数据源为空");
    }
    Workbook workbook = new HSSFWorkbook();
    Sheet sheet = workbook.createSheet(sheetName);
    // 生成表头
    sheet = generateHeader(sheet, dataSource.get(0).getClass());
    // 设置表头样式
    headerStyleSetup(workbook, 1);
    Field[] fields = dataSource.get(0).getClass().getDeclaredFields();
    /* 设置行计数器 */
    int rowCount = 1;
    /* 记录列数和最大列宽 */
    ColumnProperties columnProperties = new ColumnProperties(1, new int[sheet.getRow(0).getLastCellNum()]);
    /* 遍历list中的对象 */
    Iterator iterator = dataSource.iterator();
    while (iterator.hasNext()) {
        Object object = iterator.next();
        Row row = sheet.createRow(rowCount);
        /* 设置序号及宽度 */
        row.createCell(0).setCellValue(String.valueOf(rowCount));
        columnProperties.setMaxElement(0, 2);
        /* 设置列计数器 */
        columnProperties.setColCount(1);
        for (Field field : fields) {
            // 可访问性设置
            field.setAccessible(true);
            if (field.isAnnotationPresent(ExcelHeader.class)) {
                ExcelHeader excelHeader = (ExcelHeader) field.getAnnotation(ExcelHeader.class);
                String headerName = excelHeader.header();
                if (StringUtil.notEmpty(headerName)) {
                    Object o = field.get(object);
                    Cell cell = row.createCell(columnProperties.getColCount());
                    if (null != o) {
                        String value = o.toString();
                        cell.setCellValue(value);
                        if (value.length() > columnProperties.getCurrentMaxElement()) {
                            columnProperties.setCurrentMaxElement(value.length());
                        }
                    }
                    columnProperties.setColCount(columnProperties.getColCount() + 1);
                }
            }
        }
        rowCount++;
    }
    /* 样式调整 */
    return dataStyleSetup(workbook, 1, rowCount, columnProperties);
}
Also used : CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Field(java.lang.reflect.Field) Iterator(java.util.Iterator) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) ExcelHeader(com.bc.pmpheep.annotation.ExcelHeader) Cell(org.apache.poi.ss.usermodel.Cell)

Example 2 with ExcelHeader

use of com.bc.pmpheep.annotation.ExcelHeader in project pmph by BCSquad.

the class ExcelHelper method generateHeader.

private Sheet generateHeader(Sheet sheet, Class clazz) {
    Field[] fields = clazz.getDeclaredFields();
    /* 获取Excel首行,利用反射设置表头 */
    Row row = sheet.createRow(0);
    Cell numcell = row.createCell(0);
    numcell.setCellValue("序号");
    int count = 1;
    for (Field field : fields) {
        // 可访问性设置
        field.setAccessible(true);
        /* 仅查找与ExcelHeader注解匹配的表头 */
        if (field.isAnnotationPresent(ExcelHeader.class)) {
            ExcelHeader excelHeader = (ExcelHeader) field.getAnnotation(ExcelHeader.class);
            String headerName = excelHeader.header();
            if (StringUtil.notEmpty(headerName)) {
                Cell cell = row.createCell(count);
                // 设置基本列宽度
                sheet.setColumnWidth(count, (headerName.length() + 1) * 512);
                cell.setCellValue(headerName);
                count++;
            }
        }
    }
    return sheet;
}
Also used : Field(java.lang.reflect.Field) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell) ExcelHeader(com.bc.pmpheep.annotation.ExcelHeader)

Example 3 with ExcelHeader

use of com.bc.pmpheep.annotation.ExcelHeader in project pmph by BCSquad.

the class ExcelHelper method generateDeclarationEtcBOHeader.

private Sheet generateDeclarationEtcBOHeader(List<MaterialExtension> extensions, Sheet sheet) {
    Field[] fields = DeclarationEtcBO.class.getDeclaredFields();
    Row r1 = sheet.createRow(0);
    Row r2 = sheet.createRow(1);
    Cell numcell = r1.createCell(0);
    numcell.setCellValue("序号");
    CellRangeAddress region = new CellRangeAddress(0, 1, 0, 0);
    sheet.addMergedRegion(region);
    int count = 1;
    for (Field field : fields) {
        // 可访问性设置
        field.setAccessible(true);
        /* 仅查找与ExcelHeader注解匹配的表头 */
        if (field.isAnnotationPresent(ExcelHeader.class)) {
            ExcelHeader excelHeader = (ExcelHeader) field.getAnnotation(ExcelHeader.class);
            String headerName = excelHeader.header();
            if (StringUtil.notEmpty(headerName)) {
                switch(headerName) {
                    case "学习经历":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 3);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("起止时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("学校名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("所学专业");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("学历");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            break;
                        }
                    case "工作经历":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("起止时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("工作单位");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("职位");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            break;
                        }
                    case "教学经历":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("起止时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("学校名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("教学科目");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "个人成就":
                        {
                            Cell r1cell = r1.createCell(count);
                            r2.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 1, count, count);
                            sheet.setColumnWidth(count, 15 * 512);
                            sheet.addMergedRegion(region);
                            count++;
                            break;
                        }
                    case "学术兼职":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("兼职学术组织");
                            sheet.setColumnWidth(count, 7 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("级别");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("职务");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            break;
                        }
                    case "本套上版教材参编情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 4);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("教材名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("编写职务");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("是否数字编辑");
                            sheet.setColumnWidth(count, 7 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版单位");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "精品课程建设情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("课程名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("课程级别");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("全年课时");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "主编国家级规划教材情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("教材名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("标准书号");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("教材级别");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "人卫社教材编写情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 5);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("教材名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("级别");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("编写职务");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("是否数字编辑");
                            sheet.setColumnWidth(count, 7 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("标准书号");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "其他社教材编写情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 6);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("教材名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("级别");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("编写职务");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("是否数字编辑");
                            sheet.setColumnWidth(count, 7 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版社");
                            sheet.setColumnWidth(count, 4 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("标准书号");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "参加人卫慕课、数字教材编写情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r2.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 1, count, count);
                            sheet.setColumnWidth(count, 15 * 512);
                            sheet.addMergedRegion(region);
                            count++;
                            break;
                        }
                    case "科研情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("课题名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("审批单位");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("获奖情况");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "学术专著":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 4);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("专著名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("专著发表日期");
                            sheet.setColumnWidth(count, 7 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版方式");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版单位");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("出版时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "出版行业获奖情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("奖项名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("评奖单位");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("获奖时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "SCI论文投稿及影响因子情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 3);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("论文名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("期刊名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("期刊SCI影响因子");
                            sheet.setColumnWidth(count, 9 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("发表时间");
                            sheet.setColumnWidth(count, 3 * 512);
                            count++;
                            break;
                        }
                    case "临床医学获奖情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("奖项名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("奖项级别");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("获奖时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "学术荣誉授予情况":
                        {
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 0, count, count + 2);
                            sheet.addMergedRegion(region);
                            Cell r2cell = r2.createCell(count);
                            r2cell.setCellValue("荣誉名称");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("荣誉级别");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            r2cell = r2.createCell(count);
                            r2cell.setCellValue("授予时间");
                            sheet.setColumnWidth(count, 5 * 512);
                            count++;
                            break;
                        }
                    case "编写内容意向":
                        {
                            Cell r1cell = r1.createCell(count);
                            r2.createCell(count);
                            r1cell.setCellValue(headerName);
                            region = new CellRangeAddress(0, 1, count, count);
                            sheet.setColumnWidth(count, 15 * 512);
                            sheet.addMergedRegion(region);
                            count++;
                            break;
                        }
                    case "作家扩展项":
                        {
                            if (extensions == null || extensions.isEmpty()) {
                                break;
                            }
                            Cell r1cell = r1.createCell(count);
                            r1cell.setCellValue(headerName);
                            if (extensions.size() > 1) {
                                region = new CellRangeAddress(0, 0, count, count + extensions.size() - 1);
                                sheet.addMergedRegion(region);
                            }
                            for (MaterialExtension extension : extensions) {
                                Cell cell = r2.createCell(count);
                                String extensionName = extension.getExtensionName() == null ? "" : extension.getExtensionName();
                                cell.setCellValue(extensionName);
                                int length = extension.getExtensionName().length() > 10 ? 10 : extension.getExtensionName().length();
                                sheet.setColumnWidth(count, length * 512);
                                count++;
                            }
                            // count++;
                            break;
                        }
                    default:
                        Cell cell = r1.createCell(count);
                        r2.createCell(count);
                        // 设置基本列宽度
                        sheet.setColumnWidth(count, (headerName.length() + 1) * 512);
                        cell.setCellValue(headerName);
                        region = new CellRangeAddress(0, 1, count, count);
                        sheet.addMergedRegion(region);
                        count++;
                        break;
                }
            }
        }
    }
    return sheet;
}
Also used : Field(java.lang.reflect.Field) MaterialExtension(com.bc.pmpheep.back.po.MaterialExtension) Row(org.apache.poi.ss.usermodel.Row) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Cell(org.apache.poi.ss.usermodel.Cell) ExcelHeader(com.bc.pmpheep.annotation.ExcelHeader)

Example 4 with ExcelHeader

use of com.bc.pmpheep.annotation.ExcelHeader in project pmph by BCSquad.

the class ExcelHelper method fromDeclarationEtcBOList.

/**
 * 根据业务对象(包含子集合的BO)集合创建工作簿
 *
 * @param material
 *            申报表所属教材对象
 * @param extensions
 *            教材扩展项集合
 * @param dataSource
 *            业务对象(BO)集合
 * @param sheetName
 *            要生成的Excel表名(非文件名)
 * @return Excel工作簿
 */
public Workbook fromDeclarationEtcBOList(Material material, List<MaterialExtension> extensions, List<DeclarationEtcBO> dataSource, String sheetName) throws CheckedServiceException, IllegalArgumentException, IllegalAccessException {
    if (null == dataSource || dataSource.isEmpty()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用于导出Excel的数据源为空");
    }
    Workbook workbook = new HSSFWorkbook();
    Sheet sheet = workbook.createSheet(sheetName);
    // 生成表头
    sheet = generateDeclarationEtcBOHeader(extensions, sheet);
    // 设置表头样式
    headerStyleSetup(workbook, 2);
    Field[] fields = dataSource.get(0).getClass().getDeclaredFields();
    /* 设置行计数器 */
    int rowCount = 2;
    /* 记录列数和最大列宽 */
    ColumnProperties columnProperties = new ColumnProperties(1, new int[sheet.getRow(1).getLastCellNum()]);
    /* 遍历list中的对象 */
    Iterator iterator = dataSource.iterator();
    while (iterator.hasNext()) {
        Object object = iterator.next();
        Row row = sheet.createRow(rowCount);
        /* 设置序号及宽度 */
        row.createCell(0).setCellValue(String.valueOf(rowCount - 1));
        columnProperties.setMaxElement(0, 2);
        /* 设置列计数器 */
        columnProperties.setColCount(1);
        for (Field field : fields) {
            // 可访问性设置
            field.setAccessible(true);
            if (field.isAnnotationPresent(ExcelHeader.class)) {
                ExcelHeader excelHeader = (ExcelHeader) field.getAnnotation(ExcelHeader.class);
                String headerName = excelHeader.header();
                if (StringUtil.notEmpty(headerName)) {
                    switch(headerName) {
                        case "学习经历":
                            {
                                List<DecEduExp> list = (List<DecEduExp>) field.get(object);
                                columnProperties = fillDecEduExpData(list, row, columnProperties);
                                break;
                            }
                        case "工作经历":
                            {
                                List<DecWorkExp> list = (List<DecWorkExp>) field.get(object);
                                columnProperties = fillDecWorkExpData(list, row, columnProperties);
                                break;
                            }
                        case "教学经历":
                            {
                                List<DecTeachExp> list = (List<DecTeachExp>) field.get(object);
                                columnProperties = fillDecTeachExpData(list, row, columnProperties);
                                break;
                            }
                        case "个人成就":
                            {
                                DecAchievement decAchievement = (DecAchievement) field.get(object);
                                columnProperties = fillDecAchievementData(decAchievement, row, columnProperties);
                                break;
                            }
                        case "学术兼职":
                            {
                                List<DecAcade> list = (List<DecAcade>) field.get(object);
                                columnProperties = fillDecAcadeData(list, row, columnProperties);
                                break;
                            }
                        case "本套上版教材参编情况":
                            {
                                List<DecLastPosition> list = (List<DecLastPosition>) field.get(object);
                                columnProperties = fillDecLastPositionData(list, row, columnProperties);
                                break;
                            }
                        case "精品课程建设情况":
                            {
                                List<DecCourseConstruction> list = (List<DecCourseConstruction>) field.get(object);
                                columnProperties = fillDecCourseConstructionData(list, row, columnProperties);
                                break;
                            }
                        case "主编国家级规划教材情况":
                            {
                                List<DecNationalPlan> list = (List<DecNationalPlan>) field.get(object);
                                columnProperties = fillDecNationalPlanData(list, row, columnProperties);
                                break;
                            }
                        case "人卫社教材编写情况":
                            {
                                List<DecTextbookPmph> list = (List<DecTextbookPmph>) field.get(object);
                                columnProperties = fillDecTextbookPmphData(list, row, columnProperties);
                                break;
                            }
                        case "其他社教材编写情况":
                            {
                                List<DecTextbook> list = (List<DecTextbook>) field.get(object);
                                columnProperties = fillDecTextbookData(list, row, columnProperties);
                                break;
                            }
                        case "参加人卫慕课、数字教材编写情况":
                            {
                                DecMoocDigital decMoocDigital = (DecMoocDigital) field.get(object);
                                columnProperties = fillDecMoocDigitalData(decMoocDigital, row, columnProperties);
                                break;
                            }
                        case "科研情况":
                            {
                                List<DecResearch> list = (List<DecResearch>) field.get(object);
                                columnProperties = fillDecResearchData(list, row, columnProperties);
                                break;
                            }
                        case "学术专著":
                            {
                                List<DecMonograph> list = (List<DecMonograph>) field.get(object);
                                columnProperties = fillDecMonographData(list, row, columnProperties);
                                break;
                            }
                        case "出版行业获奖情况":
                            {
                                List<DecPublishReward> list = (List<DecPublishReward>) field.get(object);
                                columnProperties = fillDecPublishRewardData(list, row, columnProperties);
                                break;
                            }
                        case "SCI论文投稿及影响因子情况":
                            {
                                List<DecSci> list = (List<DecSci>) field.get(object);
                                columnProperties = fillDecSciData(list, row, columnProperties);
                                break;
                            }
                        case "临床医学获奖情况":
                            {
                                List<DecClinicalReward> list = (List<DecClinicalReward>) field.get(object);
                                columnProperties = fillDecClinicalRewardData(list, row, columnProperties);
                                break;
                            }
                        case "学术荣誉授予情况":
                            {
                                List<DecAcadeReward> list = (List<DecAcadeReward>) field.get(object);
                                columnProperties = fillDecAcadeRewardData(list, row, columnProperties);
                                break;
                            }
                        case "编写内容意向":
                            {
                                DecIntention decIntention = (DecIntention) field.get(object);
                                columnProperties = fillDecIntentionData(decIntention, row, columnProperties);
                                break;
                            }
                        case "作家扩展项":
                            {
                                if (extensions == null || extensions.isEmpty()) {
                                    break;
                                }
                                List<DecExtensionVO> list = (List<DecExtensionVO>) field.get(object);
                                columnProperties = fillDecExtensionVODataPlus(extensions, list, row, columnProperties);
                                break;
                            }
                        default:
                            Object o = field.get(object);
                            Cell cell = row.createCell(columnProperties.getColCount());
                            if (null != o) {
                                String value = o.toString();
                                cell.setCellValue(value);
                                if (value.length() > columnProperties.getCurrentMaxElement()) {
                                    columnProperties.setCurrentMaxElement(value.length());
                                }
                            }
                            columnProperties.setColCount(columnProperties.getColCount() + 1);
                            break;
                    }
                }
            }
        }
        rowCount++;
    }
    /* 样式调整 */
    workbook = dataStyleSetup(workbook, 2, rowCount, columnProperties);
    /* 以下隐藏多余的列 */
    return clearColumns(workbook, material);
}
Also used : DecMonograph(com.bc.pmpheep.back.po.DecMonograph) DecEduExp(com.bc.pmpheep.back.po.DecEduExp) DecTextbookPmph(com.bc.pmpheep.back.po.DecTextbookPmph) DecAchievement(com.bc.pmpheep.back.po.DecAchievement) DecSci(com.bc.pmpheep.back.po.DecSci) Field(java.lang.reflect.Field) DecClinicalReward(com.bc.pmpheep.back.po.DecClinicalReward) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ExcelHeader(com.bc.pmpheep.annotation.ExcelHeader) Cell(org.apache.poi.ss.usermodel.Cell) DecMoocDigital(com.bc.pmpheep.back.po.DecMoocDigital) DecTextbook(com.bc.pmpheep.back.po.DecTextbook) DecLastPosition(com.bc.pmpheep.back.po.DecLastPosition) DecPublishReward(com.bc.pmpheep.back.po.DecPublishReward) DecExtensionVO(com.bc.pmpheep.back.vo.DecExtensionVO) DecAcade(com.bc.pmpheep.back.po.DecAcade) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) DecIntention(com.bc.pmpheep.back.po.DecIntention) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) DecCourseConstruction(com.bc.pmpheep.back.po.DecCourseConstruction) Row(org.apache.poi.ss.usermodel.Row) DecTeachExp(com.bc.pmpheep.back.po.DecTeachExp) DecWorkExp(com.bc.pmpheep.back.po.DecWorkExp) Sheet(org.apache.poi.ss.usermodel.Sheet) DecResearch(com.bc.pmpheep.back.po.DecResearch) DecNationalPlan(com.bc.pmpheep.back.po.DecNationalPlan) DecAcadeReward(com.bc.pmpheep.back.po.DecAcadeReward)

Aggregations

ExcelHeader (com.bc.pmpheep.annotation.ExcelHeader)4 Field (java.lang.reflect.Field)4 Cell (org.apache.poi.ss.usermodel.Cell)4 Row (org.apache.poi.ss.usermodel.Row)4 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 Iterator (java.util.Iterator)2 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 DecAcade (com.bc.pmpheep.back.po.DecAcade)1 DecAcadeReward (com.bc.pmpheep.back.po.DecAcadeReward)1 DecAchievement (com.bc.pmpheep.back.po.DecAchievement)1 DecClinicalReward (com.bc.pmpheep.back.po.DecClinicalReward)1 DecCourseConstruction (com.bc.pmpheep.back.po.DecCourseConstruction)1 DecEduExp (com.bc.pmpheep.back.po.DecEduExp)1 DecIntention (com.bc.pmpheep.back.po.DecIntention)1 DecLastPosition (com.bc.pmpheep.back.po.DecLastPosition)1 DecMonograph (com.bc.pmpheep.back.po.DecMonograph)1 DecMoocDigital (com.bc.pmpheep.back.po.DecMoocDigital)1 DecNationalPlan (com.bc.pmpheep.back.po.DecNationalPlan)1