diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/cache/WordCache.java b/easypoi-base/src/main/java/org/jeecgframework/poi/cache/WordCache.java index d93551d..7888959 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/cache/WordCache.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/cache/WordCache.java @@ -39,12 +39,12 @@ public class WordCache { MyXWPFDocument doc = new MyXWPFDocument(is); return doc; } catch (Exception e) { - LOGGER.error(e.getMessage(),e); + LOGGER.error(e.getMessage(), e); } finally { try { is.close(); } catch (Exception e) { - LOGGER.error(e.getMessage(),e); + LOGGER.error(e.getMessage(), e); } } return null; diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/IFileLoader.java b/easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/IFileLoader.java index a9f3baf..9c032f6 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/IFileLoader.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/cache/manager/IFileLoader.java @@ -14,6 +14,7 @@ * limitations under the License. */ package org.jeecgframework.poi.cache.manager; + /** * 缓存读取 * @author JueYue diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/ExcelImportUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/ExcelImportUtil.java index f4d0b73..bef147b 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/ExcelImportUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/ExcelImportUtil.java @@ -94,8 +94,8 @@ public class ExcelImportUtil { * @throws Exception */ public static ExcelImportResult importExcelVerify(InputStream inputstream, - Class pojoClass, ImportParams params) - throws Exception { + Class pojoClass, + ImportParams params) throws Exception { return new ExcelImportServer().importExcelByIs(inputstream, pojoClass, params); } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ExportParams.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ExportParams.java index 973f083..cb77ea0 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ExportParams.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ExportParams.java @@ -89,11 +89,12 @@ public class ExportParams extends ExcelBaseParams { /** * 是否动态获取数据 */ - private boolean isDynamicData = false; + private boolean isDynamicData = false; /** * 是否追加图形 */ - private boolean isAppendGraph = true; + private boolean isAppendGraph = true; + public ExportParams() { } @@ -227,24 +228,20 @@ public class ExportParams extends ExcelBaseParams { this.isCreateHeadRows = isCreateHeadRows; } - public boolean isDynamicData() - { - return isDynamicData; - } + public boolean isDynamicData() { + return isDynamicData; + } - public void setDynamicData(boolean isDynamicData) - { - this.isDynamicData = isDynamicData; - } + public void setDynamicData(boolean isDynamicData) { + this.isDynamicData = isDynamicData; + } - public boolean isAppendGraph() - { - return isAppendGraph; - } + public boolean isAppendGraph() { + return isAppendGraph; + } - public void setAppendGraph(boolean isAppendGraph) - { - this.isAppendGraph = isAppendGraph; - } + public void setAppendGraph(boolean isAppendGraph) { + this.isAppendGraph = isAppendGraph; + } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ImportParams.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ImportParams.java index 54afe7b..c6050f9 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ImportParams.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/ImportParams.java @@ -57,7 +57,7 @@ public class ImportParams extends ExcelBaseParams { /** * 是否需要校验上传的Excel,默认为false */ - private boolean needVerfiy = false; + private boolean needVerfiy = false; /** * 保存上传的Excel目录,默认是 如 TestEntity这个类保存路径就是 * upload/excelUpload/Test/yyyyMMddHHmss_***** 保存名称上传时间_五位随机数 diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/CellValueType.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/CellValueType.java index ccd8d78..a5627c4 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/CellValueType.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/CellValueType.java @@ -22,6 +22,6 @@ package org.jeecgframework.poi.excel.entity.enmus; */ public enum CellValueType { - String, Number, Boolean, Date, TElement, Null, None; + String , Number , Boolean , Date , TElement , Null , None; } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelStyleType.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelStyleType.java index 5dbd1d3..49d5d93 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelStyleType.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelStyleType.java @@ -26,9 +26,9 @@ import org.jeecgframework.poi.excel.export.styler.ExcelExportStylerDefaultImpl; */ public enum ExcelStyleType { - NONE("默认样式", ExcelExportStylerDefaultImpl.class), - BORDER("边框样式", ExcelExportStylerBorderImpl.class), - COLOR("间隔行样式", ExcelExportStylerColorImpl.class); + NONE ("默认样式" , ExcelExportStylerDefaultImpl.class) , + BORDER ("边框样式" , ExcelExportStylerBorderImpl.class) , + COLOR ("间隔行样式" , ExcelExportStylerColorImpl.class); private String name; private Class clazz; diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelType.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelType.java index 899530d..aec62de 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelType.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/enmus/ExcelType.java @@ -21,7 +21,7 @@ package org.jeecgframework.poi.excel.entity.enmus; * @date 2014年12月29日 下午9:08:21 */ public enum ExcelType { - - HSSF, XSSF; + + HSSF , XSSF; } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelExportEntity.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelExportEntity.java index d2bb893..6b90f0b 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelExportEntity.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/entity/params/ExcelExportEntity.java @@ -191,28 +191,29 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable0){ - cell.setCellValue(Double.parseDouble(text)); - }else{ - cell.setCellValue(-1); + if (text != null && text.length() > 0) { + cell.setCellValue(Double.parseDouble(text)); + } else { + cell.setCellValue(-1); } cell.setCellType(Cell.CELL_TYPE_NUMERIC); if (style != null) { @@ -304,8 +299,7 @@ public abstract class ExcelExportBase extends ExportBase { } addStatisticsData(index, text, entity); } - - + /** * 创建统计行 * @param styles diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/AbstractExcelExportStyler.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/AbstractExcelExportStyler.java index f636ff2..2d5f1c0 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/AbstractExcelExportStyler.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/AbstractExcelExportStyler.java @@ -33,7 +33,7 @@ public abstract class AbstractExcelExportStyler implements IExcelExportStyler { //间隔行 protected CellStyle stringSeptailStyle; protected CellStyle stringSeptailWrapStyle; - + protected Workbook workbook; protected static final short STRING_FORMAT = (short) BuiltinFormats.getBuiltinFormat("TEXT"); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerBorderImpl.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerBorderImpl.java index 3daf13e..38ec265 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerBorderImpl.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerBorderImpl.java @@ -24,8 +24,8 @@ import org.apache.poi.ss.usermodel.Workbook; * @author JueYue * @date 2015年1月9日 下午5:55:29 */ -public class ExcelExportStylerBorderImpl extends AbstractExcelExportStyler implements - IExcelExportStyler { +public class ExcelExportStylerBorderImpl extends AbstractExcelExportStyler + implements IExcelExportStyler { public ExcelExportStylerBorderImpl(Workbook workbook) { super.createStyles(workbook); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerColorImpl.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerColorImpl.java index a211fa5..e965c1f 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerColorImpl.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerColorImpl.java @@ -24,8 +24,8 @@ import org.apache.poi.ss.usermodel.Workbook; * @author JueYue * @date 2015年1月9日 下午4:54:15 */ -public class ExcelExportStylerColorImpl extends AbstractExcelExportStyler implements - IExcelExportStyler { +public class ExcelExportStylerColorImpl extends AbstractExcelExportStyler + implements IExcelExportStyler { public ExcelExportStylerColorImpl(Workbook workbook) { super.createStyles(workbook); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerDefaultImpl.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerDefaultImpl.java index e165d85..f531eb8 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerDefaultImpl.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/export/styler/ExcelExportStylerDefaultImpl.java @@ -24,8 +24,8 @@ import org.apache.poi.ss.usermodel.Workbook; * @author JueYue * @date 2015年1月9日 下午5:36:08 */ -public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler implements - IExcelExportStyler { +public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler + implements IExcelExportStyler { public ExcelExportStylerDefaultImpl(Workbook workbook) { super.createStyles(workbook); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/builder/ExcelChartBuildService.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/builder/ExcelChartBuildService.java index bcf40f9..b328adb 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/builder/ExcelChartBuildService.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/builder/ExcelChartBuildService.java @@ -38,225 +38,219 @@ import com.google.common.collect.Lists; * @version 1.0 * */ -public class ExcelChartBuildService -{ - /** - * - * @param workbook - * @param graph - * @param build 通过实时数据行来重新计算图形定义 - * @param append - */ - public static void createExcelChart(Workbook workbook,List graphList,Boolean build,Boolean append) - { - if(workbook!=null&&graphList!=null){ - //设定默认第一个sheet为数据项 - Sheet dataSouce=workbook.getSheetAt(0); - if(dataSouce!=null){ - buildTitle(dataSouce,graphList); - - if(build){ - PoiExcelGraphDataUtil.buildGraphData(dataSouce, graphList); - } - if(append){ - buildExcelChart(dataSouce, dataSouce, graphList); - }else{ - Sheet sheet=workbook.createSheet("图形界面"); - buildExcelChart(dataSouce, sheet, graphList); - } - } - - } - } - - /** - * 构建基础图形 - * @param drawing - * @param anchor - * @param dataSourceSheet - * @param graph - */ - private static void buildExcelChart(Drawing drawing,ClientAnchor anchor,Sheet dataSourceSheet,ExcelGraph graph){ - Chart chart = drawing.createChart(anchor); - ChartLegend legend = chart.getOrCreateLegend(); - legend.setPosition(LegendPosition.TOP_RIGHT); - - ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM); +public class ExcelChartBuildService { + /** + * + * @param workbook + * @param graph + * @param build 通过实时数据行来重新计算图形定义 + * @param append + */ + public static void createExcelChart(Workbook workbook, List graphList, + Boolean build, Boolean append) { + if (workbook != null && graphList != null) { + //设定默认第一个sheet为数据项 + Sheet dataSouce = workbook.getSheetAt(0); + if (dataSouce != null) { + buildTitle(dataSouce, graphList); + + if (build) { + PoiExcelGraphDataUtil.buildGraphData(dataSouce, graphList); + } + if (append) { + buildExcelChart(dataSouce, dataSouce, graphList); + } else { + Sheet sheet = workbook.createSheet("图形界面"); + buildExcelChart(dataSouce, sheet, graphList); + } + } + + } + } + + /** + * 构建基础图形 + * @param drawing + * @param anchor + * @param dataSourceSheet + * @param graph + */ + private static void buildExcelChart(Drawing drawing, ClientAnchor anchor, Sheet dataSourceSheet, + ExcelGraph graph) { + Chart chart = drawing.createChart(anchor); + ChartLegend legend = chart.getOrCreateLegend(); + legend.setPosition(LegendPosition.TOP_RIGHT); + + ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM); ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT); leftAxis.setCrosses(AxisCrosses.AUTO_ZERO); - ExcelGraphElement categoryElement=graph.getCategory(); - + ExcelGraphElement categoryElement = graph.getCategory(); + ChartDataSource categoryChart; - if(categoryElement!=null&&categoryElement.getElementType()==ExcelGraphElementType.StringType){ - 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())); + if (categoryElement != null + && categoryElement.getElementType() == 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())); + } + + List valueList = graph.getValueList(); + List> chartValueList = Lists.newArrayList(); + if (valueList != null && valueList.size() > 0) { + for (ExcelGraphElement ele : valueList) { + ChartDataSource source = DataSources.fromNumericCellRange(dataSourceSheet, + new CellRangeAddress(ele.getStartRowNum(), ele.getEndRowNum(), + ele.getStartColNum(), ele.getEndColNum())); + chartValueList.add(source); + } + } + + if (graph.getGraphType() == ExcelGraphType.LINE_CHART) { + LineChartData data = chart.getChartDataFactory().createLineChartData(); + buildLineChartData(data, categoryChart, chartValueList, graph.getTitle()); + chart.plot(data, bottomAxis, leftAxis); + } else { + ScatterChartData data = chart.getChartDataFactory().createScatterChartData(); + buildScatterChartData(data, categoryChart, chartValueList, graph.getTitle()); + chart.plot(data, bottomAxis, leftAxis); + } + } + + /** + * 构建多个图形对象 + * @param dataSourceSheet + * @param tragetSheet + * @param graphList + */ + private static void buildExcelChart(Sheet dataSourceSheet, Sheet tragetSheet, + List graphList) { + int len = graphList.size(); + if (len == 1) { + buildExcelChart(dataSourceSheet, tragetSheet, graphList.get(0)); + } else { + int drawStart = 0; + int drawEnd = 20; + Drawing drawing = tragetSheet.createDrawingPatriarch(); + for (int i = 0; i < len; i++) { + ExcelGraph graph = graphList.get(i); + ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, drawStart, 15, drawEnd); + buildExcelChart(drawing, anchor, dataSourceSheet, graph); + drawStart = drawStart + drawEnd; + drawEnd = drawEnd + drawEnd; + } + } + } + + /** + * 构建图形对象 + * @param workbook + * @param dataSourceSheet + * @param tragetSheet + * @param graph + */ + private static void buildExcelChart(Sheet dataSourceSheet, Sheet tragetSheet, + ExcelGraph graph) { + Drawing drawing = tragetSheet.createDrawingPatriarch(); + ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 0, 15, 20); + buildExcelChart(drawing, anchor, dataSourceSheet, graph); + } + + /** + * 构建Title + * @param sheet + * @param graph + */ + private static void buildTitle(Sheet sheet, ExcelGraph graph) { + int cellTitleLen = graph.getTitleCell().size(); + int titleLen = graph.getTitle().size(); + if (titleLen > 0) { + + } else { + for (int i = 0; i < cellTitleLen; i++) { + ExcelTitleCell titleCell = graph.getTitleCell().get(i); + if (titleCell != null) { + graph.getTitle().add( + PoiCellUtil.getCellValue(sheet, titleCell.getRow(), titleCell.getCol())); + } + } } - - List valueList=graph.getValueList(); - List> chartValueList=Lists.newArrayList(); - if(valueList!=null&&valueList.size()>0){ - for(ExcelGraphElement ele:valueList){ - ChartDataSource source=DataSources.fromNumericCellRange(dataSourceSheet, new CellRangeAddress(ele.getStartRowNum(),ele.getEndRowNum(),ele.getStartColNum(),ele.getEndColNum())); - chartValueList.add(source); - } + } + + /** + * 构建Title + * @param sheet + * @param graphList + */ + private static void buildTitle(Sheet sheet, List graphList) { + if (graphList != null && graphList.size() > 0) { + for (ExcelGraph graph : graphList) { + if (graph != null) { + buildTitle(sheet, graph); + } + } } - - if(graph.getGraphType()==ExcelGraphType.LineChart){ - LineChartData data = chart.getChartDataFactory().createLineChartData(); - buildLineChartData(data, categoryChart, chartValueList, graph.getTitle()); - chart.plot(data, bottomAxis, leftAxis); - } - else - { - ScatterChartData data=chart.getChartDataFactory().createScatterChartData(); - buildScatterChartData(data, categoryChart, chartValueList,graph.getTitle()); - chart.plot(data, bottomAxis, leftAxis); - } - } - - - - - /** - * 构建多个图形对象 - * @param dataSourceSheet - * @param tragetSheet - * @param graphList - */ - private static void buildExcelChart(Sheet dataSourceSheet,Sheet tragetSheet,List graphList){ - int len=graphList.size(); - if(len==1) - { - buildExcelChart(dataSourceSheet, tragetSheet, graphList.get(0)); - } - else - { - int drawStart=0; - int drawEnd=20; - Drawing drawing = tragetSheet.createDrawingPatriarch(); - for(int i=0;i0){ - - }else{ - for(int i=0;i graphList){ - if(graphList!=null&&graphList.size()>0){ - for(ExcelGraph graph:graphList){ - if(graph!=null) - { - buildTitle(sheet, graph); - } - } - } - } - - /** - * - * @param data - * @param categoryChart - * @param chartValueList - * @param title - */ - private static void buildLineChartData(LineChartData data,ChartDataSource categoryChart,List> chartValueList,List title){ - if(chartValueList.size()==title.size()) - { - int len=title.size(); - for(int i=0;i source:chartValueList){ - String _title=title.get(i); - if(StringUtils.isNotBlank(_title)){ - data.addSerie(categoryChart, source).setTitle(_title); - }else{ - data.addSerie(categoryChart, source); - } - } - } - } - - /** - * - * @param data - * @param categoryChart - * @param chartValueList - * @param title - */ - private static void buildScatterChartData(ScatterChartData data,ChartDataSource categoryChart,List> chartValueList,List title){ - if(chartValueList.size()==title.size()) - { - int len=title.size(); - for(int i=0;i source:chartValueList){ - String _title=title.get(i); - if(StringUtils.isNotBlank(_title)){ - data.addSerie(categoryChart, source).setTitle(_title); - }else{ - data.addSerie(categoryChart, source); - } - } - } - } - - + } + + /** + * + * @param data + * @param categoryChart + * @param chartValueList + * @param title + */ + private static void buildLineChartData(LineChartData data, ChartDataSource categoryChart, + List> chartValueList, + List title) { + if (chartValueList.size() == title.size()) { + int len = title.size(); + for (int i = 0; i < len; i++) { + data.addSerie(categoryChart, chartValueList.get(i)).setTitle(title.get(i)); + } + } else { + int i = 0; + for (ChartDataSource source : chartValueList) { + String _title = title.get(i); + if (StringUtils.isNotBlank(_title)) { + data.addSerie(categoryChart, source).setTitle(_title); + } else { + data.addSerie(categoryChart, source); + } + } + } + } + + /** + * + * @param data + * @param categoryChart + * @param chartValueList + * @param title + */ + private static void buildScatterChartData(ScatterChartData data, ChartDataSource categoryChart, + List> chartValueList, + List title) { + if (chartValueList.size() == title.size()) { + int len = title.size(); + for (int i = 0; i < len; i++) { + data.addSerie(categoryChart, chartValueList.get(i)).setTitle(title.get(i)); + } + } else { + int i = 0; + for (ChartDataSource source : chartValueList) { + String _title = title.get(i); + if (StringUtils.isNotBlank(_title)) { + data.addSerie(categoryChart, source).setTitle(_title); + } else { + data.addSerie(categoryChart, source); + } + } + } + } + } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphElementType.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphElementType.java index db85314..e89cfff 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphElementType.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphElementType.java @@ -9,8 +9,7 @@ package org.jeecgframework.poi.excel.graph.constant; * @version 1.0 * 定义元素类型 */ -public interface ExcelGraphElementType -{ - public static final Integer StringType=1; - public static final Integer NumericType=2; +public interface ExcelGraphElementType { + public static final Integer STRING_TYPE = 1; + public static final Integer NUMERIC_TYPE = 2; } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphType.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphType.java index 627797e..b8f4e29 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphType.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/constant/ExcelGraphType.java @@ -9,9 +9,8 @@ package org.jeecgframework.poi.excel.graph.constant; * @version 1.0 * 定义图形类型 */ -public interface ExcelGraphType -{ - public static final Integer LineChart=1; - public static final Integer ScatterChart=2; - +public interface ExcelGraphType { + public static final Integer LINE_CHART = 1; + public static final Integer SCATTER_CHART = 2; + } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraph.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraph.java index 169f0e2..74a2715 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraph.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraph.java @@ -12,11 +12,14 @@ import java.util.List; * @see com.dawnpro.core.export.excel.model.ExcelGraph * */ -public interface ExcelGraph -{ - public ExcelGraphElement getCategory(); - public List getValueList(); - public Integer getGraphType(); - public List getTitleCell(); - public List getTitle(); +public interface ExcelGraph { + public ExcelGraphElement getCategory(); + + public List getValueList(); + + public Integer getGraphType(); + + public List getTitleCell(); + + public List getTitle(); } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphDefined.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphDefined.java index 3729c16..f2c53c5 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphDefined.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphDefined.java @@ -15,56 +15,51 @@ import com.google.common.collect.Lists; * @version 1.0 * */ -public class ExcelGraphDefined implements ExcelGraph -{ - private ExcelGraphElement category; - public List valueList=Lists.newArrayList(); - public List titleCell=Lists.newArrayList(); - private Integer graphType=ExcelGraphType.LineChart; - public List title=Lists.newArrayList(); - - public ExcelGraphElement getCategory() - { - return category; - } - public void setCategory(ExcelGraphElement category) - { - this.category = category; - } - public List getValueList() - { - return valueList; - } - public void setValueList(List valueList) - { - this.valueList = valueList; - } +public class ExcelGraphDefined implements ExcelGraph { + private ExcelGraphElement category; + public List valueList = Lists.newArrayList(); + public List titleCell = Lists.newArrayList(); + private Integer graphType = ExcelGraphType.LINE_CHART; + public List title = Lists.newArrayList(); + + public ExcelGraphElement getCategory() { + return category; + } + + public void setCategory(ExcelGraphElement category) { + this.category = category; + } + + public List getValueList() { + return valueList; + } + + public void setValueList(List valueList) { + this.valueList = valueList; + } + + public Integer getGraphType() { + return graphType; + } + + public void setGraphType(Integer graphType) { + this.graphType = graphType; + } + + public List getTitleCell() { + return titleCell; + } + + public void setTitleCell(List titleCell) { + this.titleCell = titleCell; + } + + public List getTitle() { + return title; + } + + public void setTitle(List title) { + this.title = title; + } - public Integer getGraphType() - { - return graphType; - } - public void setGraphType(Integer graphType) - { - this.graphType = graphType; - } - public List getTitleCell() - { - return titleCell; - } - public void setTitleCell(List titleCell) - { - this.titleCell = titleCell; - } - public List getTitle() - { - return title; - } - public void setTitle(List title) - { - this.title = title; - } - - - } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphElement.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphElement.java index 2fe5f36..737b081 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphElement.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelGraphElement.java @@ -5,60 +5,56 @@ package org.jeecgframework.poi.excel.graph.entity; import org.jeecgframework.poi.excel.graph.constant.ExcelGraphElementType; - /** * @author xfworld * @since 2015-12-30 * @version 1.0 * */ -public class ExcelGraphElement -{ - private Integer startRowNum; - private Integer endRowNum; - private Integer startColNum; - private Integer endColNum; - private Integer elementType=ExcelGraphElementType.StringType; - - - public Integer getStartRowNum() - { - return startRowNum; - } - public void setStartRowNum(Integer startRowNum) - { - this.startRowNum = startRowNum; - } - public Integer getEndRowNum() - { - return endRowNum; - } - public void setEndRowNum(Integer endRowNum) - { - this.endRowNum = endRowNum; - } - public Integer getStartColNum() - { - return startColNum; - } - public void setStartColNum(Integer startColNum) - { - this.startColNum = startColNum; - } - public Integer getEndColNum() - { - return endColNum; - } - public void setEndColNum(Integer endColNum) - { - this.endColNum = endColNum; - } - public Integer getElementType() - { - return elementType; - } - public void setElementType(Integer elementType) - { - this.elementType = elementType; - } +public class ExcelGraphElement { + private Integer startRowNum; + private Integer endRowNum; + private Integer startColNum; + private Integer endColNum; + private Integer elementType = ExcelGraphElementType.STRING_TYPE; + + public Integer getStartRowNum() { + return startRowNum; + } + + public void setStartRowNum(Integer startRowNum) { + this.startRowNum = startRowNum; + } + + public Integer getEndRowNum() { + return endRowNum; + } + + public void setEndRowNum(Integer endRowNum) { + this.endRowNum = endRowNum; + } + + public Integer getStartColNum() { + return startColNum; + } + + public void setStartColNum(Integer startColNum) { + this.startColNum = startColNum; + } + + public Integer getEndColNum() { + return endColNum; + } + + public void setEndColNum(Integer endColNum) { + this.endColNum = endColNum; + } + + public Integer getElementType() { + return elementType; + } + + public void setElementType(Integer elementType) { + this.elementType = elementType; + } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelTitleCell.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelTitleCell.java index 8a90431..4d2af00 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelTitleCell.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/graph/entity/ExcelTitleCell.java @@ -9,36 +9,33 @@ package org.jeecgframework.poi.excel.graph.entity; * @version 1.0 * */ -public class ExcelTitleCell -{ - private Integer row; - private Integer col; - - public ExcelTitleCell(){ - - } - - public ExcelTitleCell(Integer row,Integer col){ - this.row=row; - this.col=col; - } - - public Integer getRow() - { - return row; - } - public void setRow(Integer row) - { - this.row = row; - } - public Integer getCol() - { - return col; - } - public void setCol(Integer col) - { - this.col = col; - } - - +public class ExcelTitleCell { + private Integer row; + private Integer col; + + public ExcelTitleCell() { + + } + + public ExcelTitleCell(Integer row, Integer col) { + this.row = row; + this.col = col; + } + + public Integer getRow() { + return row; + } + + public void setRow(Integer row) { + this.row = row; + } + + public Integer getCol() { + return col; + } + + public void setCol(Integer col) { + this.col = col; + } + } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/ExcelToHtmlServer.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/ExcelToHtmlServer.java index 0c6a162..5f3773e 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/ExcelToHtmlServer.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/ExcelToHtmlServer.java @@ -35,31 +35,32 @@ import org.slf4j.LoggerFactory; */ public class ExcelToHtmlServer { - private static final Logger LOGGER = LoggerFactory.getLogger(ExcelToHtmlServer.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(ExcelToHtmlServer.class); - private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd"); + private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd"); - private String today; + private String today; - private Workbook wb; - private int sheetNum; - private int cssRandom; + private Workbook wb; + private int sheetNum; + private int cssRandom; /*是不是完成界面*/ - private boolean completeHTML; - private Formatter out; + private boolean completeHTML; + private Formatter out; /*已经完成范围处理*/ - private boolean gotBounds; - private int firstColumn; - private int endColumn; - private String imageCachePath; - private static final String COL_HEAD_CLASS = "colHeader"; + private boolean gotBounds; + private int firstColumn; + private int endColumn; + private String imageCachePath; + private static final String COL_HEAD_CLASS = "colHeader"; //private static final String ROW_HEAD_CLASS = "rowHeader"; - private static final String DEFAULTS_CLASS = "excelDefaults"; + private static final String DEFAULTS_CLASS = "excelDefaults"; //图片缓存 - private Map pictures = new HashMap(); + private Map pictures = new HashMap(); public ExcelToHtmlServer(ExcelToHtmlParams params) { this.wb = params.getWb(); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/CellValueHelper.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/CellValueHelper.java index 0bf55bf..299fa61 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/CellValueHelper.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/CellValueHelper.java @@ -37,8 +37,8 @@ public class CellValueHelper { is07 = true; cacheFontInfo(wb); } else - throw new IllegalArgumentException("unknown workbook type: " - + wb.getClass().getSimpleName()); + throw new IllegalArgumentException( + "unknown workbook type: " + wb.getClass().getSimpleName()); } /** @@ -91,11 +91,11 @@ public class CellValueHelper { sb.append("'>"); currentIndex = rich.getIndexOfFormattingRun(i); if (i < nums - 1) { - sb.append(XmlEscapers.xmlContentEscaper().escape( - text.substring(currentIndex, rich.getIndexOfFormattingRun(i + 1)))); + sb.append(XmlEscapers.xmlContentEscaper() + .escape(text.substring(currentIndex, rich.getIndexOfFormattingRun(i + 1)))); } else { - sb.append(XmlEscapers.xmlContentEscaper().escape( - text.substring(currentIndex, text.length()))); + sb.append(XmlEscapers.xmlContentEscaper() + .escape(text.substring(currentIndex, text.length()))); } sb.append(""); } @@ -122,10 +122,10 @@ public class CellValueHelper { } catch (Exception e) { } sb.append(">"); - currentIndex = rich.getIndexOfFormattingRun(i) == -1 ? text.length() : rich - .getIndexOfFormattingRun(i); - sb.append(XmlEscapers.xmlContentEscaper().escape( - text.substring(lastIndex, currentIndex))); + currentIndex = rich.getIndexOfFormattingRun(i) == -1 ? text.length() + : rich.getIndexOfFormattingRun(i); + sb.append( + XmlEscapers.xmlContentEscaper().escape(text.substring(lastIndex, currentIndex))); sb.append(""); lastIndex = currentIndex; } @@ -133,8 +133,8 @@ public class CellValueHelper { } private String getFontIndex(XSSFFont font) { - return fontCache.get(font.getBoldweight() + "_" + font.getItalic() + "_" - + font.getFontName() + "_" + font.getFontHeightInPoints() + "_" - + font.getColor()); + return fontCache + .get(font.getBoldweight() + "_" + font.getItalic() + "_" + font.getFontName() + "_" + + font.getFontHeightInPoints() + "_" + font.getColor()); } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/MergedRegionHelper.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/MergedRegionHelper.java index 48ba70a..260cd0f 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/MergedRegionHelper.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/MergedRegionHelper.java @@ -46,8 +46,8 @@ public class MergedRegionHelper { endCol = (endCol + 1) * 26 + (strArr[1].charAt(1) - 65); } int endRol = Integer.valueOf(strArr[1].substring(strArr[1].charAt(1) >= 65 ? 2 : 1)); - mergedCache.put(startRol + "_" + startCol, new Integer[] { endRol - startRol + 1, - endCol - startCol + 1 }); + mergedCache.put(startRol + "_" + startCol, + new Integer[] { endRol - startRol + 1, endCol - startCol + 1 }); for (int i = startRol; i <= endRol; i++) { for (int j = startCol; j <= endCol; j++) { notNeedCread.add(i + "_" + j); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/StylerHelper.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/StylerHelper.java index e0ecec4..ae25861 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/StylerHelper.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/html/helper/StylerHelper.java @@ -47,19 +47,12 @@ public class StylerHelper { private static final String DEFAULTS_CLASS = "excelDefaults"; - private static final Map ALIGN = PoiPublicUtil - .mapFor(ALIGN_LEFT, "left", - ALIGN_CENTER, "center", - ALIGN_RIGHT, "right", - ALIGN_FILL, "left", - ALIGN_JUSTIFY, "left", - ALIGN_CENTER_SELECTION, - "center"); - - private static final Map VERTICAL_ALIGN = PoiPublicUtil.mapFor( - VERTICAL_BOTTOM, "bottom", - VERTICAL_CENTER, "middle", - VERTICAL_TOP, "top"); + private static final Map ALIGN = PoiPublicUtil.mapFor(ALIGN_LEFT, + "left", ALIGN_CENTER, "center", ALIGN_RIGHT, "right", ALIGN_FILL, "left", ALIGN_JUSTIFY, + "left", ALIGN_CENTER_SELECTION, "center"); + + private static final Map VERTICAL_ALIGN = PoiPublicUtil + .mapFor(VERTICAL_BOTTOM, "bottom", VERTICAL_CENTER, "middle", VERTICAL_TOP, "top"); private Formatter out; @@ -80,8 +73,8 @@ public class StylerHelper { else if (wb instanceof XSSFWorkbook) helper = new XSSFHtmlHelper((XSSFWorkbook) wb); else - throw new IllegalArgumentException("unknown workbook type: " - + wb.getClass().getSimpleName()); + throw new IllegalArgumentException( + "unknown workbook type: " + wb.getClass().getSimpleName()); printInlineStyle(wb); } @@ -127,8 +120,8 @@ public class StylerHelper { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb); try { - in = new BufferedReader(new InputStreamReader( - StylerHelper.class.getResourceAsStream("excelStyle.css"))); + in = new BufferedReader( + new InputStreamReader(StylerHelper.class.getResourceAsStream("excelStyle.css"))); String line; while ((line = in.readLine()) != null) { formatter.format("%s%n", line); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/CellValueServer.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/CellValueServer.java index b8636dd..1f9b2f7 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/CellValueServer.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/CellValueServer.java @@ -48,9 +48,9 @@ import org.slf4j.LoggerFactory; */ public class CellValueServer { - private static final Logger LOGGER = LoggerFactory.getLogger(CellValueServer.class); + private static final Logger LOGGER = LoggerFactory.getLogger(CellValueServer.class); - private List hanlderList = null; + private List hanlderList = null; /** * 获取单元格内的值 @@ -243,7 +243,7 @@ public class CellValueServer { private Object getValueByType(String xclass, Object result, ExcelImportEntity entity) { try { //过滤空和空字符串,如果基本类型null会在上层抛出,这里就不处理了 - if(result == null || StringUtils.isBlank(result.toString())){ + if (result == null || StringUtils.isBlank(result.toString())) { return null; } if ("class java.util.Date".equals(xclass)) { diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/ExcelImportServer.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/ExcelImportServer.java index b60ce53..8c8b747 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/ExcelImportServer.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/ExcelImportServer.java @@ -69,15 +69,15 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked", "hiding" }) public class ExcelImportServer extends ImportBaseService { - private final static Logger LOGGER = LoggerFactory.getLogger(ExcelImportServer.class); + private final static Logger LOGGER = LoggerFactory.getLogger(ExcelImportServer.class); - private CellValueServer cellValueServer; + private CellValueServer cellValueServer; - private boolean verfiyFail = false; + private boolean verfiyFail = false; /** * 异常数据styler */ - private CellStyle errorCellStyle; + private CellStyle errorCellStyle; public ExcelImportServer() { this.cellValueServer = new CellValueServer(); @@ -195,7 +195,7 @@ public class ExcelImportServer extends ImportBaseService { rows.next(); } Map titlemap = getTitleMap(rows, params, excelCollection); - checkIsValidTemplate(titlemap, excelParams, params,excelCollection); + checkIsValidTemplate(titlemap, excelParams, params, excelCollection); Row row = null; Object object = null; String picId; @@ -415,31 +415,36 @@ public class ExcelImportServer extends ImportBaseService { * @param params * @param excelCollection */ - private void checkIsValidTemplate(Map titlemap, Map excelParams, ImportParams params, List excelCollection) { - - if(params.getImportFields() != null){ - for (int i = 0 ,le = params.getImportFields().length; i < le; i++) { - if(!titlemap.containsValue(params.getImportFields()[i])){ - throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE); + private void checkIsValidTemplate(Map titlemap, + Map excelParams, + ImportParams params, + List excelCollection) { + + if (params.getImportFields() != null) { + for (int i = 0, le = params.getImportFields().length; i < le; i++) { + if (!titlemap.containsValue(params.getImportFields()[i])) { + throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE); } } } else { - Collection collection = excelParams.values(); - for (ExcelImportEntity excelImportEntity : collection) { - if(excelImportEntity.isImportField() && !titlemap.containsValue(excelImportEntity.getName())){ - throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE); - } - } - - for (int i = 0, le = excelCollection.size(); i < le; i++) { - ExcelCollectionParams collectionparams = excelCollection.get(i); - collection = collectionparams.getExcelParams().values(); - for (ExcelImportEntity excelImportEntity : collection) { - if(excelImportEntity.isImportField() && !titlemap.containsValue(collectionparams.getExcelName()+"_"+excelImportEntity.getName())){ - throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE); - } - } - } + Collection collection = excelParams.values(); + for (ExcelImportEntity excelImportEntity : collection) { + if (excelImportEntity.isImportField() + && !titlemap.containsValue(excelImportEntity.getName())) { + throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE); + } + } + + for (int i = 0, le = excelCollection.size(); i < le; i++) { + ExcelCollectionParams collectionparams = excelCollection.get(i); + collection = collectionparams.getExcelParams().values(); + for (ExcelImportEntity excelImportEntity : collection) { + if (excelImportEntity.isImportField() && !titlemap.containsValue( + collectionparams.getExcelName() + "_" + excelImportEntity.getName())) { + throw new ExcelImportException(ExcelImportEnum.IS_NOT_A_VALID_TEMPLATE); + } + } + } } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SaxReadExcel.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SaxReadExcel.java index cc68889..1c8abd5 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SaxReadExcel.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SaxReadExcel.java @@ -82,8 +82,8 @@ public class SaxReadExcel { } } - private XMLReader fetchSheetParser(SharedStringsTable sst, ISaxRowRead rowRead) - throws SAXException { + private XMLReader fetchSheetParser(SharedStringsTable sst, + ISaxRowRead rowRead) throws SAXException { XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"); ContentHandler handler = new SheetHandler(sst, rowRead); parser.setContentHandler(handler); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SheetHandler.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SheetHandler.java index 12ee8c0..6da8a3c 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SheetHandler.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/SheetHandler.java @@ -59,8 +59,8 @@ public class SheetHandler extends DefaultHandler { } @Override - public void startElement(String uri, String localName, String name, Attributes attributes) - throws SAXException { + public void startElement(String uri, String localName, String name, + Attributes attributes) throws SAXException { // 置空 lastContents = ""; // c => 单元格 diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/ISaxRowRead.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/ISaxRowRead.java index 5292a62..cb01c32 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/ISaxRowRead.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/ISaxRowRead.java @@ -26,6 +26,7 @@ public interface ISaxRowRead { * @return */ public List getList(); + /** * 解析数据 * @param index @@ -33,5 +34,4 @@ public interface ISaxRowRead { */ public void parse(int index, List datas); - } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/SaxRowRead.java b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/SaxRowRead.java index e977fbc..f7062c5 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/SaxRowRead.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/excel/imports/sax/parse/SaxRowRead.java @@ -49,7 +49,7 @@ import com.google.common.collect.Lists; public class SaxRowRead extends ImportBaseService implements ISaxRowRead { private static final Logger LOGGER = LoggerFactory - .getLogger(SaxRowRead.class); + .getLogger(SaxRowRead.class); /** 需要返回的数据 **/ private List list; /** 导出的对象 **/ @@ -129,8 +129,9 @@ public class SaxRowRead extends ImportBaseService implements ISaxRowRead { */ private void addListData(List datas) throws Exception { // 判断是集合元素还是不是集合元素,如果是就继续加入这个集合,不是就创建新的对象 - if ((datas.get(params.getKeyIndex()) == null || StringUtils.isEmpty(String.valueOf(datas - .get(params.getKeyIndex()).getValue()))) && object != null) { + if ((datas.get(params.getKeyIndex()) == null + || StringUtils.isEmpty(String.valueOf(datas.get(params.getKeyIndex()).getValue()))) + && object != null) { for (ExcelCollectionParams param : excelCollection) { addListContinue(object, param, datas, titlemap, targetId, params); } @@ -171,7 +172,8 @@ public class SaxRowRead extends ImportBaseService implements ISaxRowRead { private void addListContinue(Object object, ExcelCollectionParams param, List datas, Map titlemap, String targetId, ImportParams params) throws Exception { - Collection collection = (Collection) PoiReflectorUtil.fromCache(pojoClass).getValue(object, param.getName()); + Collection collection = (Collection) PoiReflectorUtil.fromCache(pojoClass).getValue(object, + param.getName()); Object entity = PoiPublicUtil.createObject(param.getType(), targetId); boolean isUsed = false;// 是否需要加上这个对象 for (int i = 0; i < datas.size(); i++) { @@ -196,8 +198,8 @@ public class SaxRowRead extends ImportBaseService implements ISaxRowRead { * @throws Exception */ private void saveFieldValue(ImportParams params, Object object, SaxReadCellEntity entity, - Map excelParams, String titleString) - throws Exception { + Map excelParams, + String titleString) throws Exception { Object value = cellValueServer.getValue(params.getDataHanlder(), object, entity, excelParams, titleString); setValues(excelParams.get(titleString), object, value); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/ExcelImportException.java b/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/ExcelImportException.java index 0bd1fdf..3e15dc8 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/ExcelImportException.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/ExcelImportException.java @@ -26,7 +26,7 @@ public class ExcelImportException extends RuntimeException { private static final long serialVersionUID = 1L; - private ExcelImportEnum type; + private ExcelImportEnum type; public ExcelImportException() { super(); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelExportEnum.java b/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelExportEnum.java index 97831d5..09fe056 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelExportEnum.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelExportEnum.java @@ -22,7 +22,9 @@ package org.jeecgframework.poi.exception.excel.enums; */ public enum ExcelExportEnum { - PARAMETER_ERROR("Excel 导出 参数错误"), EXPORT_ERROR("Excel导出错误"),TEMPLATE_ERROR("Excel 模板错误"); + PARAMETER_ERROR ("Excel 导出 参数错误") , + EXPORT_ERROR ("Excel导出错误") , + TEMPLATE_ERROR ("Excel 模板错误"); private String msg; diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelImportEnum.java b/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelImportEnum.java index d06dcc4..69c0a0e 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelImportEnum.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/exception/excel/enums/ExcelImportEnum.java @@ -22,7 +22,9 @@ package org.jeecgframework.poi.exception.excel.enums; */ public enum ExcelImportEnum { - IS_NOT_A_VALID_TEMPLATE("不是合法的Excel模板"), GET_VALUE_ERROR("Excel 值获取失败"), VERIFY_ERROR("值校验失败"); + IS_NOT_A_VALID_TEMPLATE ("不是合法的Excel模板") , + GET_VALUE_ERROR ("Excel 值获取失败") , + VERIFY_ERROR ("值校验失败"); private String msg; diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelModel.java b/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelModel.java index 8b165a8..0719d2d 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelModel.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/handler/inter/IExcelModel.java @@ -14,18 +14,20 @@ * limitations under the License. */ package org.jeecgframework.poi.handler.inter; + /** * Excel标记类 * @author JueYue * @date 2015年10月31日 下午9:31:47 */ public interface IExcelModel { - + /** * 获取错误数据 * @return */ public String getErrorMsg(); + /** * 设置错误信息 * @param errorMsg diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiCellUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiCellUtil.java index 853f12e..b56c5c6 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiCellUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiCellUtil.java @@ -15,114 +15,113 @@ import org.apache.poi.ss.util.CellRangeAddress; * @see org.jeecgframework.poi.util.PoiCellUtil * 获取单元格的值 */ -public class PoiCellUtil -{ - /** - * 读取单元格的值 - * @param sheet - * @param row - * @param column - * @return - */ - public static String getCellValue(Sheet sheet ,int row , int column) - { - String value=null; - if(isMergedRegion(sheet ,row ,column)){ - value=getMergedRegionValue(sheet ,row ,column); - }else{ - Row rowData=sheet.getRow(row); - Cell cell=rowData.getCell(column); - value=getCellValue(cell); - } - return value; - } - - /** - * 获取合并单元格的值 - * @param sheet - * @param row - * @param column - * @return - */ - public static String getMergedRegionValue(Sheet sheet ,int row , int column){ - int sheetMergeCount = sheet.getNumMergedRegions(); - - for(int i = 0 ; i < sheetMergeCount ; i++){ - CellRangeAddress ca = sheet.getMergedRegion(i); - int firstColumn = ca.getFirstColumn(); - int lastColumn = ca.getLastColumn(); - int firstRow = ca.getFirstRow(); - int lastRow = ca.getLastRow(); - - if(row >= firstRow && row <= lastRow){ - - if(column >= firstColumn && column <= lastColumn){ - Row fRow = sheet.getRow(firstRow); - Cell fCell = fRow.getCell(firstColumn); - - return getCellValue(fCell) ; - } - } - } - - return null ; - } - - /** - * 判断指定的单元格是否是合并单元格 - * @param sheet - * @param row - * @param column - * @return - */ - public static boolean isMergedRegion(Sheet sheet , int row , int column){ - int sheetMergeCount = sheet.getNumMergedRegions(); - - for(int i = 0 ; i < sheetMergeCount ; i++ ){ - CellRangeAddress ca = sheet.getMergedRegion(i); - int firstColumn = ca.getFirstColumn(); - int lastColumn = ca.getLastColumn(); - int firstRow = ca.getFirstRow(); - int lastRow = ca.getLastRow(); - - if(row >= firstRow && row <= lastRow){ - if(column >= firstColumn && column <= lastColumn){ - - return true ; - } - } - } - - return false ; - } - - /** - * 获取单元格的值 - * @param cell - * @return - */ - public static String getCellValue(Cell cell){ - - if(cell == null) return ""; - - if(cell.getCellType() == Cell.CELL_TYPE_STRING){ - - return cell.getStringCellValue(); - - }else if(cell.getCellType() == Cell.CELL_TYPE_BOOLEAN){ - - return String.valueOf(cell.getBooleanCellValue()); - - }else if(cell.getCellType() == Cell.CELL_TYPE_FORMULA){ - - return cell.getCellFormula() ; - - }else if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC){ - - return String.valueOf(cell.getNumericCellValue()); - - } - - return ""; - } +public class PoiCellUtil { + /** + * 读取单元格的值 + * @param sheet + * @param row + * @param column + * @return + */ + public static String getCellValue(Sheet sheet, int row, int column) { + String value = null; + if (isMergedRegion(sheet, row, column)) { + value = getMergedRegionValue(sheet, row, column); + } else { + Row rowData = sheet.getRow(row); + Cell cell = rowData.getCell(column); + value = getCellValue(cell); + } + return value; + } + + /** + * 获取合并单元格的值 + * @param sheet + * @param row + * @param column + * @return + */ + public static String getMergedRegionValue(Sheet sheet, int row, int column) { + int sheetMergeCount = sheet.getNumMergedRegions(); + + for (int i = 0; i < sheetMergeCount; i++) { + CellRangeAddress ca = sheet.getMergedRegion(i); + int firstColumn = ca.getFirstColumn(); + int lastColumn = ca.getLastColumn(); + int firstRow = ca.getFirstRow(); + int lastRow = ca.getLastRow(); + + if (row >= firstRow && row <= lastRow) { + + if (column >= firstColumn && column <= lastColumn) { + Row fRow = sheet.getRow(firstRow); + Cell fCell = fRow.getCell(firstColumn); + + return getCellValue(fCell); + } + } + } + + return null; + } + + /** + * 判断指定的单元格是否是合并单元格 + * @param sheet + * @param row + * @param column + * @return + */ + public static boolean isMergedRegion(Sheet sheet, int row, int column) { + int sheetMergeCount = sheet.getNumMergedRegions(); + + for (int i = 0; i < sheetMergeCount; i++) { + CellRangeAddress ca = sheet.getMergedRegion(i); + int firstColumn = ca.getFirstColumn(); + int lastColumn = ca.getLastColumn(); + int firstRow = ca.getFirstRow(); + int lastRow = ca.getLastRow(); + + if (row >= firstRow && row <= lastRow) { + if (column >= firstColumn && column <= lastColumn) { + + return true; + } + } + } + + return false; + } + + /** + * 获取单元格的值 + * @param cell + * @return + */ + public static String getCellValue(Cell cell) { + + if (cell == null) + return ""; + + if (cell.getCellType() == Cell.CELL_TYPE_STRING) { + + return cell.getStringCellValue(); + + } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { + + return String.valueOf(cell.getBooleanCellValue()); + + } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + + return cell.getCellFormula(); + + } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { + + return String.valueOf(cell.getNumericCellValue()); + + } + + return ""; + } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiElUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiElUtil.java index 3bf8470..e16bfe8 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiElUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiElUtil.java @@ -25,8 +25,6 @@ import org.jeecgframework.poi.exception.excel.ExcelExportException; * @date 2015年4月25日 下午12:13:21 */ public final class PoiElUtil { - - public static final String LENGTH = "le:"; public static final String FOREACH = "fe:"; @@ -41,7 +39,7 @@ public final class PoiElUtil { public static final String IF_DELETE = "!if:"; public static final String EMPTY = ""; public static final String CONST = "'"; - public static final String NULL = "&NULL&"; + public static final String NULL = "&NULL&"; public static final String LEFT_BRACKET = "("; public static final String RIGHT_BRACKET = ")"; diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiExcelGraphDataUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiExcelGraphDataUtil.java index c18dc70..69600a4 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiExcelGraphDataUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiExcelGraphDataUtil.java @@ -3,8 +3,6 @@ */ package org.jeecgframework.poi.util; - - import java.util.List; import org.apache.poi.ss.usermodel.Sheet; @@ -17,39 +15,36 @@ import org.jeecgframework.poi.excel.graph.entity.ExcelGraphElement; * @version 1.0 * 构建特殊数据结构 */ -public class PoiExcelGraphDataUtil -{ - - /** - * 构建获取数据最后行数 并写入到定义对象中 - * @param dataSourceSheet - * @param graph - */ - public static void buildGraphData(Sheet dataSourceSheet,ExcelGraph graph){ - if(graph!=null&&graph.getCategory()!=null&&graph.getValueList()!=null&&graph.getValueList().size()>0){ - graph.getCategory().setEndRowNum(dataSourceSheet.getLastRowNum()); - for(ExcelGraphElement e:graph.getValueList()){ - if(e!=null){ - e.setEndRowNum(dataSourceSheet.getLastRowNum()); - } - } - } - } - - /** - * 构建多个图形对象 - * @param dataSourceSheet - * @param graphList - */ - public static void buildGraphData(Sheet dataSourceSheet,List graphList){ - if(graphList!=null&&graphList.size()>0){ - for(ExcelGraph graph:graphList){ - buildGraphData(dataSourceSheet,graph); - } - } - } - - - - +public class PoiExcelGraphDataUtil { + + /** + * 构建获取数据最后行数 并写入到定义对象中 + * @param dataSourceSheet + * @param graph + */ + public static void buildGraphData(Sheet dataSourceSheet, ExcelGraph graph) { + if (graph != null && graph.getCategory() != null && graph.getValueList() != null + && graph.getValueList().size() > 0) { + graph.getCategory().setEndRowNum(dataSourceSheet.getLastRowNum()); + for (ExcelGraphElement e : graph.getValueList()) { + if (e != null) { + e.setEndRowNum(dataSourceSheet.getLastRowNum()); + } + } + } + } + + /** + * 构建多个图形对象 + * @param dataSourceSheet + * @param graphList + */ + public static void buildGraphData(Sheet dataSourceSheet, List graphList) { + if (graphList != null && graphList.size() > 0) { + for (ExcelGraph graph : graphList) { + buildGraphData(dataSourceSheet, graph); + } + } + } + } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiFunctionUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiFunctionUtil.java index eba1175..397e33c 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiFunctionUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiFunctionUtil.java @@ -179,5 +179,5 @@ public final class PoiFunctionUtil { double two = Double.valueOf(second.toString()); return one > two; } - + } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiMergeCellUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiMergeCellUtil.java index 6b3a352..fc40c6a 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiMergeCellUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiMergeCellUtil.java @@ -166,7 +166,8 @@ public final class PoiMergeCellUtil { // 存在依赖关系 测试 if (mergeEntity.getText().equals(text)) { for (int i = 0; i < delys.length; i++) { - if (mergeEntity.getRelyList().get(i) ==null || !mergeEntity.getRelyList().get(i).equals(getCellNotNullText(cell, delys[i], rowNum))) { + if (mergeEntity.getRelyList().get(i) == null || !mergeEntity.getRelyList().get(i) + .equals(getCellNotNullText(cell, delys[i], rowNum))) { return false; } } @@ -184,13 +185,15 @@ public final class PoiMergeCellUtil { * @return */ private static String getCellNotNullText(Cell cell, int index, int rowNum) { - if(cell == null || cell.getRow() == null){ + if (cell == null || cell.getRow() == null) { return null; } - if(cell.getRow().getCell(index) != null && StringUtils.isNotEmpty(cell.getRow().getCell(index).getStringCellValue())){ + if (cell.getRow().getCell(index) != null + && StringUtils.isNotEmpty(cell.getRow().getCell(index).getStringCellValue())) { return cell.getRow().getCell(index).getStringCellValue(); } - return getCellNotNullText(cell.getRow().getSheet().getRow(--rowNum).getCell(index),index,rowNum); + return getCellNotNullText(cell.getRow().getSheet().getRow(--rowNum).getCell(index), index, + rowNum); } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiPublicUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiPublicUtil.java index e42018a..9d2b9e6 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiPublicUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiPublicUtil.java @@ -100,9 +100,11 @@ public final class PoiPublicUtil { } if (isCollection(field.getType())) { ExcelCollection collection = field.getAnnotation(ExcelCollection.class); - PoiReflectorUtil.fromCache(clazz).setValue(obj , field.getName(), collection.type().newInstance()); + PoiReflectorUtil.fromCache(clazz).setValue(obj, field.getName(), + collection.type().newInstance()); } else if (!isJavaClass(field)) { - PoiReflectorUtil.fromCache(clazz).setValue(obj , field.getName(), createObject(field.getType(), targetId)); + PoiReflectorUtil.fromCache(clazz).setValue(obj, field.getName(), + createObject(field.getType(), targetId)); } } @@ -163,7 +165,8 @@ public final class PoiPublicUtil { * 工作簿对象 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData */ - public static Map getSheetPictrues03(HSSFSheet sheet, HSSFWorkbook workbook) { + public static Map getSheetPictrues03(HSSFSheet sheet, + HSSFWorkbook workbook) { Map sheetIndexPicMap = new HashMap(); List pictures = workbook.getAllPictures(); if (!pictures.isEmpty()) { @@ -193,7 +196,8 @@ public final class PoiPublicUtil { * 工作簿对象 * @return Map key:图片单元格索引(1_1)String,value:图片流PictureData */ - public static Map getSheetPictrues07(XSSFSheet sheet, XSSFWorkbook workbook) { + public static Map getSheetPictrues07(XSSFSheet sheet, + XSSFWorkbook workbook) { Map sheetIndexPicMap = new HashMap(); for (POIXMLDocumentPart dr : sheet.getRelations()) { if (dr instanceof XSSFDrawing) { @@ -266,23 +270,20 @@ public final class PoiPublicUtil { boolean boo = true; if (field.getAnnotation(ExcelIgnore.class) != null) { boo = true; - } else if (boo - && field.getAnnotation(ExcelCollection.class) != null + } else if (boo && field.getAnnotation(ExcelCollection.class) != null && isUseInThis(field.getAnnotation(ExcelCollection.class).name(), targetId) - && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation( - ExcelCollection.class).name()))) { + && (exclusionsList == null || !exclusionsList + .contains(field.getAnnotation(ExcelCollection.class).name()))) { boo = false; - } else if (boo - && field.getAnnotation(Excel.class) != null + } else if (boo && field.getAnnotation(Excel.class) != null && isUseInThis(field.getAnnotation(Excel.class).name(), targetId) - && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation( - Excel.class).name()))) { + && (exclusionsList == null + || !exclusionsList.contains(field.getAnnotation(Excel.class).name()))) { boo = false; - } else if (boo - && field.getAnnotation(ExcelEntity.class) != null + } else if (boo && field.getAnnotation(ExcelEntity.class) != null && isUseInThis(field.getAnnotation(ExcelEntity.class).name(), targetId) - && (exclusionsList == null || !exclusionsList.contains(field.getAnnotation( - ExcelEntity.class).name()))) { + && (exclusionsList == null || !exclusionsList + .contains(field.getAnnotation(ExcelEntity.class).name()))) { boo = false; } return boo; @@ -331,15 +332,12 @@ public final class PoiPublicUtil { ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); BufferedImage bufferImg; String path = Thread.currentThread().getContextClassLoader().getResource("").toURI() - .getPath() - + entity.getUrl(); + .getPath() + entity.getUrl(); path = path.replace("WEB-INF/classes/", ""); path = path.replace("file:/", ""); bufferImg = ImageIO.read(new File(path)); - ImageIO.write( - bufferImg, - entity.getUrl().substring(entity.getUrl().indexOf(".") + 1, - entity.getUrl().length()), byteArrayOut); + ImageIO.write(bufferImg, entity.getUrl().substring(entity.getUrl().indexOf(".") + 1, + entity.getUrl().length()), byteArrayOut); result[0] = byteArrayOut.toByteArray(); type = entity.getUrl().split("/.")[entity.getUrl().split("/.").length - 1]; } else { @@ -376,11 +374,12 @@ public final class PoiPublicUtil { * @date 2013-11-16 * @return */ - public static Object getRealValue(String currentText, Map map) throws Exception { + public static Object getRealValue(String currentText, + Map map) throws Exception { String params = ""; while (currentText.indexOf(START_STR) != -1) { - params = currentText - .substring(currentText.indexOf(START_STR) + 2, currentText.indexOf(END_STR)); + params = currentText.substring(currentText.indexOf(START_STR) + 2, + currentText.indexOf(END_STR)); Object obj = PoiElUtil.eval(params.trim(), map); //判断图片或者是集合 @@ -404,8 +403,8 @@ public final class PoiPublicUtil { * @throws Exception */ @SuppressWarnings("rawtypes") - public static Object getValueDoWhile(Object object, String[] paramsArr, int index) - throws Exception { + public static Object getValueDoWhile(Object object, String[] paramsArr, + int index) throws Exception { if (object == null) { return ""; } @@ -415,10 +414,11 @@ public final class PoiPublicUtil { if (object instanceof Map) { object = ((Map) object).get(paramsArr[index]); } else { - object = PoiReflectorUtil.fromCache(object.getClass()).getValue(object, paramsArr[index]); + object = PoiReflectorUtil.fromCache(object.getClass()).getValue(object, + paramsArr[index]); } - return (index == paramsArr.length - 1) ? (object == null ? "" : object) : getValueDoWhile( - object, paramsArr, ++index); + return (index == paramsArr.length - 1) ? (object == null ? "" : object) + : getValueDoWhile(object, paramsArr, ++index); } /** @@ -434,14 +434,14 @@ public final class PoiPublicUtil { } return temp; } - + /** * 统一 key的获取规则 * @param key * @param targetId * @return */ - public static String getValueByTargetId(String key, String targetId, String defalut){ + public static String getValueByTargetId(String key, String targetId, String defalut) { if (StringUtils.isEmpty(targetId) || key.indexOf("_") < 0) { return key; } @@ -449,7 +449,7 @@ public final class PoiPublicUtil { String[] tempArr; for (String str : arr) { tempArr = str.split("_"); - if(tempArr == null || tempArr.length < 2){ + if (tempArr == null || tempArr.length < 2) { return defalut; } if (targetId.equals(tempArr[1])) { @@ -458,15 +458,14 @@ public final class PoiPublicUtil { } return defalut; } - - + /** * 支持换行操作 * @param currentRun * @param currentText */ public static void setWordText(XWPFRun currentRun, String currentText) { - if(StringUtils.isNotBlank(currentText)){ + if (StringUtils.isNotBlank(currentText)) { String[] tempArr = currentText.split("\r\n"); for (int i = 0, le = tempArr.length - 1; i < le; i++) { currentRun.setText(tempArr[i], i); @@ -476,5 +475,4 @@ public final class PoiPublicUtil { } } - } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiReflectorUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiReflectorUtil.java index 1499eff..92dd081 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiReflectorUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/util/PoiReflectorUtil.java @@ -21,11 +21,11 @@ public final class PoiReflectorUtil { private static final Map, PoiReflectorUtil> CACHE_REFLECTOR = new ConcurrentHashMap, PoiReflectorUtil>(); - private Map getMethods = new HashMap(); - private Map setMethods = new HashMap(); - private List fieldList = new ArrayList(); + private Map getMethods = new HashMap(); + private Map setMethods = new HashMap(); + private List fieldList = new ArrayList(); - private Class type; + private Class type; private PoiReflectorUtil(Class clazz) { addGetMethods(clazz); @@ -80,9 +80,10 @@ public final class PoiReflectorUtil { if (methodType.equals(getterType)) { throw new RuntimeException( "Illegal overloaded getter method with ambiguous type for property " - + propName + " in class " + firstMethod.getDeclaringClass() - + ". This breaks the JavaBeans " - + "specification and can cause unpredicatble results."); + + propName + " in class " + + firstMethod.getDeclaringClass() + + ". This breaks the JavaBeans " + + "specification and can cause unpredicatble results."); } else if (methodType.isAssignableFrom(getterType)) { // OK getter type is descendant } else if (getterType.isAssignableFrom(methodType)) { @@ -91,9 +92,10 @@ public final class PoiReflectorUtil { } else { throw new RuntimeException( "Illegal overloaded getter method with ambiguous type for property " - + propName + " in class " + firstMethod.getDeclaringClass() - + ". This breaks the JavaBeans " - + "specification and can cause unpredicatble results."); + + propName + " in class " + + firstMethod.getDeclaringClass() + + ". This breaks the JavaBeans " + + "specification and can cause unpredicatble results."); } } addGetMethod(propName, getter); @@ -121,7 +123,7 @@ public final class PoiReflectorUtil { } resolveSetterConflicts(conflictingSetters); } - + private static String methodToProperty(String name) { if (name.startsWith("is")) { name = name.substring(2); @@ -168,9 +170,10 @@ public final class PoiReflectorUtil { if (setter == null) { throw new RuntimeException( "Illegal overloaded setter method with ambiguous type for property " - + propName + " in class " + firstMethod.getDeclaringClass() - + ". This breaks the JavaBeans " - + "specification and can cause unpredicatble results."); + + propName + " in class " + + firstMethod.getDeclaringClass() + + ". This breaks the JavaBeans " + + "specification and can cause unpredicatble results."); } addSetMethod(propName, setter); } @@ -292,8 +295,8 @@ public final class PoiReflectorUtil { public Method getGetMethod(String propertyName) { Method method = getMethods.get(propertyName); if (method == null) { - throw new RuntimeException("There is no getter for property named '" + propertyName - + "' in '" + type + "'"); + throw new RuntimeException( + "There is no getter for property named '" + propertyName + "' in '" + type + "'"); } return method; } @@ -301,8 +304,8 @@ public final class PoiReflectorUtil { public Method getSetMethod(String propertyName) { Method method = setMethods.get(propertyName); if (method == null) { - throw new RuntimeException("There is no getter for property named '" + propertyName - + "' in '" + type + "'"); + throw new RuntimeException( + "There is no getter for property named '" + propertyName + "' in '" + type + "'"); } return method; } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/word/WordExportUtil.java b/easypoi-base/src/main/java/org/jeecgframework/poi/word/WordExportUtil.java index 1de77e1..39e5516 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/word/WordExportUtil.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/word/WordExportUtil.java @@ -55,8 +55,8 @@ public class WordExportUtil { * 解析数据源 * @return */ - public static void exportWord07(XWPFDocument document, Map map) - throws Exception { + public static void exportWord07(XWPFDocument document, + Map map) throws Exception { new ParseWord07().parseWord(document, map); } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/MyXWPFDocument.java b/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/MyXWPFDocument.java index 3f74398..72bec5b 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/MyXWPFDocument.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/MyXWPFDocument.java @@ -45,8 +45,7 @@ public class MyXWPFDocument extends XWPFDocument { + " " + " " + " " - + " " - + " " + + " " + " " + " " + " " + " " @@ -57,10 +56,9 @@ public class MyXWPFDocument extends XWPFDocument { + " " + " " + " " - + " " - + " " + " " - + " " + " " - + ""; + + " " + " " + + " " + " " + + " " + ""; public MyXWPFDocument() { super(); diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/params/ExcelListEntity.java b/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/params/ExcelListEntity.java index e6d055e..f6ea280 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/params/ExcelListEntity.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/word/entity/params/ExcelListEntity.java @@ -57,12 +57,15 @@ public class ExcelListEntity extends ExcelBaseParams { this.clazz = clazz; setDataHanlder(dataHanlder); } - public ExcelListEntity(List list, Class clazz, IExcelDataHandler dataHanlder, int headRows) { + + public ExcelListEntity(List list, Class clazz, IExcelDataHandler dataHanlder, + int headRows) { this.list = list; this.clazz = clazz; this.headRows = headRows; setDataHanlder(dataHanlder); } + public ExcelListEntity(List list, Class clazz, int headRows) { this.list = list; this.clazz = clazz; diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelEntityParse.java b/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelEntityParse.java index 5487462..2743b1c 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelEntityParse.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelEntityParse.java @@ -100,8 +100,8 @@ public class ExcelEntityParse extends ExportBase { * @param styles */ public void createListCells(int index, int cellNum, Object obj, - List excelParams, XWPFTable table) - throws Exception { + List excelParams, + XWPFTable table) throws Exception { ExcelExportEntity entity; XWPFTableRow row; if (table.getRow(index) == null) { @@ -183,9 +183,11 @@ public class ExcelEntityParse extends ExportBase { private void setCellValue(XWPFTableRow row, Object value, int cellNum) { if (row.getCell(cellNum++) != null) { row.getCell(cellNum - 1).setText(value == null ? "" : value.toString()); - PoiPublicUtil.setWordText(row.createCell().addParagraph().createRun(),value == null ? "" : value.toString()); + PoiPublicUtil.setWordText(row.createCell().addParagraph().createRun(), + value == null ? "" : value.toString()); } else { - PoiPublicUtil.setWordText(row.createCell().addParagraph().createRun(),value == null ? "" : value.toString()); + PoiPublicUtil.setWordText(row.createCell().addParagraph().createRun(), + value == null ? "" : value.toString()); } } diff --git a/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelMapParse.java b/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelMapParse.java index 98c9be0..0379dff 100644 --- a/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelMapParse.java +++ b/easypoi-base/src/main/java/org/jeecgframework/poi/word/parse/excel/ExcelMapParse.java @@ -82,12 +82,13 @@ public final class ExcelMapParse { for (cellIndex = 0; cellIndex < currentRow.getTableCells().size(); cellIndex++) { String val = eval(params[cellIndex], tempMap).toString(); currentRow.getTableCells().get(cellIndex).setText(""); - PoiPublicUtil.setWordText(currentRow.getTableCells().get(cellIndex).addParagraph().createRun(),val); + PoiPublicUtil.setWordText( + currentRow.getTableCells().get(cellIndex).addParagraph().createRun(), val); } for (; cellIndex < params.length; cellIndex++) { String val = eval(params[cellIndex], tempMap).toString(); - PoiPublicUtil.setWordText(currentRow.createCell().addParagraph().createRun(),val); + PoiPublicUtil.setWordText(currentRow.createCell().addParagraph().createRun(), val); } }