From 6421eb5d54c9bd2500e8fd9c3b693eaf17b38a54 Mon Sep 17 00:00:00 2001 From: jueyue Date: Sat, 22 Sep 2018 15:30:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=87=BA=E9=94=99=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easypoi-annotation/pom.xml | 2 +- easypoi-base/pom.xml | 2 +- .../afterturn/easypoi/cache/ExcelCache.java | 3 - .../easypoi/excel/entity/ExportParams.java | 4 +- .../excel/export/ExcelExportService.java | 8 +-- .../excel/export/base/BaseExportService.java | 13 +--- .../styler/ExcelExportStylerBorderImpl.java | 61 +++++++++--------- .../styler/ExcelExportStylerColorImpl.java | 44 +++++++------ .../styler/ExcelExportStylerDefaultImpl.java | 20 +++--- .../template/ExcelExportOfTemplateUtil.java | 27 ++++---- .../graph/builder/ExcelChartBuildService.java | 6 +- .../html/css/impl/AlignCssConvertImpl.java | 18 +++--- .../css/impl/BackgroundCssConvertImpl.java | 3 +- .../html/css/impl/BorderCssConverImpl.java | 21 ++++--- .../html/css/impl/TextCssConvertImpl.java | 4 +- .../excel/html/helper/CellValueHelper.java | 13 ++-- .../excel/html/helper/StylerHelper.java | 63 ++++++++----------- .../excel/imports/CellValueService.java | 16 ++--- .../excel/imports/ExcelImportService.java | 4 -- .../afterturn/easypoi/util/PoiCellUtil.java | 11 ++-- .../afterturn/easypoi/util/PoiCssUtils.java | 10 +-- .../afterturn/easypoi/util/PoiPublicUtil.java | 2 +- .../afterturn/easypoi/util/PoiSheetUtil.java | 10 +-- easypoi-web/pom.xml | 2 +- pom.xml | 16 ++--- 25 files changed, 175 insertions(+), 208 deletions(-) diff --git a/easypoi-annotation/pom.xml b/easypoi-annotation/pom.xml index 0598d4a..ac6512a 100644 --- a/easypoi-annotation/pom.xml +++ b/easypoi-annotation/pom.xml @@ -4,7 +4,7 @@ cn.afterturn easypoi - 3.3.0 + 4.0.0-SNAPSHOT easypoi-annotation 基础注解类,解耦合 diff --git a/easypoi-base/pom.xml b/easypoi-base/pom.xml index 13ef61f..81b71f0 100644 --- a/easypoi-base/pom.xml +++ b/easypoi-base/pom.xml @@ -4,7 +4,7 @@ cn.afterturn easypoi - 3.3.0 + 4.0.0-SNAPSHOT easypoi-base diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/ExcelCache.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/ExcelCache.java index 2096064..170f360 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/ExcelCache.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/cache/ExcelCache.java @@ -19,7 +19,6 @@ import java.io.InputStream; import java.util.Arrays; import java.util.List; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.slf4j.Logger; @@ -53,8 +52,6 @@ public final class ExcelCache { } } return wb; - } catch (InvalidFormatException e) { - LOGGER.error(e.getMessage(), e); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } finally { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExportParams.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExportParams.java index ffc70ed..2d92092 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExportParams.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExportParams.java @@ -70,11 +70,11 @@ public class ExportParams extends ExcelBaseParams { /** * 表头颜色 */ - private short color = HSSFColor.WHITE.index; + private short color = HSSFColor.HSSFColorPredefined.WHITE.getIndex(); /** * 属性说明行的颜色 例如:HSSFColor.SKY_BLUE.index 默认 */ - private short headerColor = HSSFColor.SKY_BLUE.index; + private short headerColor = HSSFColor.HSSFColorPredefined.SKY_BLUE.getIndex(); /** * Excel 导出版本 */ diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportService.java index 3e0638e..be00db3 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportService.java @@ -24,11 +24,7 @@ import java.util.List; import cn.afterturn.easypoi.util.PoiMergeCellUtil; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Drawing; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import cn.afterturn.easypoi.excel.annotation.ExcelTarget; @@ -146,7 +142,7 @@ public class ExcelExportService extends BaseExportService { row = sheet.createRow(1); row.setHeight(entity.getSecondTitleHeight()); CellStyle style = workbook.createCellStyle(); - style.setAlignment(CellStyle.ALIGN_RIGHT); + style.setAlignment(HorizontalAlignment.RIGHT); createStringCell(row, 0, entity.getSecondTitle(), style, null); for (int i = 1; i <= fieldWidth; i++) { createStringCell(row, i, "", diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java index d16065a..35c59a4 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java @@ -17,14 +17,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.poi.hssf.usermodel.HSSFClientAnchor; import org.apache.poi.hssf.usermodel.HSSFRichTextString; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.ClientAnchor; -import org.apache.poi.ss.usermodel.Drawing; -import org.apache.poi.ss.usermodel.RichTextString; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFRichTextString; @@ -265,7 +258,7 @@ public abstract class BaseExportService extends ExportCommonService { Cell cell = row.createCell(index); if (style != null && style.getDataFormat() > 0 && style.getDataFormat() < 12) { cell.setCellValue(Double.parseDouble(text)); - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); } else { RichTextString rtext; if (type.equals(ExcelType.HSSF)) { @@ -290,7 +283,7 @@ public abstract class BaseExportService extends ExportCommonService { if (text != null && text.length() > 0) { cell.setCellValue(Double.parseDouble(text)); } - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); if (style != null) { cell.setCellStyle(style); } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerBorderImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerBorderImpl.java index 44303a9..6708787 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerBorderImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerBorderImpl.java @@ -1,13 +1,13 @@ /** * Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and @@ -15,17 +15,16 @@ */ package cn.afterturn.easypoi.excel.export.styler; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; /** * 带有边框的Excel样式 + * * @author JueYue - * 2015年1月9日 下午5:55:29 + * 2015年1月9日 下午5:55:29 */ public class ExcelExportStylerBorderImpl extends AbstractExcelExportStyler - implements IExcelExportStyler { + implements IExcelExportStyler { public ExcelExportStylerBorderImpl(Workbook workbook) { super.createStyles(workbook); @@ -37,24 +36,24 @@ public class ExcelExportStylerBorderImpl extends AbstractExcelExportStyler Font font = workbook.createFont(); font.setFontHeightInPoints((short) 12); titleStyle.setFont(font); - titleStyle.setBorderLeft((short) 1); // 左边框 - titleStyle.setBorderRight((short) 1); // 右边框 - titleStyle.setBorderBottom((short) 1); - titleStyle.setBorderTop((short) 1); - titleStyle.setAlignment(CellStyle.ALIGN_CENTER); - titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + titleStyle.setBorderLeft(BorderStyle.THIN); + titleStyle.setBorderRight(BorderStyle.THIN); + titleStyle.setBorderBottom(BorderStyle.THIN); + titleStyle.setBorderTop(BorderStyle.THIN); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); return titleStyle; } @Override public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); - style.setBorderLeft((short) 1); // 左边框 - style.setBorderRight((short) 1); // 右边框 - style.setBorderBottom((short) 1); - style.setBorderTop((short) 1); - style.setAlignment(CellStyle.ALIGN_CENTER); - style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + style.setBorderLeft(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT); if (isWarp) { style.setWrapText(true); @@ -65,12 +64,12 @@ public class ExcelExportStylerBorderImpl extends AbstractExcelExportStyler @Override public CellStyle getTitleStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); - titleStyle.setBorderLeft((short) 1); // 左边框 - titleStyle.setBorderRight((short) 1); // 右边框 - titleStyle.setBorderBottom((short) 1); - titleStyle.setBorderTop((short) 1); - titleStyle.setAlignment(CellStyle.ALIGN_CENTER); - titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + titleStyle.setBorderLeft(BorderStyle.THIN); + titleStyle.setBorderRight(BorderStyle.THIN); + titleStyle.setBorderBottom(BorderStyle.THIN); + titleStyle.setBorderTop(BorderStyle.THIN); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); titleStyle.setWrapText(true); return titleStyle; } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerColorImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerColorImpl.java index ec0a023..d8f50f1 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerColorImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerColorImpl.java @@ -15,9 +15,7 @@ */ package cn.afterturn.easypoi.excel.export.styler; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; /** * 带有样式的导出服务 @@ -38,20 +36,20 @@ public class ExcelExportStylerColorImpl extends AbstractExcelExportStyler font.setFontHeightInPoints((short) 24); titleStyle.setFont(font); titleStyle.setFillForegroundColor(headerColor); - titleStyle.setAlignment(CellStyle.ALIGN_CENTER); - titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); return titleStyle; } @Override public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); - style.setBorderLeft((short) 1); // 左边框 - style.setBorderRight((short) 1); // 右边框 - style.setBorderBottom((short) 1); - style.setBorderTop((short) 1); - style.setAlignment(CellStyle.ALIGN_CENTER); - style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + style.setBorderLeft(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT); if (isWarp) { style.setWrapText(true); @@ -62,10 +60,10 @@ public class ExcelExportStylerColorImpl extends AbstractExcelExportStyler @Override public CellStyle getTitleStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); - titleStyle.setFillForegroundColor(color); // 填充的背景颜色 - titleStyle.setAlignment(CellStyle.ALIGN_CENTER); - titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); - titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案 + titleStyle.setFillForegroundColor(color); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); + titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); titleStyle.setWrapText(true); return titleStyle; } @@ -73,14 +71,14 @@ public class ExcelExportStylerColorImpl extends AbstractExcelExportStyler @Override public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); - style.setBorderLeft((short) 1); // 左边框 - style.setBorderRight((short) 1); // 右边框 - style.setBorderBottom((short) 1); - style.setBorderTop((short) 1); - style.setFillForegroundColor((short) 41); // 填充的背景颜色 - style.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案 - style.setAlignment(CellStyle.ALIGN_CENTER); - style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + style.setBorderLeft(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setFillForegroundColor((short) 41); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT); if (isWarp) { style.setWrapText(true); diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerDefaultImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerDefaultImpl.java index 7942c52..305c74c 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerDefaultImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/styler/ExcelExportStylerDefaultImpl.java @@ -15,9 +15,7 @@ */ package cn.afterturn.easypoi.excel.export.styler; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; /** * 样式的默认实现 @@ -34,8 +32,8 @@ public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler @Override public CellStyle getTitleStyle(short color) { CellStyle titleStyle = workbook.createCellStyle(); - titleStyle.setAlignment(CellStyle.ALIGN_CENTER); - titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); titleStyle.setWrapText(true); return titleStyle; } @@ -43,8 +41,8 @@ public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler @Override public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); - style.setAlignment(CellStyle.ALIGN_CENTER); - style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT); if (isWarp) { style.setWrapText(true); @@ -58,16 +56,16 @@ public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler Font font = workbook.createFont(); font.setFontHeightInPoints((short) 12); titleStyle.setFont(font); - titleStyle.setAlignment(CellStyle.ALIGN_CENTER); - titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + titleStyle.setAlignment(HorizontalAlignment.CENTER); + titleStyle.setVerticalAlignment(VerticalAlignment.CENTER); return titleStyle; } @Override public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) { CellStyle style = workbook.createCellStyle(); - style.setAlignment(CellStyle.ALIGN_CENTER); - style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setDataFormat(STRING_FORMAT); if (isWarp) { style.setWrapText(true); 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 125d568..62ac827 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 @@ -30,12 +30,7 @@ import java.util.Set; import cn.afterturn.easypoi.util.*; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Drawing; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; @@ -348,8 +343,8 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { } for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) { cell = row.getCell(i); - if (row.getCell(i) != null && (cell.getCellType() == Cell.CELL_TYPE_STRING - || cell.getCellType() == Cell.CELL_TYPE_NUMERIC)) { + if (row.getCell(i) != null && (cell.getCellType() == CellType.STRING + || cell.getCellType() == CellType.NUMERIC)) { String text = PoiCellUtil.getCellValue(cell); if (text.contains(FOREACH_COL) || text.contains(FOREACH_COL_VALUE)) { foreachCol(cell, map, text); @@ -413,9 +408,9 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { } for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) { cell = row.getCell(i); - if (row.getCell(i) != null && (cell.getCellType() == Cell.CELL_TYPE_STRING - || cell.getCellType() == Cell.CELL_TYPE_NUMERIC)) { - cell.setCellType(Cell.CELL_TYPE_STRING); + if (row.getCell(i) != null && (cell.getCellType() == CellType.STRING + || cell.getCellType() == CellType.NUMERIC)) { + cell.setCellType(CellType.STRING); String text = cell.getStringCellValue(); if (text.contains(IF_DELETE)) { if (Boolean.valueOf( @@ -438,12 +433,12 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { * @param map */ private void setValueForCellByMap(Cell cell, Map map) throws Exception { - int cellType = cell.getCellType(); - if (cellType != Cell.CELL_TYPE_STRING && cellType != Cell.CELL_TYPE_NUMERIC) { + CellType cellType = cell.getCellType(); + if (cellType != CellType.STRING && cellType != CellType.NUMERIC) { return; } String oldString; - cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellType(CellType.STRING); oldString = cell.getStringCellValue(); if (oldString != null && oldString.indexOf(START_STR) != -1 && !oldString.contains(FOREACH)) { @@ -467,7 +462,7 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { createImageCell(cell,img.getHeight(),img.getUrl(),img.getData()); }else if (isNumber && StringUtils.isNotBlank(obj.toString())) { cell.setCellValue(Double.parseDouble(obj.toString())); - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); } else { cell.setCellValue(obj.toString()); } @@ -580,7 +575,7 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { createImageCell(row.getCell(ci),img.getHeight(),img.getUrl(),img.getData()); }else if (isNumber && StringUtils.isNotEmpty(val)) { row.getCell(ci).setCellValue(Double.parseDouble(val)); - row.getCell(ci).setCellType(Cell.CELL_TYPE_NUMERIC); + row.getCell(ci).setCellType(CellType.NUMERIC); } else { try { row.getCell(ci).setCellValue(val); 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 cb5f368..4bc5db7 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 @@ -44,7 +44,7 @@ public class ExcelChartBuildService /** * * @param workbook - * @param graph + * @param graphList * @param build 通过实时数据行来重新计算图形定义 * @param append */ @@ -78,7 +78,9 @@ public class ExcelChartBuildService * @param graph */ private static void buildExcelChart(Drawing drawing,ClientAnchor anchor,Sheet dataSourceSheet,ExcelGraph graph){ - Chart chart = drawing.createChart(anchor); + Chart chart = null; + // TODO 图表没有成功 + //drawing.createChart(anchor); ChartLegend legend = chart.getOrCreateLegend(); legend.setPosition(LegendPosition.TOP_RIGHT); diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/AlignCssConvertImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/AlignCssConvertImpl.java index 7380a18..c4b9134 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/AlignCssConvertImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/AlignCssConvertImpl.java @@ -7,6 +7,8 @@ import cn.afterturn.easypoi.excel.html.css.ICssConvertToExcel; import cn.afterturn.easypoi.excel.html.css.ICssConvertToHtml; import cn.afterturn.easypoi.excel.html.entity.HtmlCssConstant; import cn.afterturn.easypoi.excel.html.entity.style.CellStyleEntity; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; public class AlignCssConvertImpl implements ICssConvertToExcel, ICssConvertToHtml { @@ -20,23 +22,23 @@ public class AlignCssConvertImpl implements ICssConvertToExcel, ICssConvertToHtm public void convertToExcel(Cell cell, CellStyle cellStyle, CellStyleEntity style) { // align if (HtmlCssConstant.RIGHT.equals(style.getAlign())) { - cellStyle.setAlignment(CellStyle.ALIGN_RIGHT); + cellStyle.setAlignment(HorizontalAlignment.RIGHT); } else if (HtmlCssConstant.CENTER.equals(style.getAlign())) { - cellStyle.setAlignment(CellStyle.ALIGN_CENTER); + cellStyle.setAlignment(HorizontalAlignment.CENTER); } else if (HtmlCssConstant.LEFT.equals(style.getAlign())) { - cellStyle.setAlignment(CellStyle.ALIGN_LEFT); + cellStyle.setAlignment(HorizontalAlignment.LEFT); } else if (HtmlCssConstant.JUSTIFY.equals(style.getAlign())) { - cellStyle.setAlignment(CellStyle.ALIGN_JUSTIFY); + cellStyle.setAlignment(HorizontalAlignment.JUSTIFY); } // vertical align if (HtmlCssConstant.TOP.equals(style.getVetical())) { - cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); + cellStyle.setVerticalAlignment(VerticalAlignment.TOP); } else if (HtmlCssConstant.CENTER.equals(style.getAlign())) { - cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); } else if (HtmlCssConstant.BOTTOM.equals(style.getAlign())) { - cellStyle.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); + cellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM); } else if (HtmlCssConstant.JUSTIFY.equals(style.getAlign())) { - cellStyle.setVerticalAlignment(CellStyle.VERTICAL_JUSTIFY); + cellStyle.setVerticalAlignment(VerticalAlignment.JUSTIFY); } } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BackgroundCssConvertImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BackgroundCssConvertImpl.java index 12d5874..5a84332 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BackgroundCssConvertImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BackgroundCssConvertImpl.java @@ -5,6 +5,7 @@ import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCellStyle; @@ -26,7 +27,7 @@ public class BackgroundCssConvertImpl implements ICssConvertToExcel, ICssConvert if (StringUtils.isEmpty(style.getBackground())) { return; } - cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); // 填充图案 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); // 填充图案 if (cell instanceof XSSFCell) { ((XSSFCellStyle) cellStyle) .setFillForegroundColor(PoiCssUtils.parseColor(style.getBackground())); diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BorderCssConverImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BorderCssConverImpl.java index 1dc5f13..70706b3 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BorderCssConverImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/BorderCssConverImpl.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.reflect.MethodUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.xssf.usermodel.XSSFCell; @@ -109,31 +110,31 @@ public class BorderCssConverImpl implements ICssConvertToExcel, ICssConvertToHtm } catch (Exception e) { log.error("Set Border Style Error Caused.", e); } - short shortValue = -1; + BorderStyle shortValue = BorderStyle.NONE; // empty or solid if (StringUtils.isBlank(styleValue) || "solid".equals(styleValue)) { if (width > 2) { - shortValue = CellStyle.BORDER_THICK; + shortValue = BorderStyle.THICK; } else if (width > 1) { - shortValue = CellStyle.BORDER_MEDIUM; + shortValue = BorderStyle.MEDIUM; } else { - shortValue = CellStyle.BORDER_THIN; + shortValue = BorderStyle.THIN; } } else if (ArrayUtils.contains(new String[] { NONE, HIDDEN }, styleValue)) { - shortValue = CellStyle.BORDER_NONE; + shortValue = BorderStyle.NONE; } else if (DOUBLE.equals(styleValue)) { - shortValue = CellStyle.BORDER_DOUBLE; + shortValue = BorderStyle.DOUBLE; } else if (DOTTED.equals(styleValue)) { - shortValue = CellStyle.BORDER_DOTTED; + shortValue = BorderStyle.DOTTED; } else if (DASHED.equals(styleValue)) { if (width > 1) { - shortValue = CellStyle.BORDER_MEDIUM_DASHED; + shortValue = BorderStyle.MEDIUM_DASHED; } else { - shortValue = CellStyle.BORDER_DASHED; + shortValue = BorderStyle.DASHED; } } // border style - if (shortValue != -1) { + if (shortValue != BorderStyle.NONE) { try { MethodUtils.invokeMethod(cellStyle, "setBorder" + posName, shortValue); } catch (Exception e) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/TextCssConvertImpl.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/TextCssConvertImpl.java index 32ca1c4..4ec0df9 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/TextCssConvertImpl.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/css/impl/TextCssConvertImpl.java @@ -1,12 +1,12 @@ package cn.afterturn.easypoi.excel.html.css.impl; import static cn.afterturn.easypoi.excel.html.entity.HtmlCssConstant.*; +import static org.apache.poi.ss.usermodel.IndexedColors.BLACK; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.hssf.util.HSSFColor.BLACK; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; @@ -41,7 +41,7 @@ public class TextCssConvertImpl implements ICssConvertToExcel, ICssConvertToHtml font.setFontHeightInPoints((short) fontSize); } if (BOLD.equals(style.getFont().getWeight())) { - font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setBold(true); } String fontFamily = style.getFont().getFamily(); if (StringUtils.isNotBlank(fontFamily)) { 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 20f4e46..5073216 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 @@ -6,6 +6,7 @@ import java.util.Map; import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFFont; @@ -49,7 +50,7 @@ public class CellValueHelper { private void cacheFontInfo(Workbook wb) { for (short i = 0, le = wb.getNumberOfFonts(); i < le; i++) { Font font = wb.getFontAt(i); - fontCache.put(font.getBoldweight() + "_" + font.getItalic() + "_" + font.getFontName() + fontCache.put(font.getBold() + "_" + font.getItalic() + "_" + font.getFontName() + "_" + font.getFontHeightInPoints() + "_" + font.getColor(), font.getIndex() + ""); } @@ -57,11 +58,11 @@ public class CellValueHelper { } public String getHtmlValue(Cell cell) { - if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType() - || Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { - cell.setCellType(Cell.CELL_TYPE_STRING); + if (CellType.BOOLEAN == cell.getCellType() + || CellType.NUMERIC == cell.getCellType()) { + cell.setCellType(CellType.STRING); return cell.getStringCellValue(); - } else if (Cell.CELL_TYPE_STRING == cell.getCellType()) { + } else if (CellType.STRING == cell.getCellType()) { if (cell.getRichStringCellValue().numFormattingRuns() == 0) { return XmlEscapers.xmlContentEscaper().escape(cell.getStringCellValue()); } else if (is07) { @@ -135,7 +136,7 @@ public class CellValueHelper { private String getFontIndex(XSSFFont font) { return fontCache - .get(font.getBoldweight() + "_" + font.getItalic() + "_" + font.getFontName() + "_" + .get(font.getBold() + "_" + font.getItalic() + "_" + font.getFontName() + "_" + font.getFontHeightInPoints() + "_" + font.getColor()); } } 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 a6a0ef2..cb65c17 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 @@ -1,15 +1,5 @@ package cn.afterturn.easypoi.excel.html.helper; -import static org.apache.poi.ss.usermodel.CellStyle.ALIGN_CENTER; -import static org.apache.poi.ss.usermodel.CellStyle.ALIGN_CENTER_SELECTION; -import static org.apache.poi.ss.usermodel.CellStyle.ALIGN_FILL; -import static org.apache.poi.ss.usermodel.CellStyle.ALIGN_JUSTIFY; -import static org.apache.poi.ss.usermodel.CellStyle.ALIGN_LEFT; -import static org.apache.poi.ss.usermodel.CellStyle.ALIGN_RIGHT; -import static org.apache.poi.ss.usermodel.CellStyle.VERTICAL_BOTTOM; -import static org.apache.poi.ss.usermodel.CellStyle.VERTICAL_CENTER; -import static org.apache.poi.ss.usermodel.CellStyle.VERTICAL_TOP; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -23,13 +13,7 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFPalette; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.Color; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFCellStyle; import org.apache.poi.xssf.usermodel.XSSFColor; import org.apache.poi.xssf.usermodel.XSSFFont; @@ -39,31 +23,34 @@ import cn.afterturn.easypoi.util.PoiPublicUtil; /** * 样式帮助类 + * * @author JueYue - * 2015年5月9日 下午4:04:24 + * 2015年5月9日 下午4:04:24 */ public class StylerHelper { - private static String DEFAULTS_CLASS_CSS = ".excelDefaults {background-color: white;color: black;text-decoration: none;direction: ltr;text-transform: none;text-indent: 0;letter-spacing: 0;word-spacing: 0;white-space: normal;unicode-bidi: normal;vertical-align: 0;text-shadow: none;padding: 0;margin: 0;border-collapse: collapse;white-space: pre-wrap;word-wrap: break-word;word-break: break-all;}.excelDefaults td {padding: 1px 5px;border: 1px solid silver;border-color: #000000;text-align: center;vertical-align: middle;font-size: 12pt;}.excelDefaults .colHeader {background-color: silver;font-weight: bold;border: 1px solid black;text-align: center;padding: 1px 5px;}.excelDefaults .rowHeader {background-color: silver;font-weight: bold;border: 1px solid black;text-align: right;padding: 1px 5px;}"; + private static String DEFAULTS_CLASS_CSS = ".excelDefaults {background-color: white;color: black;text-decoration: none;direction: ltr;text-transform: none;text-indent: 0;letter-spacing: 0;word-spacing: 0;white-space: normal;unicode-bidi: normal;vertical-align: 0;text-shadow: none;padding: 0;margin: 0;border-collapse: collapse;white-space: pre-wrap;word-wrap: break-word;word-break: break-all;}.excelDefaults td {padding: 1px 5px;border: 1px solid silver;border-color: #000000;text-align: center;vertical-align: middle;font-size: 12pt;}.excelDefaults .colHeader {background-color: silver;font-weight: bold;border: 1px solid black;text-align: center;padding: 1px 5px;}.excelDefaults .rowHeader {background-color: silver;font-weight: bold;border: 1px solid black;text-align: right;padding: 1px 5px;}"; - private static final String DEFAULTS_CLASS = "excelDefaults"; + 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 ALIGN = PoiPublicUtil.mapFor(HorizontalAlignment.LEFT, + "left", HorizontalAlignment.CENTER, "center", HorizontalAlignment.RIGHT, "right", HorizontalAlignment.FILL, + "left", HorizontalAlignment.JUSTIFY, + "left", HorizontalAlignment.CENTER_SELECTION, "center"); - private static final Map VERTICAL_ALIGN = PoiPublicUtil - .mapFor(VERTICAL_BOTTOM, "bottom", VERTICAL_CENTER, "middle", VERTICAL_TOP, "top"); + private static final Map VERTICAL_ALIGN = PoiPublicUtil + .mapFor(VerticalAlignment.BOTTOM, "bottom", VerticalAlignment.CENTER, + "middle", VerticalAlignment.TOP, "top"); - private Formatter out; + private Formatter out; - private Sheet sheet; + private Sheet sheet; - private HtmlHelper helper; + private HtmlHelper helper; - private int sheetNum; + private int sheetNum; - private int cssRandom; + private int cssRandom; public StylerHelper(Workbook wb, Formatter out, int sheetNum, int cssRandom) { this.out = out; @@ -123,7 +110,7 @@ public class StylerHelper { Formatter formatter = new Formatter(sb); try { in = new BufferedReader( - new InputStreamReader(StylerHelper.class.getResourceAsStream("excelStyle.css"))); + new InputStreamReader(StylerHelper.class.getResourceAsStream("excelStyle.css"))); String line; while ((line = in.readLine()) != null) { formatter.format("%s%n", line); @@ -150,15 +137,15 @@ public class StylerHelper { } private void styleContents(CellStyle style) { - if (style.getAlignment() != 2) { + if (style.getAlignment() != HorizontalAlignment.CENTER) { styleOut("text-align", style.getAlignment(), ALIGN); - styleOut("vertical-align", style.getAlignment(), VERTICAL_ALIGN); + styleOut("vertical-align", style.getVerticalAlignment(), VERTICAL_ALIGN); } helper.colorStyles(style, out); } private void fontStyle(Font font) { - if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) { + if (font.getBold()) { out.format(" font-weight: bold;%n"); } if (font.getItalic()) { @@ -177,7 +164,7 @@ public class StylerHelper { private Color getColor(Font font) { if (helper instanceof HSSFHtmlHelper) { return ((HSSFWorkbook) sheet.getWorkbook()).getCustomPalette() - .getColor(font.getColor()); + .getColor(font.getColor()); } else { return ((XSSFFont) font).getXSSFColor(); } @@ -211,9 +198,9 @@ public class StylerHelper { private class HSSFHtmlHelper implements HtmlHelper { private final HSSFWorkbook wb; - private final HSSFPalette colors; + private final HSSFPalette colors; - private HSSFColor hssfAuto = new HSSFColor.AUTOMATIC(); + private HSSFColor hssfAuto = HSSFColor.HSSFColorPredefined.AUTOMATIC.getColor(); public HSSFHtmlHelper(HSSFWorkbook wb) { this.wb = wb; @@ -235,7 +222,7 @@ public class StylerHelper { } else { short[] rgb = color.getTriplet(); out.format(" %s: #%02x%02x%02x; /* index = %d */%n", attr, rgb[0], rgb[1], rgb[2], - index); + index); } } diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java index 5b0abfa..0a1fafa 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/CellValueService.java @@ -81,7 +81,7 @@ public class CellValueService { result = getDateData(entity, cell.getStringCellValue()); }*/ //FIX: 单元格yyyyMMdd数字时候使用 cell.getDateCellValue() 解析出的日期错误 - if (Cell.CELL_TYPE_NUMERIC == cell.getCellType() && DateUtil.isCellDateFormatted(cell)) { + if (CellType.NUMERIC == cell.getCellType() && DateUtil.isCellDateFormatted(cell)) { result = DateUtil.getJavaDate(cell.getNumericCellValue()); } else { cell.setCellType(CellType.STRING); @@ -96,15 +96,15 @@ public class CellValueService { if (("class java.sql.Timestamp").equals(classFullName)) { result = new Timestamp(((Date) result).getTime()); } - } else if (Cell.CELL_TYPE_NUMERIC == cell.getCellType() && DateUtil.isCellDateFormatted(cell)) { + } else if (CellType.NUMERIC == cell.getCellType() && DateUtil.isCellDateFormatted(cell)) { result = DateUtil.getJavaDate(cell.getNumericCellValue()); } else { switch (cell.getCellType()) { - case Cell.CELL_TYPE_STRING: + case STRING: result = cell.getRichStringCellValue() == null ? "" : cell.getRichStringCellValue().getString(); break; - case Cell.CELL_TYPE_NUMERIC: + case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { if ("class java.lang.String".equals(classFullName)) { result = formateDate(entity, cell.getDateCellValue()); @@ -113,14 +113,14 @@ public class CellValueService { result = readNumericCell(cell); } break; - case Cell.CELL_TYPE_BOOLEAN: + case BOOLEAN: result = Boolean.toString(cell.getBooleanCellValue()); break; - case Cell.CELL_TYPE_BLANK: + case BLANK: break; - case Cell.CELL_TYPE_ERROR: + case ERROR: break; - case Cell.CELL_TYPE_FORMULA: + case FORMULA: try { result = readNumericCell(cell); } catch (Exception e1) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportService.java index 7497f67..0965514 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportService.java @@ -18,10 +18,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.apache.poi.openxml4j.opc.OPCPackage; -import org.apache.poi.poifs.filesystem.DocumentFactoryHelper; -import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; 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 f516e88..2f8c364 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 @@ -4,6 +4,7 @@ package cn.afterturn.easypoi.util; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; @@ -104,24 +105,24 @@ public class PoiCellUtil { return ""; } - if (cell.getCellType() == Cell.CELL_TYPE_STRING) { + if (cell.getCellType() == CellType.STRING) { return cell.getStringCellValue(); - } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { + } else if (cell.getCellType() == CellType.BOOLEAN) { return String.valueOf(cell.getBooleanCellValue()); - } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + } else if (cell.getCellType() == CellType.FORMULA) { return cell.getStringCellValue(); - } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { + } else if (cell.getCellType() == CellType.NUMERIC) { return String.valueOf(cell.getNumericCellValue()); } else { - cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellType(CellType.STRING); return cell.getStringCellValue(); } } 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 d8a9fe9..75d2745 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 @@ -40,17 +40,17 @@ public class PoiCssUtils { colors.put(colorName(color.getValue().getClass()), color.getValue()); } // light gray - HSSFColor color = colors.get(colorName(HSSFColor.GREY_25_PERCENT.class)); + HSSFColor color = colors.get(colorName(HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getColor().getClass())); colors.put("lightgray", color); colors.put("lightgrey", color); // silver - colors.put("silver", colors.get(colorName(HSSFColor.GREY_40_PERCENT.class))); + colors.put("silver", colors.get(colorName(HSSFColor.HSSFColorPredefined.GREY_40_PERCENT.getColor().getClass()))); // darkgray - color = colors.get(colorName(HSSFColor.GREY_50_PERCENT.class)); + color = colors.get(colorName(HSSFColor.HSSFColorPredefined.GREY_50_PERCENT.getColor().getClass())); colors.put("darkgray", color); colors.put("darkgrey", color); // gray - color = colors.get(colorName(HSSFColor.GREY_80_PERCENT.class)); + color = colors.get(colorName(HSSFColor.HSSFColorPredefined.GREY_80_PERCENT.getColor().getClass())); colors.put("gray", color); colors.put("grey", color); } @@ -165,7 +165,7 @@ public class PoiCssUtils { if (StringUtils.isNotBlank(color)) { Color awtColor = Color.decode(color); if (awtColor != null) { - poiColor = new XSSFColor(awtColor); + poiColor = new XSSFColor(awtColor,null); } } return poiColor; 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 4bc172d..b64f270 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 @@ -33,13 +33,13 @@ import java.util.Map; import javax.imageio.ImageIO; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.hssf.usermodel.HSSFClientAnchor; import org.apache.poi.hssf.usermodel.HSSFPicture; import org.apache.poi.hssf.usermodel.HSSFPictureData; import org.apache.poi.hssf.usermodel.HSSFShape; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ooxml.POIXMLDocumentPart; import org.apache.poi.ss.usermodel.PictureData; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFDrawing; diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtil.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtil.java index 2a6c8da..825de7f 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtil.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/util/PoiSheetUtil.java @@ -83,23 +83,23 @@ public class PoiSheetUtil { cNew.setCellStyle(cOld.getCellStyle()); switch (cNew.getCellType()) { - case Cell.CELL_TYPE_BOOLEAN: { + case BOOLEAN: { cNew.setCellValue(cOld.getBooleanCellValue()); break; } - case Cell.CELL_TYPE_NUMERIC: { + case NUMERIC: { cNew.setCellValue(cOld.getNumericCellValue()); break; } - case Cell.CELL_TYPE_STRING: { + case STRING: { cNew.setCellValue(cOld.getStringCellValue()); break; } - case Cell.CELL_TYPE_ERROR: { + case ERROR: { cNew.setCellValue(cOld.getErrorCellValue()); break; } - case Cell.CELL_TYPE_FORMULA: { + case FORMULA: { cNew.setCellFormula(cOld.getCellFormula()); break; } diff --git a/easypoi-web/pom.xml b/easypoi-web/pom.xml index f5a19dd..dacaf4d 100644 --- a/easypoi-web/pom.xml +++ b/easypoi-web/pom.xml @@ -4,7 +4,7 @@ cn.afterturn easypoi - 3.3.0 + 4.0.0-SNAPSHOT easypoi-web diff --git a/pom.xml b/pom.xml index cfcf1d4..17627a6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 cn.afterturn easypoi - 3.3.0 + 4.0.0-SNAPSHOT pom easypoi @@ -45,13 +45,13 @@ - 3.3.0 - 3.15 + 4.0.0-SNAPSHOT + 4.0.0 2.9.1 16.0.1 3.2.1 1.6.1 - 4.3.8.RELEASE + 5.0.6.RELEASE @@ -94,8 +94,8 @@ org.apache.poi - ooxml-schemas - 1.3 + poi-ooxml-schemas + ${poi.version} true @@ -244,8 +244,8 @@ maven-compiler-plugin 3.0 - 1.6 - 1.6 + 1.8 + 1.8 UTF-8