| | |
| | | public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
|
| | |
|
| | | /**
|
| | | * 用于dictType属性数据存储,避免重复查缓存
|
| | | */
|
| | | public Map<String, String> sysDictMap = new HashMap<String, String>();
|
| | |
|
| | | /**
|
| | | * Excel sheet最大行数,默认65536
|
| | | */
|
| | | public static final int sheetSize = 65536;
|
| | |
| | | }
|
| | | else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
| | | {
|
| | | val = dataFormatHandlerAdapter(val, attr);
|
| | | val = dataFormatHandlerAdapter(val, attr, null);
|
| | | }
|
| | | else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures))
|
| | | {
|
| | |
| | | }
|
| | | else if (StringUtils.isNotEmpty(dictType) && StringUtils.isNotNull(value))
|
| | | {
|
| | | cell.setCellValue(convertDictByExp(Convert.toStr(value), dictType, separator));
|
| | | if (!sysDictMap.containsKey(dictType + value))
|
| | | {
|
| | | String lable = convertDictByExp(Convert.toStr(value), dictType, separator);
|
| | | sysDictMap.put(dictType + value, lable);
|
| | | }
|
| | | cell.setCellValue(sysDictMap.get(dictType + value));
|
| | | }
|
| | | else if (value instanceof BigDecimal && -1 != attr.scale())
|
| | | {
|
| | |
| | | }
|
| | | else if (!attr.handler().equals(ExcelHandlerAdapter.class))
|
| | | {
|
| | | cell.setCellValue(dataFormatHandlerAdapter(value, attr));
|
| | | cell.setCellValue(dataFormatHandlerAdapter(value, attr, cell));
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | * @param excel 数据注解
|
| | | * @return
|
| | | */
|
| | | public String dataFormatHandlerAdapter(Object value, Excel excel)
|
| | | public String dataFormatHandlerAdapter(Object value, Excel excel, Cell cell)
|
| | | {
|
| | | try
|
| | | {
|
| | | Object instance = excel.handler().newInstance();
|
| | | Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class });
|
| | | value = formatMethod.invoke(instance, value, excel.args());
|
| | | Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class, Cell.class, Workbook.class });
|
| | | value = formatMethod.invoke(instance, value, excel.args(), cell, this.wb);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | | Excel[] excels = attrs.value();
|
| | | for (Excel attr : excels)
|
| | | {
|
| | | if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
|
| | | if (!ArrayUtils.contains(this.excludeFields, field.getName() + "." + attr.targetAttr())
|
| | | && (attr != null && (attr.type() == Type.ALL || attr.type() == type)))
|
| | | {
|
| | | field.setAccessible(true);
|
| | | fields.add(new Object[] { field, attr });
|