From c7e80a9edff6ca985bb4c435e82932c137d72c50 Mon Sep 17 00:00:00 2001 From: jueyue Date: Sun, 15 Oct 2017 11:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E9=98=BF=E9=87=8C=E5=B7=B4=E5=B7=B4?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83=E6=8F=92=E4=BB=B6?= =?UTF-8?q?,=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../easypoi/cache/manager/FileLoaderImpl.java | 1 + .../cache/manager/POICacheManager.java | 6 ++-- .../excel/entity/params/ExcelBaseEntity.java | 2 +- .../entity/params/ExcelExportEntity.java | 15 ++++++---- .../entity/vo/BaseEntityTypeConstants.java | 6 ++-- .../excel/export/ExcelBatchExportServer.java | 3 +- .../excel/export/ExcelExportServer.java | 9 +++--- ...tBaseServer.java => BaseExportServer.java} | 26 ++++++++--------- .../template/ExcelExportOfTemplateUtil.java | 7 +++-- .../export/template/TemplateSumHanlder.java | 3 +- .../graph/builder/ExcelChartBuildService.java | 14 ++++----- .../graph/constant/ExcelGraphElementType.java | 4 +-- .../excel/graph/constant/ExcelGraphType.java | 4 +-- .../excel/graph/entity/ExcelGraphDefined.java | 17 +++++++---- .../excel/graph/entity/ExcelGraphElement.java | 2 +- .../easypoi/excel/html/ExcelToHtmlServer.java | 14 +++++---- .../excel/html/css/CssParseServer.java | 9 +++--- .../excel/html/helper/CellValueHelper.java | 9 +++--- .../excel/html/helper/StylerHelper.java | 29 ++++++++++++------- .../excel/imports/ExcelImportServer.java | 15 +++++----- .../excel/imports/base/ImportBaseService.java | 2 +- .../excel/imports/sax/SheetHandler.java | 4 +-- .../excel/imports/sax/parse/SaxRowRead.java | 2 +- .../easypoi/pdf/export/PdfExportServer.java | 2 +- .../afterturn/easypoi/util/PoiCellUtil.java | 3 +- .../afterturn/easypoi/util/PoiCssUtils.java | 11 +++++-- .../easypoi/util/PoiFunctionUtil.java | 6 ++-- .../afterturn/easypoi/util/PoiPublicUtil.java | 18 ++++++------ .../easypoi/util/PoiReflectorUtil.java | 2 +- .../easypoi/util/PoiSheetUtility.java | 14 ++++++--- .../easypoi/util/PoiValidationUtil.java | 8 ++--- .../easypoi/word/entity/MyXWPFDocument.java | 12 ++++---- .../word/parse/excel/ExcelEntityParse.java | 2 +- 33 files changed, 162 insertions(+), 119 deletions(-) rename easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/{ExportBaseServer.java => BaseExportServer.java} (96%) diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoaderImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoaderImpl.java index 799043f..bbd20d4 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoaderImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoaderImpl.java @@ -37,6 +37,7 @@ public class FileLoaderImpl implements IFileLoader { private static final Logger LOGGER = LoggerFactory.getLogger(FileLoaderImpl.class); + @Override public byte[] getFile(String url) { InputStream fileis = null; ByteArrayOutputStream baos = null; diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/POICacheManager.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/POICacheManager.java index b65aee0..3948ba5 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/POICacheManager.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/POICacheManager.java @@ -52,8 +52,9 @@ public final class POICacheManager { .build(new CacheLoader() { @Override public byte[] load(String url) throws Exception { - if (LOCAL_FILELOADER.get() != null) + if (LOCAL_FILELOADER.get() != null) { return LOCAL_FILELOADER.get().getFile(url); + } return fileLoder.getFile(url); } }); @@ -81,8 +82,9 @@ public final class POICacheManager { * @param fileLoder */ public static void setFileLoderOnce(IFileLoader fileLoder) { - if (fileLoder != null) + if (fileLoder != null) { LOCAL_FILELOADER.set(fileLoder); + } } public static void setLoadingCache(LoadingCache loadingCache) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelBaseEntity.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelBaseEntity.java index 834e2d4..2901bfa 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelBaseEntity.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelBaseEntity.java @@ -37,7 +37,7 @@ public class ExcelBaseEntity { /** * 对应type */ - private int type = BaseEntityTypeConstants.StringType; + private int type = BaseEntityTypeConstants.STRING_TYPE; /** * 数据库格式 */ diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java index eabea73..cd7e890 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java @@ -212,18 +212,23 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable entityList, Collection dataSet, Sheet sheet) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportServer.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportServer.java index 8bf718e..ed72e91 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportServer.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportServer.java @@ -34,7 +34,7 @@ import cn.afterturn.easypoi.excel.annotation.ExcelTarget; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; -import cn.afterturn.easypoi.excel.export.base.ExportBaseServer; +import cn.afterturn.easypoi.excel.export.base.BaseExportServer; import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler; import cn.afterturn.easypoi.exception.excel.ExcelExportException; import cn.afterturn.easypoi.exception.excel.enums.ExcelExportEnum; @@ -46,10 +46,10 @@ import cn.afterturn.easypoi.util.PoiPublicUtil; * * @author JueYue 2014年6月17日 下午5:30:54 */ -public class ExcelExportServer extends ExportBaseServer { +public class ExcelExportServer extends BaseExportServer { // 最大行数,超过自动多Sheet - private int MAX_NUM = 60000; + private static int MAX_NUM = 60000; protected int createHeaderAndTitle(ExportParams entity, Sheet sheet, Workbook workbook, List excelParams) { @@ -175,8 +175,9 @@ public class ExcelExportServer extends ExportBaseServer { Object t = its.next(); index += createCells(patriarch, index, t, excelParams, sheet, workbook, rowHeight); tempList.add(t); - if (index >= MAX_NUM) + if (index >= MAX_NUM) { break; + } } if (entity.getFreezeCol() != 0) { sheet.createFreezePane(entity.getFreezeCol(), 0, entity.getFreezeCol(), 0); diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportBaseServer.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportServer.java similarity index 96% rename from easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportBaseServer.java rename to easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportServer.java index 3d8b80a..caaa468 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportBaseServer.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportServer.java @@ -28,8 +28,6 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFRichTextString; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.text.DecimalFormat; import java.util.Collection; @@ -56,7 +54,7 @@ import cn.afterturn.easypoi.util.PoiPublicUtil; * @author JueYue 2014年6月17日 下午6:15:13 */ @SuppressWarnings("unchecked") -public abstract class ExportBaseServer extends ExportCommonServer { +public abstract class BaseExportServer extends ExportCommonServer { private int currentIndex = 0; @@ -100,7 +98,7 @@ public abstract class ExportBaseServer extends ExportCommonServer { } else { Object value = getCellValue(entity, t); - if (entity.getType() == BaseEntityTypeConstants.StringType) { + if (entity.getType() == BaseEntityTypeConstants.STRING_TYPE) { createStringCell(row, cellNum++, value == null ? "" : value.toString(), index % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity); @@ -110,7 +108,7 @@ public abstract class ExportBaseServer extends ExportCommonServer { row.getSheet().getWorkbook().getCreationHelper(), t, entity.getName(), value)); } - } else if (entity.getType() == BaseEntityTypeConstants.DoubleType) { + } else if (entity.getType() == BaseEntityTypeConstants.DOUBLE_TYPE) { createDoubleCell(row, cellNum++, value == null ? "" : value.toString(), index % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity); @@ -193,7 +191,7 @@ public abstract class ExportBaseServer extends ExportCommonServer { } private int createIndexCell(Row row, int index, ExcelExportEntity excelExportEntity) { - if (excelExportEntity.getName() != null && excelExportEntity.getName().equals("序号") && excelExportEntity.getFormat() != null + if (excelExportEntity.getName() != null && "序号".equals(excelExportEntity.getName()) && excelExportEntity.getFormat() != null && excelExportEntity.getFormat().equals(PoiBaseConstants.IS_ADD_INDEX)) { createStringCell(row, 0, currentIndex + "", index % 2 == 0 ? getStyles(false, null) : getStyles(true, null), null); @@ -221,7 +219,7 @@ public abstract class ExportBaseServer extends ExportCommonServer { for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) { entity = excelParams.get(k); Object value = getCellValue(entity, obj); - if (entity.getType() == BaseEntityTypeConstants.StringType) { + if (entity.getType() == BaseEntityTypeConstants.STRING_TYPE) { createStringCell(row, cellNum++, value == null ? "" : value.toString(), row.getRowNum() % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity); @@ -231,7 +229,7 @@ public abstract class ExportBaseServer extends ExportCommonServer { row.getSheet().getWorkbook().getCreationHelper(), obj, entity.getName(), value)); } - } else if (entity.getType() == BaseEntityTypeConstants.DoubleType) { + } else if (entity.getType() == BaseEntityTypeConstants.DOUBLE_TYPE) { createDoubleCell(row, cellNum++, value == null ? "" : value.toString(), index % 2 == 0 ? getStyles(false, entity) : getStyles(true, entity), entity); if (entity.isHyperlink()) { @@ -257,13 +255,13 @@ public abstract class ExportBaseServer extends ExportCommonServer { cell.setCellValue(Double.parseDouble(text)); cell.setCellType(Cell.CELL_TYPE_NUMERIC); } else { - RichTextString Rtext; + RichTextString rtext; if (type.equals(ExcelType.HSSF)) { - Rtext = new HSSFRichTextString(text); + rtext = new HSSFRichTextString(text); } else { - Rtext = new XSSFRichTextString(text); + rtext = new XSSFRichTextString(text); } - cell.setCellValue(Rtext); + cell.setCellValue(rtext); } if (style != null) { cell.setCellStyle(style); @@ -330,9 +328,9 @@ public abstract class ExportBaseServer extends ExportCommonServer { */ public int getImageType(byte[] value) { String type = PoiPublicUtil.getFileExtendName(value); - if (type.equalsIgnoreCase("JPG")) { + if ("JPG".equalsIgnoreCase(type)) { return Workbook.PICTURE_TYPE_JPEG; - } else if (type.equalsIgnoreCase("PNG")) { + } else if ("PNG".equalsIgnoreCase(type)) { return Workbook.PICTURE_TYPE_PNG; } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/ExcelExportOfTemplateUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/ExcelExportOfTemplateUtil.java index 086dbb4..809af4e 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/ExcelExportOfTemplateUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/ExcelExportOfTemplateUtil.java @@ -47,7 +47,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.afterturn.easypoi.excel.entity.params.ExcelForEachParams; -import cn.afterturn.easypoi.excel.export.base.ExportBaseServer; +import cn.afterturn.easypoi.excel.export.base.BaseExportServer; import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler; import cn.afterturn.easypoi.excel.export.template.TemplateSumHanlder.TemplateSumEntity; import cn.afterturn.easypoi.excel.html.helper.MergedRegionHelper; @@ -64,7 +64,7 @@ import cn.afterturn.easypoi.util.PoiSheetUtility; * 2013-10-17 * @version 1.0 */ -public final class ExcelExportOfTemplateUtil extends ExportBaseServer { +public final class ExcelExportOfTemplateUtil extends BaseExportServer { private static final Logger LOGGER = LoggerFactory .getLogger(ExcelExportOfTemplateUtil.class); @@ -517,8 +517,9 @@ public final class ExcelExportOfTemplateUtil extends ExportBaseServer { : getStyles(true, size >= j - columnIndex ? null : columns.get(j - columnIndex)); //返回的styler不为空时才使用,否则使用Excel设置的,更加推荐Excel设置的样式 - if (style != null) + if (style != null) { row.getCell(j).setCellStyle(style); + } } } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/TemplateSumHanlder.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/TemplateSumHanlder.java index 5007039..eba6f49 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/TemplateSumHanlder.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/TemplateSumHanlder.java @@ -78,8 +78,9 @@ public class TemplateSumHanlder { } public void addValueOfKey(String key, String val) { - if (StringUtils.isNoneEmpty(key)) + if (StringUtils.isNoneEmpty(key)) { sumMap.get(key).setValue(sumMap.get(key).getValue() + Double.valueOf(val)); + } } public List getDataList() { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/builder/ExcelChartBuildService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/builder/ExcelChartBuildService.java index 6d49b6a..cb5f368 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/builder/ExcelChartBuildService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/builder/ExcelChartBuildService.java @@ -88,7 +88,7 @@ public class ExcelChartBuildService ExcelGraphElement categoryElement=graph.getCategory(); ChartDataSource categoryChart; - if(categoryElement!=null&&categoryElement.getElementType()==ExcelGraphElementType.StringType){ + if(categoryElement!=null&& categoryElement.getElementType().equals(ExcelGraphElementType.STRING_TYPE)){ categoryChart=DataSources.fromStringCellRange(dataSourceSheet, new CellRangeAddress(categoryElement.getStartRowNum(),categoryElement.getEndRowNum(),categoryElement.getStartColNum(),categoryElement.getEndColNum())); }else{ categoryChart=DataSources.fromNumericCellRange(dataSourceSheet, new CellRangeAddress(categoryElement.getStartRowNum(),categoryElement.getEndRowNum(),categoryElement.getStartColNum(),categoryElement.getEndColNum())); @@ -103,7 +103,7 @@ public class ExcelChartBuildService } } - if(graph.getGraphType()==ExcelGraphType.LineChart){ + if(graph.getGraphType().equals(ExcelGraphType.LINE_CHART)){ LineChartData data = chart.getChartDataFactory().createLineChartData(); buildLineChartData(data, categoryChart, chartValueList, graph.getTitle()); chart.plot(data, bottomAxis, leftAxis); @@ -220,8 +220,8 @@ public class ExcelChartBuildService { int i=0; for(ChartDataSource source:chartValueList){ - String _title=title.get(i); - if(StringUtils.isNotBlank(_title)){ + String temp_title=title.get(i); + if(StringUtils.isNotBlank(temp_title)){ //data.addSerie(categoryChart, source).setTitle(_title); }else{ //data.addSerie(categoryChart, source); @@ -249,9 +249,9 @@ public class ExcelChartBuildService { int i=0; for(ChartDataSource source:chartValueList){ - String _title=title.get(i); - if(StringUtils.isNotBlank(_title)){ - data.addSerie(categoryChart, source).setTitle(_title); + String temp_title=title.get(i); + if(StringUtils.isNotBlank(temp_title)){ + data.addSerie(categoryChart, source).setTitle(temp_title); }else{ data.addSerie(categoryChart, source); } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphElementType.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphElementType.java index ea5f09e..2d83503 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphElementType.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphElementType.java @@ -11,6 +11,6 @@ package cn.afterturn.easypoi.excel.graph.constant; */ public interface ExcelGraphElementType { - public static final Integer StringType=1; - public static final Integer NumericType=2; + public static final Integer STRING_TYPE =1; + public static final Integer NUMERIC_TYPE =2; } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphType.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphType.java index fe5b65a..f1097ce 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphType.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/constant/ExcelGraphType.java @@ -11,7 +11,7 @@ package cn.afterturn.easypoi.excel.graph.constant; */ public interface ExcelGraphType { - public static final Integer LineChart=1; - public static final Integer ScatterChart=2; + public static final Integer LINE_CHART =1; + public static final Integer SCATTER_CHART =2; } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphDefined.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphDefined.java index fc25d22..7bd5ca2 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphDefined.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphDefined.java @@ -20,10 +20,11 @@ public class ExcelGraphDefined implements ExcelGraph private ExcelGraphElement category; public List valueList=Lists.newArrayList(); public List titleCell=Lists.newArrayList(); - private Integer graphType=ExcelGraphType.LineChart; + private Integer graphType=ExcelGraphType.LINE_CHART; public List title=Lists.newArrayList(); - public ExcelGraphElement getCategory() + @Override + public ExcelGraphElement getCategory() { return category; } @@ -31,7 +32,8 @@ public class ExcelGraphDefined implements ExcelGraph { this.category = category; } - public List getValueList() + @Override + public List getValueList() { return valueList; } @@ -40,7 +42,8 @@ public class ExcelGraphDefined implements ExcelGraph this.valueList = valueList; } - public Integer getGraphType() + @Override + public Integer getGraphType() { return graphType; } @@ -48,7 +51,8 @@ public class ExcelGraphDefined implements ExcelGraph { this.graphType = graphType; } - public List getTitleCell() + @Override + public List getTitleCell() { return titleCell; } @@ -56,7 +60,8 @@ public class ExcelGraphDefined implements ExcelGraph { this.titleCell = titleCell; } - public List getTitle() + @Override + public List getTitle() { return title; } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphElement.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphElement.java index 1841982..9c65630 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphElement.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/graph/entity/ExcelGraphElement.java @@ -18,7 +18,7 @@ public class ExcelGraphElement private Integer endRowNum; private Integer startColNum; private Integer endColNum; - private Integer elementType=ExcelGraphElementType.StringType; + private Integer elementType=ExcelGraphElementType.STRING_TYPE; public Integer getStartRowNum() diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlServer.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlServer.java index 2121577..892dd62 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlServer.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlServer.java @@ -71,7 +71,7 @@ public class ExcelToHtmlServer { this.sheetNum = params.getSheetNum(); cssRandom = (int) Math.ceil(Math.random() * 1000); this.imageCachePath = params.getPath(); - today = DATE_FORMAT.format(new Date()); + today = new SimpleDateFormat("yyyy_MM_dd").format(new Date()); } public String printPage() { @@ -101,8 +101,9 @@ public class ExcelToHtmlServer { } catch (Exception e) { LOGGER.error(e.getMessage(), e); } finally { - if (out != null) + if (out != null) { out.close(); + } } return null; } @@ -125,8 +126,9 @@ public class ExcelToHtmlServer { } private void ensureOut() { - if (out == null) + if (out == null) { out = new Formatter(new StringBuilder()); + } } private void printSheets() { @@ -159,8 +161,9 @@ public class ExcelToHtmlServer { } private void ensureColumnBounds(Sheet sheet) { - if (gotBounds) + if (gotBounds) { return; + } Iterator iter = sheet.rowIterator(); firstColumn = (iter.hasNext() ? Integer.MAX_VALUE : 0); @@ -301,8 +304,9 @@ public class ExcelToHtmlServer { } private String styleName(CellStyle style) { - if (style == null) + if (style == null) { return ""; + } return String.format("style_%02x_%s font_%s_%s", style.getIndex(), cssRandom, style.getFontIndex(), cssRandom); } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/CssParseServer.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/CssParseServer.java index 903c165..a1c51e0 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/CssParseServer.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/CssParseServer.java @@ -28,6 +28,9 @@ public class CssParseServer { private static final Logger log = LoggerFactory.getLogger(CssParseServer.class); + private static final Pattern STYLE_PATTERN = Pattern.compile("(?:^|\\s+)(italic|oblique)(?:\\s+|$)"); + private static final Pattern WEIGHT_PATTERN = Pattern.compile("(?:^|\\s+)(bold(?:er)?|[7-9]00)(?:\\s+|$)"); + @SuppressWarnings("serial") private final static Set BORDER_STYLES = new HashSet() { { @@ -193,8 +196,7 @@ public class CssParseServer { font.replaceAll("^|\\s*" + StringUtils.join(ignoreStyles, "|") + "\\s+|$", " ")); log.debug("Font Attr [{}] After Process Ingore.", sbFont); // style - Matcher m = Pattern.compile("(?:^|\\s+)(italic|oblique)(?:\\s+|$)") - .matcher(sbFont.toString()); + Matcher m = STYLE_PATTERN.matcher(sbFont.toString()); if (m.find()) { sbFont.setLength(0); if (log.isDebugEnabled()) { @@ -205,8 +207,7 @@ public class CssParseServer { m.appendTail(sbFont); } // weight - m = Pattern.compile("(?:^|\\s+)(bold(?:er)?|[7-9]00)(?:\\s+|$)") - .matcher(sbFont.toString()); + m = WEIGHT_PATTERN.matcher(sbFont.toString()); if (m.find()) { sbFont.setLength(0); if (log.isDebugEnabled()) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/CellValueHelper.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/CellValueHelper.java index 8394fd4..20f4e46 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/CellValueHelper.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/CellValueHelper.java @@ -31,14 +31,15 @@ public class CellValueHelper { public CellValueHelper(Workbook wb, int cssRandom) { this.cssRandom = cssRandom; - if (wb instanceof HSSFWorkbook) + if (wb instanceof HSSFWorkbook) { is07 = false; - else if (wb instanceof XSSFWorkbook) { + }else if (wb instanceof XSSFWorkbook) { is07 = true; cacheFontInfo(wb); - } else + } else { throw new IllegalArgumentException( - "unknown workbook type: " + wb.getClass().getSimpleName()); + "unknown workbook type: " + wb.getClass().getSimpleName()); + } } /** diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/StylerHelper.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/StylerHelper.java index 56d9a90..a6a0ef2 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/StylerHelper.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/helper/StylerHelper.java @@ -69,13 +69,14 @@ public class StylerHelper { this.out = out; this.sheetNum = sheetNum; this.cssRandom = cssRandom; - if (wb instanceof HSSFWorkbook) + if (wb instanceof HSSFWorkbook) { helper = new HSSFHtmlHelper((HSSFWorkbook) wb); - else if (wb instanceof XSSFWorkbook) + } else if (wb instanceof XSSFWorkbook) { helper = new XSSFHtmlHelper((XSSFWorkbook) wb); - else + } else { throw new IllegalArgumentException( - "unknown workbook type: " + wb.getClass().getSimpleName()); + "unknown workbook type: " + wb.getClass().getSimpleName()); + } printInlineStyle(wb); } @@ -157,10 +158,12 @@ public class StylerHelper { } private void fontStyle(Font font) { - if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) + if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) { out.format(" font-weight: bold;%n"); - if (font.getItalic()) + } + if (font.getItalic()) { out.format(" font-style: italic;%n"); + } out.format(" font-family: %s;%n", font.getFontName()); int fontheight = font.getFontHeightInPoints(); @@ -181,8 +184,9 @@ public class StylerHelper { } private String styleName(CellStyle style) { - if (style == null) + if (style == null) { return ""; + } return String.format("style_%02x_%s", style.getIndex(), cssRandom); } @@ -209,13 +213,14 @@ public class StylerHelper { private final HSSFWorkbook wb; private final HSSFPalette colors; - private HSSFColor HSSF_AUTO = new HSSFColor.AUTOMATIC(); + private HSSFColor hssfAuto = new HSSFColor.AUTOMATIC(); public HSSFHtmlHelper(HSSFWorkbook wb) { this.wb = wb; colors = wb.getCustomPalette(); } + @Override public void colorStyles(CellStyle style, Formatter out) { HSSFCellStyle cs = (HSSFCellStyle) style; out.format(" /* fill pattern = %d */%n", cs.getFillPattern()); @@ -225,7 +230,7 @@ public class StylerHelper { private void styleColor(Formatter out, String attr, short index) { HSSFColor color = colors.getColor(index); - if (index == HSSF_AUTO.getIndex() || color == null) { + if (index == hssfAuto.getIndex() || color == null) { out.format(" /* %s: index = %d */%n", attr, index); } else { short[] rgb = color.getTriplet(); @@ -234,6 +239,7 @@ public class StylerHelper { } } + @Override public void styleColor(Formatter out, String attr, Color color) { if (color == null) { return; @@ -254,16 +260,19 @@ public class StylerHelper { public XSSFHtmlHelper(XSSFWorkbook wb) { } + @Override public void colorStyles(CellStyle style, Formatter out) { XSSFCellStyle cs = (XSSFCellStyle) style; styleColor(out, "background-color", cs.getFillForegroundXSSFColor()); styleColor(out, "color", cs.getFont().getXSSFColor()); } + @Override public void styleColor(Formatter out, String attr, Color color) { XSSFColor xSSFColor = (XSSFColor) color; - if (color == null || xSSFColor.isAuto()) + if (color == null || xSSFColor.isAuto()) { return; + } byte[] rgb = xSSFColor.getRGB(); if (rgb == null) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportServer.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportServer.java index 460f452..84d401a 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportServer.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportServer.java @@ -142,7 +142,7 @@ public class ExcelImportServer extends ImportBaseService { */ private String getSaveUrl(ExcelImportEntity excelImportEntity, Object object) throws Exception { String url = ""; - if (excelImportEntity.getSaveUrl().equals("upload")) { + if ("upload".equals(excelImportEntity.getSaveUrl())) { if (excelImportEntity.getMethods() != null && excelImportEntity.getMethods().size() > 0) { object = getFieldBySomeMethod(excelImportEntity.getMethods(), object); @@ -162,7 +162,7 @@ public class ExcelImportServer extends ImportBaseService { List excelCollection = new ArrayList(); String targetId = null; if (!Map.class.equals(pojoClass)) { - Field fileds[] = PoiPublicUtil.getClassFields(pojoClass); + Field[] fileds = PoiPublicUtil.getClassFields(pojoClass); ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class); if (etarget != null) { targetId = etarget.value(); @@ -267,8 +267,9 @@ public class ExcelImportServer extends ImportBaseService { if (params.getVerifyHanlder() != null) { ExcelVerifyHanlderResult result = params.getVerifyHanlder().verifyHandler(object); if (!result.isSuccess()) { - if (cell == null) + if (cell == null) { cell = row.createCell(row.getLastCellNum()); + } cell.setCellValue((StringUtils.isNoneBlank(cell.getStringCellValue()) ? cell.getStringCellValue() + "," : "") + result.getMsg()); if (object instanceof IExcelModel) { @@ -372,7 +373,7 @@ public class ExcelImportServer extends ImportBaseService { for (int i = params.getStartSheetIndex(); i < params.getStartSheetIndex() + params.getSheetNum(); i++) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug(" start to read excel by is ,startTime is {}", new Date().getTime()); + LOGGER.debug(" start to read excel by is ,startTime is {}", System.currentTimeMillis()); } if (isXSSFWorkbook) { pictures = PoiPublicUtil.getSheetPictrues07((XSSFSheet) book.getSheetAt(i), @@ -382,16 +383,16 @@ public class ExcelImportServer extends ImportBaseService { (HSSFWorkbook) book); } if (LOGGER.isDebugEnabled()) { - LOGGER.debug(" end to read excel by is ,endTime is {}", new Date().getTime()); + LOGGER.debug(" end to read excel by is ,endTime is {}", System.currentTimeMillis()); } result.addAll(importExcel(result, book.getSheetAt(i), pojoClass, params, pictures)); if (LOGGER.isDebugEnabled()) { - LOGGER.debug(" end to read excel list by pos ,endTime is {}", new Date().getTime()); + LOGGER.debug(" end to read excel list by pos ,endTime is {}", System.currentTimeMillis()); } if (params.isReadSingleCell()) { readSingleCell(importResult, book.getSheetAt(i), params); if (LOGGER.isDebugEnabled()) { - LOGGER.debug(" read Key-Value ,endTime is {}", new Date().getTime()); + LOGGER.debug(" read Key-Value ,endTime is {}", System.currentTimeMillis()); } } } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java index 091f44f..f836ce4 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/base/ImportBaseService.java @@ -222,7 +222,7 @@ public class ImportBaseService { */ public String getSaveExcelUrl(ImportParams params, Class pojoClass) throws Exception { String url = ""; - if (params.getSaveUrl().equals("upload/excelUpload")) { + if ("upload/excelUpload".equals(params.getSaveUrl())) { url = pojoClass.getName().split("\\.")[pojoClass.getName().split("\\.").length - 1]; return params.getSaveUrl() + "/" + url; } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/SheetHandler.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/SheetHandler.java index 9ad0954..60c7cfa 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/SheetHandler.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/SheetHandler.java @@ -108,7 +108,7 @@ public class SheetHandler extends DefaultHandler { // 将单元格内容加入rowlist中,在这之前先去掉字符串前后的空白符 } else if ("v".equals(name)) { String value = lastContents.trim(); - value = value.equals("") ? " " : value; + value = "".equals(value) ? " " : value; if (CellValueType.Date.equals(type)) { Date date = HSSFDateUtil.getJavaDate(Double.valueOf(value)); rowlist.add(curCol, new SaxReadCellEntity(CellValueType.Date, date)); @@ -119,7 +119,7 @@ public class SheetHandler extends DefaultHandler { rowlist.add(curCol, new SaxReadCellEntity(CellValueType.String, value)); } curCol++; - } else if (name.equals("row")) {//如果标签名称为 row ,这说明已到行尾,调用 optRows() 方法 + } else if ("row".equals(name)) {//如果标签名称为 row ,这说明已到行尾,调用 optRows() 方法 read.parse(curRow, rowlist); rowlist.clear(); curRow++; diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/parse/SaxRowRead.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/parse/SaxRowRead.java index 25d3d65..4106654 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/parse/SaxRowRead.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/sax/parse/SaxRowRead.java @@ -83,7 +83,7 @@ public class SaxRowRead extends ImportBaseService implements ISaxRowRead { private void initParams(Class pojoClass, ImportParams params) { try { - Field fileds[] = PoiPublicUtil.getClassFields(pojoClass); + Field[] fileds = PoiPublicUtil.getClassFields(pojoClass); ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class); if (etarget != null) { targetId = etarget.value(); diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/pdf/export/PdfExportServer.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/pdf/export/PdfExportServer.java index 0281545..83af998 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/pdf/export/PdfExportServer.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/pdf/export/PdfExportServer.java @@ -87,7 +87,7 @@ public class PdfExportServer extends ExportCommonServer { //excelParams.add(indexExcelEntity(entity)); } // 得到所有字段 - Field fileds[] = PoiPublicUtil.getClassFields(pojoClass); + Field[] fileds = PoiPublicUtil.getClassFields(pojoClass); ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class); String targetId = etarget == null ? null : etarget.value(); getAllExcelField(entity.getExclusions(), targetId, fileds, excelParams, pojoClass, diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCellUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCellUtil.java index 8c8f201..3cde637 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCellUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCellUtil.java @@ -100,8 +100,9 @@ public class PoiCellUtil { * @return */ public static String getCellValue(Cell cell) { - if (cell == null) + if (cell == null) { return ""; + } if (cell.getCellType() == Cell.CELL_TYPE_STRING) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCssUtils.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCssUtils.java index 021a1f1..d8a9fe9 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCssUtils.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiCssUtils.java @@ -27,6 +27,11 @@ public class PoiCssUtils { private static final String COLOR_PATTERN_VALUE_LONG = "^(#(?:[a-f]|\\d{2}){3})$"; // matches #rgb(r, g, b) private static final String COLOR_PATTERN_RGB = "^(rgb\\s*\\(\\s*(.+)\\s*,\\s*(.+)\\s*,\\s*(.+)\\s*\\))$"; + + private static final Pattern COLOR_PATTERN_VALUE_SHORT_PATTERN = Pattern.compile("([a-f]|\\d)"); + private static final Pattern INT_PATTERN = Pattern.compile("^(\\d+)(?:\\w+|%)?$"); + private static final Pattern INT_AND_PER_PATTERN = Pattern.compile("^(\\d*\\.?\\d+)\\s*(%)?$"); + // color name -> POI Color private static Map colors = new HashMap(); // static init @@ -67,7 +72,7 @@ public class PoiCssUtils { public static int getInt(String strValue) { int value = 0; if (StringUtils.isNotBlank(strValue)) { - Matcher m = Pattern.compile("^(\\d+)(?:\\w+|%)?$").matcher(strValue); + Matcher m = INT_PATTERN.matcher(strValue); if (m.find()) { value = Integer.parseInt(m.group(1)); } @@ -98,7 +103,7 @@ public class PoiCssUtils { if (color.matches(COLOR_PATTERN_VALUE_SHORT)) { log.debug("Short Hex Color [{}] Found.", color); StringBuffer sbColor = new StringBuffer(); - Matcher m = Pattern.compile("([a-f]|\\d)").matcher(color); + Matcher m = COLOR_PATTERN_VALUE_SHORT_PATTERN.matcher(color); while (m.find()) { m.appendReplacement(sbColor, "$1$1"); } @@ -180,7 +185,7 @@ public class PoiCssUtils { public static int calcColorValue(String color) { int rtn = 0; // matches 64 or 64% - Matcher m = Pattern.compile("^(\\d*\\.?\\d+)\\s*(%)?$").matcher(color); + Matcher m = INT_AND_PER_PATTERN.matcher(color); if (m.matches()) { // % not found if (m.group(2) == null) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiFunctionUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiFunctionUtil.java index c8b705e..61e29c9 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiFunctionUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiFunctionUtil.java @@ -103,11 +103,11 @@ public final class PoiFunctionUtil { } SimpleDateFormat dateFormat = null; if (DAY_STR.equals(format)) { - dateFormat = DAY_FORMAT; + dateFormat = new SimpleDateFormat(DAY_STR); } else if (TIME_STR.equals(format)) { - dateFormat = TIME_FORMAT; + dateFormat = new SimpleDateFormat(TIME_STR); } else if (TIME__NO_S_STR.equals(format)) { - dateFormat = TIME__NO_S_FORMAT; + dateFormat = new SimpleDateFormat(TIME__NO_S_STR); } else { dateFormat = new SimpleDateFormat(format); } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiPublicUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiPublicUtil.java index 7a677ba..5f2bfa5 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiPublicUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiPublicUtil.java @@ -251,10 +251,10 @@ public final class PoiPublicUtil { if (fieldType.isArray()) { isBaseClass = false; } else if (fieldType.isPrimitive() || fieldType.getPackage() == null - || fieldType.getPackage().getName().equals("java.lang") - || fieldType.getPackage().getName().equals("java.math") - || fieldType.getPackage().getName().equals("java.sql") - || fieldType.getPackage().getName().equals("java.util")) { + || "java.lang".equals(fieldType.getPackage().getName()) + || "java.math".equals(fieldType.getPackage().getName()) + || "java.sql".equals(fieldType.getPackage().getName()) + || "java.util".equals(fieldType.getPackage().getName())) { isBaseClass = true; } return isBaseClass; @@ -300,21 +300,21 @@ public final class PoiPublicUtil { * @return */ private static boolean isUseInThis(String exportName, String targetId) { - return targetId == null || exportName.equals("") || exportName.indexOf("_") < 0 + return targetId == null || "".equals(exportName) || exportName.indexOf("_") < 0 || exportName.indexOf(targetId) != -1; } private static Integer getImageType(String type) { - if (type.equalsIgnoreCase("JPG") || type.equalsIgnoreCase("JPEG")) { + if ("JPG".equalsIgnoreCase(type) || "JPEG".equalsIgnoreCase(type)) { return XWPFDocument.PICTURE_TYPE_JPEG; } - if (type.equalsIgnoreCase("GIF")) { + if ("GIF".equalsIgnoreCase(type)) { return XWPFDocument.PICTURE_TYPE_GIF; } - if (type.equalsIgnoreCase("BMP")) { + if ("BMP".equalsIgnoreCase(type)) { return XWPFDocument.PICTURE_TYPE_GIF; } - if (type.equalsIgnoreCase("PNG")) { + if ("PNG".equalsIgnoreCase(type)) { return XWPFDocument.PICTURE_TYPE_PNG; } return XWPFDocument.PICTURE_TYPE_JPEG; diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiReflectorUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiReflectorUtil.java index 4cd1efa..4d6d5cc 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiReflectorUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiReflectorUtil.java @@ -196,7 +196,7 @@ public final class PoiReflectorUtil { // Ignored. This is only a final precaution, nothing we can do. } } - if (field.isAccessible() && !field.getName().equalsIgnoreCase("serialVersionUID")) { + if (field.isAccessible() && !"serialVersionUID".equalsIgnoreCase(field.getName())) { this.fieldList.add(field); } } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtility.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtility.java index eeafaed..8489268 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtility.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtility.java @@ -40,21 +40,25 @@ public class PoiSheetUtility extends Object { Row row = sheet.getRow(r); // if no row exists here; then nothing to do; next! - if (row == null) + if (row == null) { continue; + } // if the row doesn't have this many columns then we are good; next! int lastColumn = row.getLastCellNum(); - if (lastColumn > maxColumn) + if (lastColumn > maxColumn) { maxColumn = lastColumn; + } - if (lastColumn < columnToDelete) + if (lastColumn < columnToDelete) { continue; + } for (int x = columnToDelete + 1; x < lastColumn + 1; x++) { Cell oldCell = row.getCell(x - 1); - if (oldCell != null) + if (oldCell != null) { row.removeCell(oldCell); + } Cell nextCell = row.getCell(x); if (nextCell != null) { @@ -99,6 +103,8 @@ public class PoiSheetUtility extends Object { cNew.setCellFormula(cOld.getCellFormula()); break; } + default: + cNew.setCellValue(cOld.getStringCellValue()); } } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiValidationUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiValidationUtil.java index 81d22e7..d48a763 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiValidationUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiValidationUtil.java @@ -29,19 +29,19 @@ import javax.validation.ValidatorFactory; */ public class PoiValidationUtil { - private final static Validator validator; + private final static Validator VALIDATOR; static { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - validator = factory.getValidator(); + VALIDATOR = factory.getValidator(); } public static String validation(Object obj, Class[] verfiyGroup) { Set> set = null; if(verfiyGroup != null){ - set = validator.validate(obj,verfiyGroup); + set = VALIDATOR.validate(obj,verfiyGroup); }else{ - set = validator.validate(obj); + set = VALIDATOR.validate(obj); } if (set!= null && set.size() > 0) { return getValidateErrMsg(set); diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/entity/MyXWPFDocument.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/entity/MyXWPFDocument.java index 09f4584..417a3d4 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/entity/MyXWPFDocument.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/entity/MyXWPFDocument.java @@ -73,9 +73,9 @@ public class MyXWPFDocument extends XWPFDocument { } public void createPicture(String blipId, int id, int width, int height) { - final int EMU = 9525; - width *= EMU; - height *= EMU; + final int emu = 9525; + width *= emu; + height *= emu; CTInline inline = createParagraph().createRun().getCTR().addNewDrawing().addNewInline(); String picXml = String.format(PICXML, id, blipId, width, height); XmlToken xmlToken = null; @@ -102,9 +102,9 @@ public class MyXWPFDocument extends XWPFDocument { } public void createPicture(XWPFRun run, String blipId, int id, int width, int height) { - final int EMU = 9525; - width *= EMU; - height *= EMU; + final int emu = 9525; + width *= emu; + height *= emu; CTInline inline = run.getCTR().addNewDrawing().addNewInline(); String picXml = String.format(PICXML, id, blipId, width, height); XmlToken xmlToken = null; diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java index a2482d6..6305242 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/word/parse/excel/ExcelEntityParse.java @@ -171,7 +171,7 @@ public class ExcelEntityParse extends ExportCommonServer { Map titlemap = getTitleMap(table, index, entity.getHeadRows()); try { // 得到所有字段 - Field fileds[] = PoiPublicUtil.getClassFields(entity.getClazz()); + Field[] fileds = PoiPublicUtil.getClassFields(entity.getClazz()); ExcelTarget etarget = entity.getClazz().getAnnotation(ExcelTarget.class); String targetId = null; if (etarget != null) {