diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExcelToHtmlParams.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExcelToHtmlParams.java index 4e16d81..e4a126e 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExcelToHtmlParams.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ExcelToHtmlParams.java @@ -28,6 +28,9 @@ public class ExcelToHtmlParams { */ private String path = null; + private boolean showRowNum = false; + private boolean showColumnHead = false; + public ExcelToHtmlParams(Workbook wb) { this.wb = wb; } @@ -98,6 +101,22 @@ public class ExcelToHtmlParams { this.path = path; } + public boolean isShowRowNum() { + return showRowNum; + } + + public void setShowRowNum(boolean showRowNum) { + this.showRowNum = showRowNum; + } + + public boolean isShowColumnHead() { + return showColumnHead; + } + + public void setShowColumnHead(boolean showColumnHead) { + this.showColumnHead = showColumnHead; + } + @Override public boolean equals(Object obj) { if (obj instanceof ExcelToHtmlParams) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ImportParams.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ImportParams.java index 50b74f8..3752975 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ImportParams.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/ImportParams.java @@ -102,6 +102,14 @@ public class ImportParams extends ExcelBaseParams { * 仅仅支持titleRows + headRows + startRows 以及 lastOfInvalidRow */ private boolean readSingleCell = false; + /** + * 是否并行计算 + */ + private boolean concurrentTask = false; + /** + * 最小截取大小 + */ + private Integer critical = 1000; public int getHeadRows() { return headRows; @@ -238,4 +246,20 @@ public class ImportParams extends ExcelBaseParams { public void setNeedCheckOrder(boolean needCheckOrder) { this.needCheckOrder = needCheckOrder; } + + public boolean isConcurrentTask() { + return concurrentTask; + } + + public void setConcurrentTask(boolean concurrentTask) { + this.concurrentTask = concurrentTask; + } + + public Integer getCritical() { + return critical; + } + + public void setCritical(Integer critical) { + this.critical = critical; + } } 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 93a7e60..57f923d 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 @@ -621,11 +621,15 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { private void setMergedRegionStyle(Row row, int ci, ExcelForEachParams params) { //第一行数据 for (int i = 1; i < params.getColspan(); i++) { - row.getCell(ci + i).setCellStyle(params.getCellStyle()); + if(params.getCellStyle() != null){ + row.getCell(ci + i).setCellStyle(params.getCellStyle()); + } } for (int i = 1; i < params.getRowspan(); i++) { for (int j = 0; j < params.getColspan(); j++) { - row.getCell(ci + j).setCellStyle(params.getCellStyle()); + if(params.getCellStyle() != null){ + row.getCell(ci + j).setCellStyle(params.getCellStyle()); + } } } } @@ -785,6 +789,9 @@ public final class ExcelExportOfTemplateUtil extends BaseExportService { try { this.teplateParams = params; wb = getCloneWorkBook(); + // 创建表格样式 + setExcelExportStyler((IExcelExportStyler) teplateParams.getStyle() + .getConstructor(Workbook.class).newInstance(wb)); // step 3. 解析模板 for (int i = 0, le = params.isScanAllsheet() ? wb.getNumberOfSheets() : params.getSheetNum().length; i < le; i++) { diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlService.java index 7028ed1..a34a288 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlService.java +++ b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/html/ExcelToHtmlService.java @@ -34,19 +34,21 @@ public class ExcelToHtmlService { private String today; private Workbook wb; - private int sheetNum; - private int cssRandom; + 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 static final String ROW_HEAD_CLASS = "rowHeader"; + private boolean gotBounds; + private int firstColumn; + private int endColumn; + private String imageCachePath; + private boolean showRowNum; + private boolean showColumnHead; + private static final String COL_HEAD_CLASS = "colHeader"; + private static final String ROW_HEAD_CLASS = "rowHeader"; private static final String DEFAULTS_CLASS = "excelDefaults"; @@ -57,9 +59,11 @@ public class ExcelToHtmlService { this.wb = params.getWb(); this.completeHTML = params.isCompleteHTML(); this.sheetNum = params.getSheetNum(); - cssRandom = (int) Math.ceil(Math.random() * 1000); + this.cssRandom = (int) Math.ceil(Math.random() * 1000); this.imageCachePath = params.getPath(); - today = new SimpleDateFormat("yyyy_MM_dd").format(new Date()); + this.showRowNum = params.isShowRowNum(); + this.showColumnHead = params.isShowColumnHead(); + this.today = new SimpleDateFormat("yyyy_MM_dd").format(new Date()); } public String printPage() { @@ -125,17 +129,19 @@ public class ExcelToHtmlService { } private void printSheet(Sheet sheet) { - out.format("
+ * 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,51 +15,32 @@
*/
package cn.afterturn.easypoi.util;
-import static cn.afterturn.easypoi.util.PoiElUtil.*;
-
-import java.awt.image.BufferedImage;
-import java.io.*;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.imageio.ImageIO;
-
+import cn.afterturn.easypoi.cache.ImageCache;
+import cn.afterturn.easypoi.entity.ImageEntity;
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
+import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
+import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
+import cn.afterturn.easypoi.word.entity.params.ExcelListEntity;
import org.apache.commons.lang3.StringUtils;
-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.hssf.usermodel.*;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.PictureData;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
-import org.apache.poi.xssf.usermodel.XSSFDrawing;
-import org.apache.poi.xssf.usermodel.XSSFPicture;
-import org.apache.poi.xssf.usermodel.XSSFShape;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import cn.afterturn.easypoi.cache.ImageCache;
-import cn.afterturn.easypoi.excel.annotation.Excel;
-import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
-import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
-import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
-import cn.afterturn.easypoi.entity.ImageEntity;
-import cn.afterturn.easypoi.word.entity.params.ExcelListEntity;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.util.*;
+
+import static cn.afterturn.easypoi.util.PoiElUtil.END_STR;
+import static cn.afterturn.easypoi.util.PoiElUtil.START_STR;
/**
* EASYPOI 的公共基础类
@@ -74,7 +55,7 @@ public final class PoiPublicUtil {
}
- @SuppressWarnings({ "unchecked" })
+ @SuppressWarnings({"unchecked"})
public static