@@ -4,7 +4,7 @@ | |||
<parent> | |||
<groupId>cn.afterturn</groupId> | |||
<artifactId>easypoi</artifactId> | |||
<version>3.3.0</version> | |||
<version>4.0.0-SNAPSHOT</version> | |||
</parent> | |||
<artifactId>easypoi-annotation</artifactId> | |||
<description>基础注解类,解耦合</description> |
@@ -4,7 +4,7 @@ | |||
<parent> | |||
<groupId>cn.afterturn</groupId> | |||
<artifactId>easypoi</artifactId> | |||
<version>3.3.0</version> | |||
<version>4.0.0-SNAPSHOT</version> | |||
</parent> | |||
<artifactId>easypoi-base</artifactId> | |||
<dependencies> | |||
@@ -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 { | |||
@@ -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 导出版本 | |||
*/ | |||
@@ -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, "", | |||
@@ -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); | |||
} | |||
@@ -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 | |||
* <p> | |||
* 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 | |||
* <p> | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* <p> | |||
* 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; | |||
} | |||
@@ -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); | |||
@@ -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); | |||
@@ -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<String, Object> 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); | |||
@@ -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); | |||
@@ -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); | |||
} | |||
} | |||
@@ -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())); | |||
@@ -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) { | |||
@@ -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)) { | |||
@@ -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()); | |||
} | |||
} |
@@ -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<Short, String> 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<HorizontalAlignment, String> 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<Short, String> VERTICAL_ALIGN = PoiPublicUtil | |||
.mapFor(VERTICAL_BOTTOM, "bottom", VERTICAL_CENTER, "middle", VERTICAL_TOP, "top"); | |||
private static final Map<VerticalAlignment, String> 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); | |||
} | |||
} | |||
@@ -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) { | |||
@@ -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; | |||
@@ -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(); | |||
} | |||
} | |||
@@ -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; | |||
@@ -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; | |||
@@ -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; | |||
} | |||
@@ -4,7 +4,7 @@ | |||
<parent> | |||
<groupId>cn.afterturn</groupId> | |||
<artifactId>easypoi</artifactId> | |||
<version>3.3.0</version> | |||
<version>4.0.0-SNAPSHOT</version> | |||
</parent> | |||
<artifactId>easypoi-web</artifactId> | |||
<dependencies> | |||
@@ -3,7 +3,7 @@ | |||
<modelVersion>4.0.0</modelVersion> | |||
<groupId>cn.afterturn</groupId> | |||
<artifactId>easypoi</artifactId> | |||
<version>3.3.0</version> | |||
<version>4.0.0-SNAPSHOT</version> | |||
<packaging>pom</packaging> | |||
<name>easypoi</name> | |||
<modules> | |||
@@ -45,13 +45,13 @@ | |||
</organization> | |||
<properties> | |||
<sub.version>3.3.0</sub.version> | |||
<poi.version>3.15</poi.version> | |||
<sub.version>4.0.0-SNAPSHOT</sub.version> | |||
<poi.version>4.0.0</poi.version> | |||
<xerces.version>2.9.1</xerces.version> | |||
<guava.version>16.0.1</guava.version> | |||
<commons-lang.version>3.2.1</commons-lang.version> | |||
<slf4j.version>1.6.1</slf4j.version> | |||
<spring.version>4.3.8.RELEASE</spring.version> | |||
<spring.version>5.0.6.RELEASE</spring.version> | |||
</properties> | |||
<dependencyManagement> | |||
<dependencies> | |||
@@ -94,8 +94,8 @@ | |||
<!-- Word 使用--> | |||
<dependency> | |||
<groupId>org.apache.poi</groupId> | |||
<artifactId>ooxml-schemas</artifactId> | |||
<version>1.3</version> | |||
<artifactId>poi-ooxml-schemas</artifactId> | |||
<version>${poi.version}</version> | |||
<optional>true</optional> | |||
</dependency> | |||
@@ -244,8 +244,8 @@ | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
<version>3.0</version> | |||
<configuration> | |||
<source>1.6</source> | |||
<target>1.6</target> | |||
<source>1.8</source> | |||
<target>1.8</target> | |||
<encoding>UTF-8</encoding> | |||
</configuration> | |||
</plugin> | |||