@@ -97,6 +97,12 @@ | |||
<artifactId>validation-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.projectlombok</groupId> | |||
<artifactId>lombok</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>cn.afterturn</groupId> | |||
<artifactId>easypoi-annotation</artifactId> | |||
@@ -18,13 +18,14 @@ package cn.afterturn.easypoi.excel.entity; | |||
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
import cn.afterturn.easypoi.handler.inter.IExcelDictHandler; | |||
import cn.afterturn.easypoi.handler.inter.IExcelI18nHandler; | |||
import lombok.Data; | |||
/** | |||
* 基础参数 | |||
* @author JueYue | |||
* 2014年6月20日 下午1:56:52 | |||
*/ | |||
@SuppressWarnings("rawtypes") | |||
@Data | |||
public class ExcelBaseParams { | |||
/** | |||
@@ -41,27 +42,4 @@ public class ExcelBaseParams { | |||
*/ | |||
private IExcelI18nHandler i18nHandler; | |||
public IExcelDataHandler getDataHandler() { | |||
return dataHandler; | |||
} | |||
public void setDataHandler(IExcelDataHandler dataHandler) { | |||
this.dataHandler = dataHandler; | |||
} | |||
public IExcelDictHandler getDictHandler() { | |||
return dictHandler; | |||
} | |||
public void setDictHandler(IExcelDictHandler dictHandler) { | |||
this.dictHandler = dictHandler; | |||
} | |||
public IExcelI18nHandler getI18nHandler() { | |||
return i18nHandler; | |||
} | |||
public void setI18nHandler(IExcelI18nHandler i18nHandler) { | |||
this.i18nHandler = i18nHandler; | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package cn.afterturn.easypoi.excel.entity; | |||
import lombok.Data; | |||
import org.apache.poi.ss.usermodel.Workbook; | |||
/** | |||
@@ -7,6 +8,7 @@ import org.apache.poi.ss.usermodel.Workbook; | |||
* @author JueYue | |||
* 2015年8月7日 下午1:45:46 | |||
*/ | |||
@Data | |||
public class ExcelToHtmlParams { | |||
/** | |||
* Excel | |||
@@ -69,54 +71,6 @@ public class ExcelToHtmlParams { | |||
this.path = path; | |||
} | |||
public Workbook getWb() { | |||
return wb; | |||
} | |||
public void setWb(Workbook wb) { | |||
this.wb = wb; | |||
} | |||
public boolean isCompleteHTML() { | |||
return completeHTML; | |||
} | |||
public void setCompleteHTML(boolean completeHTML) { | |||
this.completeHTML = completeHTML; | |||
} | |||
public int getSheetNum() { | |||
return sheetNum; | |||
} | |||
public void setSheetNum(int sheetNum) { | |||
this.sheetNum = sheetNum; | |||
} | |||
public String getPath() { | |||
return path; | |||
} | |||
public void setPath(String path) { | |||
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) { | |||
@@ -7,29 +7,15 @@ import java.util.List; | |||
import java.util.Map; | |||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; | |||
import lombok.Data; | |||
/** | |||
* @author xfworld | |||
* @since 2016-5-26 | |||
* @version 1.0 | |||
*/ | |||
@Data | |||
public class ExportExcelItem { | |||
private List<ExcelExportEntity> entityList; | |||
private List<Map<String, Object>> resultList; | |||
public List<ExcelExportEntity> getEntityList() { | |||
return this.entityList; | |||
} | |||
public void setEntityList(List<ExcelExportEntity> entityList) { | |||
this.entityList = entityList; | |||
} | |||
public List<Map<String, Object>> getResultList() { | |||
return this.resultList; | |||
} | |||
public void setResultList(List<Map<String, Object>> resultList) { | |||
this.resultList = resultList; | |||
} | |||
} |
@@ -17,6 +17,7 @@ package cn.afterturn.easypoi.excel.entity; | |||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; | |||
import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl; | |||
import lombok.Data; | |||
import org.apache.poi.hssf.util.HSSFColor; | |||
/** | |||
@@ -25,6 +26,7 @@ import org.apache.poi.hssf.util.HSSFColor; | |||
* @author JueYue | |||
* @version 1.0 2013年8月24日 | |||
*/ | |||
@Data | |||
public class ExportParams extends ExcelBaseParams { | |||
/** | |||
@@ -142,171 +144,4 @@ public class ExportParams extends ExcelBaseParams { | |||
this.sheetName = sheetName; | |||
} | |||
public short getColor() { | |||
return color; | |||
} | |||
public String[] getExclusions() { | |||
return exclusions; | |||
} | |||
public short getHeaderColor() { | |||
return headerColor; | |||
} | |||
public String getSecondTitle() { | |||
return secondTitle; | |||
} | |||
public short getSecondTitleHeight() { | |||
return (short) (secondTitleHeight * 50); | |||
} | |||
public String getSheetName() { | |||
return sheetName; | |||
} | |||
public String getTitle() { | |||
return title; | |||
} | |||
public short getTitleHeight() { | |||
return (short) (titleHeight * 50); | |||
} | |||
public boolean isAddIndex() { | |||
return addIndex; | |||
} | |||
public void setAddIndex(boolean addIndex) { | |||
this.addIndex = addIndex; | |||
} | |||
public void setColor(short color) { | |||
this.color = color; | |||
} | |||
public void setExclusions(String[] exclusions) { | |||
this.exclusions = exclusions; | |||
} | |||
public void setHeaderColor(short headerColor) { | |||
this.headerColor = headerColor; | |||
} | |||
public void setSecondTitle(String secondTitle) { | |||
this.secondTitle = secondTitle; | |||
} | |||
public void setSecondTitleHeight(short secondTitleHeight) { | |||
this.secondTitleHeight = secondTitleHeight; | |||
} | |||
public void setSheetName(String sheetName) { | |||
this.sheetName = sheetName; | |||
} | |||
public void setTitle(String title) { | |||
this.title = title; | |||
} | |||
public void setTitleHeight(short titleHeight) { | |||
this.titleHeight = titleHeight; | |||
} | |||
public ExcelType getType() { | |||
return type; | |||
} | |||
public void setType(ExcelType type) { | |||
this.type = type; | |||
} | |||
public String getIndexName() { | |||
return indexName; | |||
} | |||
public void setIndexName(String indexName) { | |||
this.indexName = indexName; | |||
} | |||
public Class<?> getStyle() { | |||
return style; | |||
} | |||
public void setStyle(Class<?> style) { | |||
this.style = style; | |||
} | |||
public int getFreezeCol() { | |||
return freezeCol; | |||
} | |||
public void setFreezeCol(int freezeCol) { | |||
this.freezeCol = freezeCol; | |||
} | |||
public boolean isCreateHeadRows() { | |||
return isCreateHeadRows; | |||
} | |||
public void setCreateHeadRows(boolean isCreateHeadRows) { | |||
this.isCreateHeadRows = isCreateHeadRows; | |||
} | |||
public boolean isDynamicData() { | |||
return isDynamicData; | |||
} | |||
public void setDynamicData(boolean isDynamicData) { | |||
this.isDynamicData = isDynamicData; | |||
} | |||
public boolean isAppendGraph() { | |||
return isAppendGraph; | |||
} | |||
public void setAppendGraph(boolean isAppendGraph) { | |||
this.isAppendGraph = isAppendGraph; | |||
} | |||
public int getMaxNum() { | |||
return maxNum; | |||
} | |||
public void setMaxNum(int maxNum) { | |||
this.maxNum = maxNum; | |||
} | |||
public short getHeight() { | |||
return height == -1 ? -1 : (short) (height * 50); | |||
} | |||
public void setHeight(short height) { | |||
this.height = height; | |||
} | |||
public short getHeaderHeight() { | |||
return (short) (titleHeight * 50); | |||
} | |||
public void setHeaderHeight(double headerHeight) { | |||
this.headerHeight = headerHeight; | |||
} | |||
public boolean isFixedTitle() { | |||
return isFixedTitle; | |||
} | |||
public void setFixedTitle(boolean fixedTitle) { | |||
isFixedTitle = fixedTitle; | |||
} | |||
public boolean isReadonly() { | |||
return readonly; | |||
} | |||
public void setReadonly(boolean readonly) { | |||
this.readonly = readonly; | |||
} | |||
} |
@@ -16,6 +16,7 @@ | |||
package cn.afterturn.easypoi.excel.entity; | |||
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler; | |||
import lombok.Data; | |||
/** | |||
* 导入参数设置 | |||
@@ -24,7 +25,7 @@ import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler; | |||
* 2013-9-24 | |||
* @version 1.0 | |||
*/ | |||
@SuppressWarnings("rawtypes") | |||
@Data | |||
public class ImportParams extends ExcelBaseParams { | |||
public static final String SAVE_URL = "/excel/upload/excelUpload"; | |||
@@ -110,156 +111,4 @@ public class ImportParams extends ExcelBaseParams { | |||
* 最小截取大小 | |||
*/ | |||
private Integer critical = 1000; | |||
public int getHeadRows() { | |||
return headRows; | |||
} | |||
public String getSaveUrl() { | |||
return saveUrl; | |||
} | |||
public int getSheetNum() { | |||
return sheetNum; | |||
} | |||
public int getStartRows() { | |||
return startRows; | |||
} | |||
public int getTitleRows() { | |||
return titleRows; | |||
} | |||
public IExcelVerifyHandler getVerifyHandler() { | |||
return verifyHandler; | |||
} | |||
public boolean isNeedSave() { | |||
return needSave; | |||
} | |||
public void setHeadRows(int headRows) { | |||
this.headRows = headRows; | |||
} | |||
public void setKeyIndex(Integer keyIndex) { | |||
this.keyIndex = keyIndex; | |||
} | |||
public void setNeedSave(boolean needSave) { | |||
this.needSave = needSave; | |||
} | |||
public void setSaveUrl(String saveUrl) { | |||
this.saveUrl = saveUrl; | |||
} | |||
public void setSheetNum(int sheetNum) { | |||
this.sheetNum = sheetNum; | |||
} | |||
public void setStartRows(int startRows) { | |||
this.startRows = startRows; | |||
} | |||
public void setTitleRows(int titleRows) { | |||
this.titleRows = titleRows; | |||
} | |||
public void setVerifyHandler(IExcelVerifyHandler verifyHandler) { | |||
this.verifyHandler = verifyHandler; | |||
} | |||
public int getLastOfInvalidRow() { | |||
return lastOfInvalidRow; | |||
} | |||
public void setLastOfInvalidRow(int lastOfInvalidRow) { | |||
this.lastOfInvalidRow = lastOfInvalidRow; | |||
} | |||
public int getStartSheetIndex() { | |||
return startSheetIndex; | |||
} | |||
public void setStartSheetIndex(int startSheetIndex) { | |||
this.startSheetIndex = startSheetIndex; | |||
} | |||
public boolean isNeedVerify() { | |||
return needVerify; | |||
} | |||
public void setNeedVerify(boolean needVerify) { | |||
this.needVerify = needVerify; | |||
} | |||
public String[] getImportFields() { | |||
return importFields; | |||
} | |||
public void setImportFields(String[] importFields) { | |||
this.importFields = importFields; | |||
} | |||
public int getReadRows() { | |||
return readRows; | |||
} | |||
public void setReadRows(int readRows) { | |||
this.readRows = readRows; | |||
} | |||
public Integer getKeyIndex() { | |||
return keyIndex; | |||
} | |||
public String getKeyMark() { | |||
return keyMark; | |||
} | |||
public void setKeyMark(String keyMark) { | |||
this.keyMark = keyMark; | |||
} | |||
public boolean isReadSingleCell() { | |||
return readSingleCell; | |||
} | |||
public void setReadSingleCell(boolean readSingleCell) { | |||
this.readSingleCell = readSingleCell; | |||
} | |||
public Class[] getVerifyGroup() { | |||
return verifyGroup; | |||
} | |||
public void setVerifyGroup(Class[] verifyGroup) { | |||
this.verifyGroup = verifyGroup; | |||
} | |||
public boolean isNeedCheckOrder() { | |||
return needCheckOrder; | |||
} | |||
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; | |||
} | |||
} |
@@ -16,6 +16,7 @@ | |||
package cn.afterturn.easypoi.excel.entity; | |||
import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl; | |||
import lombok.Data; | |||
import org.apache.poi.ss.usermodel.Workbook; | |||
import java.io.InputStream; | |||
@@ -27,6 +28,7 @@ import java.io.InputStream; | |||
* 2013-10-17 | |||
* @version 1.0 | |||
*/ | |||
@Data | |||
public class TemplateExportParams extends ExcelBaseParams { | |||
/** | |||
@@ -128,107 +130,4 @@ public class TemplateExportParams extends ExcelBaseParams { | |||
} | |||
} | |||
public int getHeadingRows() { | |||
return headingRows; | |||
} | |||
public int getHeadingStartRow() { | |||
return headingStartRow; | |||
} | |||
public String[] getSheetName() { | |||
return sheetName; | |||
} | |||
public Integer[] getSheetNum() { | |||
return sheetNum; | |||
} | |||
public String getTemplateUrl() { | |||
return templateUrl; | |||
} | |||
public void setHeadingRows(int headingRows) { | |||
this.headingRows = headingRows; | |||
} | |||
public void setHeadingStartRow(int headingStartRow) { | |||
this.headingStartRow = headingStartRow; | |||
} | |||
public void setSheetName(String[] sheetName) { | |||
this.sheetName = sheetName; | |||
} | |||
public void setSheetName(String sheetName) { | |||
this.sheetName = new String[] { sheetName }; | |||
} | |||
public void setSheetNum(Integer[] sheetNum) { | |||
this.sheetNum = sheetNum; | |||
} | |||
public void setSheetNum(Integer sheetNum) { | |||
this.sheetNum = new Integer[] { sheetNum }; | |||
} | |||
public void setTemplateUrl(String templateUrl) { | |||
this.templateUrl = templateUrl; | |||
} | |||
public Class<?> getStyle() { | |||
return style; | |||
} | |||
public void setStyle(Class<?> style) { | |||
this.style = style; | |||
} | |||
public int getDataSheetNum() { | |||
return dataSheetNum; | |||
} | |||
public void setDataSheetNum(int dataSheetNum) { | |||
this.dataSheetNum = dataSheetNum; | |||
} | |||
public boolean isScanAllsheet() { | |||
return scanAllsheet; | |||
} | |||
public void setScanAllsheet(boolean scanAllsheet) { | |||
this.scanAllsheet = scanAllsheet; | |||
} | |||
public String getTempParams() { | |||
return tempParams; | |||
} | |||
public void setTempParams(String tempParams) { | |||
this.tempParams = tempParams; | |||
} | |||
public boolean isColForEach() { | |||
return colForEach; | |||
} | |||
public void setColForEach(boolean colForEach) { | |||
this.colForEach = colForEach; | |||
} | |||
public void setTemplateWb(Workbook templateWb) { | |||
this.templateWb = templateWb; | |||
} | |||
public Workbook getTemplateWb() { | |||
return templateWb; | |||
} | |||
public boolean isReadonly() { | |||
return readonly; | |||
} | |||
public void setReadonly(boolean readonly) { | |||
this.readonly = readonly; | |||
} | |||
} |
@@ -1,10 +1,13 @@ | |||
package cn.afterturn.easypoi.excel.entity; | |||
import lombok.Data; | |||
/** | |||
* 统计对象 | |||
* | |||
* @author JueYue | |||
*/ | |||
@Data | |||
public class TemplateSumEntity { | |||
/** | |||
@@ -28,45 +31,4 @@ public class TemplateSumEntity { | |||
*/ | |||
private double value; | |||
public String getCellValue() { | |||
return cellValue; | |||
} | |||
public void setCellValue(String cellValue) { | |||
this.cellValue = cellValue; | |||
} | |||
public String getSumKey() { | |||
return sumKey; | |||
} | |||
public void setSumKey(String sumKey) { | |||
this.sumKey = sumKey; | |||
} | |||
public int getCol() { | |||
return col; | |||
} | |||
public void setCol(int col) { | |||
this.col = col; | |||
} | |||
public int getRow() { | |||
return row; | |||
} | |||
public void setRow(int row) { | |||
this.row = row; | |||
} | |||
public double getValue() { | |||
return value; | |||
} | |||
public void setValue(double value) { | |||
this.value = value; | |||
} | |||
} |
@@ -19,12 +19,14 @@ import java.lang.reflect.Method; | |||
import java.util.List; | |||
import cn.afterturn.easypoi.excel.entity.vo.BaseEntityTypeConstants; | |||
import lombok.Data; | |||
/** | |||
* Excel 导入导出基础对象类 | |||
* @author JueYue | |||
* 2014年6月20日 下午2:26:09 | |||
*/ | |||
@Data | |||
public class ExcelBaseEntity { | |||
/** | |||
* 对应name | |||
@@ -73,104 +75,4 @@ public class ExcelBaseEntity { | |||
private List<Method> methods; | |||
public String getDatabaseFormat() { | |||
return databaseFormat; | |||
} | |||
public String getFormat() { | |||
return format; | |||
} | |||
public Method getMethod() { | |||
return method; | |||
} | |||
public List<Method> getMethods() { | |||
return methods; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public String[] getReplace() { | |||
return replace; | |||
} | |||
public int getType() { | |||
return type; | |||
} | |||
public void setDatabaseFormat(String databaseFormat) { | |||
this.databaseFormat = databaseFormat; | |||
} | |||
public void setFormat(String format) { | |||
this.format = format; | |||
} | |||
public void setMethod(Method method) { | |||
this.method = method; | |||
} | |||
public void setMethods(List<Method> methods) { | |||
this.methods = methods; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public void setReplace(String[] replace) { | |||
this.replace = replace; | |||
} | |||
public void setType(int type) { | |||
this.type = type; | |||
} | |||
public boolean isHyperlink() { | |||
return hyperlink; | |||
} | |||
public String getGroupName() { | |||
return groupName; | |||
} | |||
public void setGroupName(String groupName) { | |||
this.groupName = groupName; | |||
} | |||
public void setHyperlink(boolean hyperlink) { | |||
this.hyperlink = hyperlink; | |||
} | |||
public int getFixedIndex() { | |||
return fixedIndex; | |||
} | |||
public void setFixedIndex(int fixedIndex) { | |||
this.fixedIndex = fixedIndex; | |||
} | |||
public String getDict() { | |||
return dict; | |||
} | |||
public void setDict(String dict) { | |||
this.dict = dict; | |||
} | |||
public void setFixedIndex(Integer fixedIndex) { | |||
this.fixedIndex = fixedIndex; | |||
} | |||
public String getTimezone() { | |||
return timezone; | |||
} | |||
public void setTimezone(String timezone) { | |||
this.timezone = timezone; | |||
} | |||
} |
@@ -15,6 +15,8 @@ | |||
*/ | |||
package cn.afterturn.easypoi.excel.entity.params; | |||
import lombok.Data; | |||
import java.util.Map; | |||
/** | |||
@@ -24,6 +26,7 @@ import java.util.Map; | |||
* 2013-9-26 | |||
* @version 1.0 | |||
*/ | |||
@Data | |||
public class ExcelCollectionParams { | |||
/** | |||
@@ -43,35 +46,4 @@ public class ExcelCollectionParams { | |||
*/ | |||
private Map<String, ExcelImportEntity> excelParams; | |||
public Map<String, ExcelImportEntity> getExcelParams() { | |||
return excelParams; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public Class<?> getType() { | |||
return type; | |||
} | |||
public void setExcelParams(Map<String, ExcelImportEntity> excelParams) { | |||
this.excelParams = excelParams; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public void setType(Class<?> type) { | |||
this.type = type; | |||
} | |||
public String getExcelName() { | |||
return excelName; | |||
} | |||
public void setExcelName(String excelName) { | |||
this.excelName = excelName; | |||
} | |||
} |
@@ -15,6 +15,8 @@ | |||
*/ | |||
package cn.afterturn.easypoi.excel.entity.params; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
@@ -23,6 +25,7 @@ import java.util.List; | |||
* @author JueYue | |||
* @version 1.0 2013年8月24日 | |||
*/ | |||
@Data | |||
public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<ExcelExportEntity> { | |||
@@ -102,126 +105,6 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||
private List<ExcelExportEntity> list; | |||
public int getExportImageType() { | |||
return exportImageType; | |||
} | |||
public double getHeight() { | |||
return height; | |||
} | |||
public Object getKey() { | |||
return key; | |||
} | |||
public List<ExcelExportEntity> getList() { | |||
return list; | |||
} | |||
public int[] getMergeRely() { | |||
return mergeRely == null ? new int[0] : mergeRely; | |||
} | |||
public int getOrderNum() { | |||
return orderNum; | |||
} | |||
public double getWidth() { | |||
return width; | |||
} | |||
public boolean isMergeVertical() { | |||
return mergeVertical; | |||
} | |||
public boolean isNeedMerge() { | |||
return needMerge; | |||
} | |||
public boolean isWrap() { | |||
return isWrap; | |||
} | |||
public void setExportImageType(int exportImageType) { | |||
this.exportImageType = exportImageType; | |||
} | |||
public void setHeight(double height) { | |||
this.height = height; | |||
} | |||
public void setKey(Object key) { | |||
this.key = key; | |||
} | |||
public void setList(List<ExcelExportEntity> list) { | |||
this.list = list; | |||
} | |||
public void setMergeRely(int[] mergeRely) { | |||
this.mergeRely = mergeRely; | |||
} | |||
public void setMergeVertical(boolean mergeVertical) { | |||
this.mergeVertical = mergeVertical; | |||
} | |||
public void setNeedMerge(boolean needMerge) { | |||
this.needMerge = needMerge; | |||
} | |||
public void setOrderNum(int orderNum) { | |||
this.orderNum = orderNum; | |||
} | |||
public void setWidth(double width) { | |||
this.width = width; | |||
} | |||
public void setWrap(boolean isWrap) { | |||
this.isWrap = isWrap; | |||
} | |||
public String getSuffix() { | |||
return suffix; | |||
} | |||
public void setSuffix(String suffix) { | |||
this.suffix = suffix; | |||
} | |||
public boolean isStatistics() { | |||
return isStatistics; | |||
} | |||
public void setStatistics(boolean isStatistics) { | |||
this.isStatistics = isStatistics; | |||
} | |||
public String getNumFormat() { | |||
return numFormat; | |||
} | |||
public void setNumFormat(String numFormat) { | |||
this.numFormat = numFormat; | |||
} | |||
public String getEnumExportField() { | |||
return enumExportField; | |||
} | |||
public void setEnumExportField(String enumExportField) { | |||
this.enumExportField = enumExportField; | |||
} | |||
public boolean isColumnHidden() { | |||
return isColumnHidden; | |||
} | |||
public void setColumnHidden(boolean columnHidden) { | |||
isColumnHidden = columnHidden; | |||
} | |||
@Override | |||
public int compareTo(ExcelExportEntity prev) { | |||
return this.getOrderNum() - prev.getOrderNum(); | |||
@@ -1,5 +1,6 @@ | |||
package cn.afterturn.easypoi.excel.entity.params; | |||
import lombok.Data; | |||
import org.apache.poi.ss.usermodel.CellStyle; | |||
import java.io.Serializable; | |||
@@ -11,6 +12,7 @@ import java.util.Stack; | |||
* @author JueYue | |||
* 2015年4月29日 下午9:22:48 | |||
*/ | |||
@Data | |||
public class ExcelForEachParams implements Serializable { | |||
/** | |||
@@ -70,75 +72,4 @@ public class ExcelForEachParams implements Serializable { | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public CellStyle getCellStyle() { | |||
return cellStyle; | |||
} | |||
public void setCellStyle(CellStyle cellStyle) { | |||
this.cellStyle = cellStyle; | |||
} | |||
public short getHeight() { | |||
return height; | |||
} | |||
public void setHeight(short height) { | |||
this.height = height; | |||
} | |||
public String getConstValue() { | |||
return constValue; | |||
} | |||
public void setConstValue(String constValue) { | |||
this.constValue = constValue; | |||
} | |||
public int getColspan() { | |||
return colspan; | |||
} | |||
public void setColspan(int colspan) { | |||
this.colspan = colspan; | |||
} | |||
public int getRowspan() { | |||
return rowspan; | |||
} | |||
public void setRowspan(int rowspan) { | |||
this.rowspan = rowspan; | |||
} | |||
public boolean isNeedSum() { | |||
return needSum; | |||
} | |||
public void setNeedSum(boolean needSum) { | |||
this.needSum = needSum; | |||
} | |||
public Stack<String> getTempName() { | |||
return tempName; | |||
} | |||
public void setTempName(Stack<String> tempName) { | |||
this.tempName = tempName; | |||
} | |||
public boolean isCollectCell() { | |||
return collectCell; | |||
} | |||
public void setCollectCell(boolean collectCell) { | |||
this.collectCell = collectCell; | |||
} | |||
} |
@@ -15,6 +15,8 @@ | |||
*/ | |||
package cn.afterturn.easypoi.excel.entity.params; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
@@ -22,6 +24,7 @@ import java.util.List; | |||
* @author JueYue | |||
* @version 1.0 2013年8月24日 | |||
*/ | |||
@Data | |||
public class ExcelImportEntity extends ExcelBaseEntity { | |||
public final static String IMG_SAVE_PATH = "/excel/upload/img"; | |||
@@ -57,67 +60,4 @@ public class ExcelImportEntity extends ExcelBaseEntity { | |||
private List<ExcelImportEntity> list; | |||
public String getClassType() { | |||
return classType; | |||
} | |||
public String getCollectionName() { | |||
return collectionName; | |||
} | |||
public List<ExcelImportEntity> getList() { | |||
return list; | |||
} | |||
public int getSaveType() { | |||
return saveType; | |||
} | |||
public String getSaveUrl() { | |||
return saveUrl; | |||
} | |||
public void setClassType(String classType) { | |||
this.classType = classType; | |||
} | |||
public void setCollectionName(String collectionName) { | |||
this.collectionName = collectionName; | |||
} | |||
public void setList(List<ExcelImportEntity> list) { | |||
this.list = list; | |||
} | |||
public void setSaveType(int saveType) { | |||
this.saveType = saveType; | |||
} | |||
public void setSaveUrl(String saveUrl) { | |||
this.saveUrl = saveUrl; | |||
} | |||
public String getSuffix() { | |||
return suffix; | |||
} | |||
public void setSuffix(String suffix) { | |||
this.suffix = suffix; | |||
} | |||
public boolean isImportField() { | |||
return importField; | |||
} | |||
public void setImportField(boolean importField) { | |||
this.importField = importField; | |||
} | |||
public String getEnumImportMethod() { | |||
return enumImportMethod; | |||
} | |||
public void setEnumImportMethod(String enumImportMethod) { | |||
this.enumImportMethod = enumImportMethod; | |||
} | |||
} |
@@ -15,6 +15,8 @@ | |||
*/ | |||
package cn.afterturn.easypoi.excel.entity.params; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
@@ -22,6 +24,7 @@ import java.util.List; | |||
* | |||
* Created by jue on 14-6-11. | |||
*/ | |||
@Data | |||
public class MergeEntity { | |||
/** | |||
* 合并开始行 | |||
@@ -50,35 +53,4 @@ public class MergeEntity { | |||
this.startRow = startRow; | |||
} | |||
public int getEndRow() { | |||
return endRow; | |||
} | |||
public List<String> getRelyList() { | |||
return relyList; | |||
} | |||
public int getStartRow() { | |||
return startRow; | |||
} | |||
public String getText() { | |||
return text; | |||
} | |||
public void setEndRow(int endRow) { | |||
this.endRow = endRow; | |||
} | |||
public void setRelyList(List<String> relyList) { | |||
this.relyList = relyList; | |||
} | |||
public void setStartRow(int startRow) { | |||
this.startRow = startRow; | |||
} | |||
public void setText(String text) { | |||
this.text = text; | |||
} | |||
} |
@@ -18,6 +18,7 @@ package cn.afterturn.easypoi.excel.entity.result; | |||
import java.util.List; | |||
import java.util.Map; | |||
import lombok.Data; | |||
import org.apache.poi.ss.usermodel.Workbook; | |||
/** | |||
@@ -26,6 +27,7 @@ import org.apache.poi.ss.usermodel.Workbook; | |||
* @author JueYue | |||
* 2014年6月29日 下午5:12:10 | |||
*/ | |||
@Data | |||
public class ExcelImportResult<T> { | |||
/** | |||
@@ -63,51 +65,4 @@ public class ExcelImportResult<T> { | |||
this.workbook = workbook; | |||
} | |||
public List<T> getList() { | |||
return list; | |||
} | |||
public Workbook getWorkbook() { | |||
return workbook; | |||
} | |||
public boolean isVerfiyFail() { | |||
return verfiyFail; | |||
} | |||
public void setList(List<T> list) { | |||
this.list = list; | |||
} | |||
public void setVerfiyFail(boolean verfiyFail) { | |||
this.verfiyFail = verfiyFail; | |||
} | |||
public void setWorkbook(Workbook workbook) { | |||
this.workbook = workbook; | |||
} | |||
public Map<String, Object> getMap() { | |||
return map; | |||
} | |||
public void setMap(Map<String, Object> map) { | |||
this.map = map; | |||
} | |||
public Workbook getFailWorkbook() { | |||
return failWorkbook; | |||
} | |||
public void setFailWorkbook(Workbook failWorkbook) { | |||
this.failWorkbook = failWorkbook; | |||
} | |||
public List<T> getFailList() { | |||
return failList; | |||
} | |||
public void setFailList(List<T> failList) { | |||
this.failList = failList; | |||
} | |||
} |
@@ -15,12 +15,15 @@ | |||
*/ | |||
package cn.afterturn.easypoi.excel.entity.result; | |||
import lombok.Data; | |||
/** | |||
* Excel导入处理返回结果 | |||
* | |||
* @author JueYue | |||
* 2014年6月23日 下午11:03:29 | |||
*/ | |||
@Data | |||
public class ExcelVerifyHandlerResult { | |||
/** | |||
* 是否正确 | |||
@@ -44,20 +47,4 @@ public class ExcelVerifyHandlerResult { | |||
this.msg = msg; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public boolean isSuccess() { | |||
return success; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
public void setSuccess(boolean success) { | |||
this.success = success; | |||
} | |||
} |
@@ -9,6 +9,10 @@ public interface SaxConstant { | |||
* Row 表达式 | |||
*/ | |||
public static String ROW = "row"; | |||
/** | |||
* cell 的位置 | |||
*/ | |||
public static String ROW_COL = "r"; | |||
/** | |||
* cell 表达式 | |||
*/ | |||
@@ -16,12 +16,14 @@ | |||
package cn.afterturn.easypoi.excel.entity.sax; | |||
import cn.afterturn.easypoi.excel.entity.enmus.CellValueType; | |||
import lombok.Data; | |||
/** | |||
* Cell 对象 | |||
* @author JueYue | |||
* 2014年12月29日 下午10:12:57 | |||
*/ | |||
@Data | |||
public class SaxReadCellEntity { | |||
/** | |||
* 值类型 | |||
@@ -37,22 +39,6 @@ public class SaxReadCellEntity { | |||
this.value = value; | |||
} | |||
public CellValueType getCellType() { | |||
return cellType; | |||
} | |||
public void setCellType(CellValueType cellType) { | |||
this.cellType = cellType; | |||
} | |||
public Object getValue() { | |||
return value; | |||
} | |||
public void setValue(Object value) { | |||
this.value = value; | |||
} | |||
@Override | |||
public String toString() { | |||
return "[type=" + cellType.toString() + ",value=" + value + "]"; | |||
@@ -66,13 +66,13 @@ public class ExcelExportService extends BaseExportService { | |||
List<ExcelExportEntity> excelParams, int cellIndex) { | |||
Row row = sheet.getRow(index) == null ? sheet.createRow(index) : sheet.getRow(index); | |||
int rows = getRowNums(excelParams, true); | |||
row.setHeight(title.getHeaderHeight()); | |||
row.setHeight((short)title.getHeaderHeight()); | |||
Row listRow = null; | |||
if (rows >= 2) { | |||
listRow = sheet.getRow(index + 1); | |||
if (listRow == null) { | |||
listRow = sheet.createRow(index + 1); | |||
listRow.setHeight(title.getHeaderHeight()); | |||
listRow.setHeight((short)(short)title.getHeaderHeight()); | |||
} | |||
} | |||
@@ -21,7 +21,6 @@ import cn.afterturn.easypoi.excel.entity.vo.PoiBaseConstants; | |||
import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler; | |||
import cn.afterturn.easypoi.exception.excel.ExcelExportException; | |||
import cn.afterturn.easypoi.exception.excel.enums.ExcelExportEnum; | |||
import cn.afterturn.easypoi.handler.inter.IExcelExportServer; | |||
import cn.afterturn.easypoi.util.PoiExcelGraphDataUtil; | |||
import cn.afterturn.easypoi.util.PoiMergeCellUtil; | |||
import cn.afterturn.easypoi.util.PoiPublicUtil; | |||
@@ -69,15 +68,16 @@ public abstract class BaseExportService extends ExportCommonService { | |||
int maxHeight = 1, listMaxHeight = 1; | |||
// 合并需要合并的单元格 | |||
int margeCellNum = cellNum; | |||
int indexKey = 0; | |||
if (excelParams != null && !excelParams.isEmpty()){ | |||
int indexKey = 0; | |||
if (excelParams != null && !excelParams.isEmpty()) { | |||
indexKey = createIndexCell(row, index, excelParams.get(0)); | |||
} | |||
cellNum += indexKey; | |||
for (int k = indexKey, paramSize = excelParams.size(); k < paramSize; k++) { | |||
entity = excelParams.get(k); | |||
//不论数据是否为空都应该把该列的数据跳过去 | |||
if (entity.getList() != null) { | |||
Collection<?> list = getListCellValue(entity, t); | |||
Collection<?> list = getListCellValue(entity, t); | |||
int tmpListHeight = 0; | |||
if (list != null && list.size() > 0) { | |||
int tempCellNum = 0; | |||
@@ -88,6 +88,8 @@ public abstract class BaseExportService extends ExportCommonService { | |||
} | |||
cellNum = tempCellNum; | |||
listMaxHeight = Math.max(listMaxHeight, tmpListHeight); | |||
} else { | |||
cellNum = cellNum + getListCellSize(entity.getList()); | |||
} | |||
} else { | |||
Object value = getCellValue(entity, t); | |||
@@ -123,7 +125,7 @@ public abstract class BaseExportService extends ExportCommonService { | |||
margeCellNum += entity.getList().size(); | |||
} else if (entity.isNeedMerge() && maxHeight > 1) { | |||
for (int i = index + 1; i < index + maxHeight; i++) { | |||
if(sheet.getRow(i) == null ) { | |||
if (sheet.getRow(i) == null) { | |||
sheet.createRow(i); | |||
} | |||
sheet.getRow(i).createCell(margeCellNum); | |||
@@ -142,6 +144,24 @@ public abstract class BaseExportService extends ExportCommonService { | |||
} | |||
/** | |||
* 获取集合的宽度 | |||
* | |||
* @param list | |||
* @return | |||
*/ | |||
protected int getListCellSize(List<ExcelExportEntity> list) { | |||
int cellSize = 0; | |||
for (ExcelExportEntity ee : list) { | |||
if (ee.getList() != null) { | |||
cellSize += getListCellSize(ee.getList()); | |||
} else { | |||
cellSize++; | |||
} | |||
} | |||
return cellSize; | |||
} | |||
/** | |||
* 图片类型的Cell | |||
*/ | |||
@@ -26,7 +26,6 @@ import cn.afterturn.easypoi.exception.excel.enums.ExcelExportEnum; | |||
import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
import cn.afterturn.easypoi.handler.inter.IExcelDictHandler; | |||
import cn.afterturn.easypoi.handler.inter.IExcelI18nHandler; | |||
import cn.afterturn.easypoi.util.PoiElUtil; | |||
import cn.afterturn.easypoi.util.PoiPublicUtil; | |||
import cn.afterturn.easypoi.util.PoiReflectorUtil; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -40,10 +39,7 @@ import java.lang.reflect.Method; | |||
import java.lang.reflect.ParameterizedType; | |||
import java.text.DecimalFormat; | |||
import java.text.SimpleDateFormat; | |||
import java.time.Instant; | |||
import java.time.LocalDate; | |||
import java.time.LocalDateTime; | |||
import java.time.ZoneId; | |||
import java.time.*; | |||
import java.util.*; | |||
/** | |||
@@ -68,7 +64,7 @@ public class ExportCommonService { | |||
private ExcelExportEntity createExcelExportEntity(Field field, String targetId, | |||
Class<?> pojoClass, | |||
List<Method> getMethods, ExcelEntity excelGroup) throws Exception { | |||
Excel excel = field.getAnnotation(Excel.class); | |||
Excel excel = field.getAnnotation(Excel.class); | |||
ExcelExportEntity excelEntity = new ExcelExportEntity(); | |||
excelEntity.setType(excel.type()); | |||
getExcelField(targetId, field, excelEntity, excel, pojoClass, excelGroup); | |||
@@ -89,15 +85,21 @@ public class ExportCommonService { | |||
} else if (value instanceof Date) { | |||
temp = (Date) value; | |||
} else if (value instanceof Instant) { | |||
Instant instant = (Instant)value; | |||
Instant instant = (Instant) value; | |||
temp = Date.from(instant); | |||
} else if (value instanceof LocalDate) { | |||
LocalDate localDate = (LocalDate)value; | |||
} else if (value instanceof LocalDate) { | |||
LocalDate localDate = (LocalDate) value; | |||
temp = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); | |||
} else if(value instanceof LocalDateTime){ | |||
LocalDateTime localDateTime = (LocalDateTime)value; | |||
} else if (value instanceof LocalDateTime) { | |||
LocalDateTime localDateTime = (LocalDateTime) value; | |||
temp = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); | |||
} else if(value instanceof java.sql.Date) { | |||
} else if (value instanceof ZonedDateTime) { | |||
ZonedDateTime zonedDateTime = (ZonedDateTime) value; | |||
temp = Date.from(zonedDateTime.toInstant()); | |||
} else if (value instanceof OffsetDateTime) { | |||
OffsetDateTime offsetDateTime = (OffsetDateTime) value; | |||
temp = Date.from(offsetDateTime.toInstant()); | |||
} else if (value instanceof java.sql.Date) { | |||
temp = new Date(((java.sql.Date) value).getTime()); | |||
} else if (value instanceof java.sql.Time) { | |||
temp = new Date(((java.sql.Time) value).getTime()); | |||
@@ -106,7 +108,7 @@ public class ExportCommonService { | |||
} | |||
if (temp != null) { | |||
SimpleDateFormat format = new SimpleDateFormat(entity.getFormat()); | |||
if(StringUtils.isNotEmpty(entity.getTimezone())){ | |||
if (StringUtils.isNotEmpty(entity.getTimezone())) { | |||
format.setTimeZone(TimeZone.getTimeZone(entity.getTimezone())); | |||
} | |||
value = format.format(temp); | |||
@@ -123,7 +125,7 @@ public class ExportCommonService { | |||
LOGGER.error("data want num format ,but is not num, value is:" + value); | |||
return null; | |||
} | |||
Double d = Double.parseDouble(value.toString()); | |||
Double d = Double.parseDouble(value.toString()); | |||
DecimalFormat df = new DecimalFormat(entity.getNumFormat()); | |||
return df.format(d); | |||
} | |||
@@ -136,7 +138,7 @@ public class ExportCommonService { | |||
public void getAllExcelField(String[] exclusions, String targetId, Field[] fields, | |||
List<ExcelExportEntity> excelParams, Class<?> pojoClass, | |||
List<Method> getMethods, ExcelEntity excelGroup) throws Exception { | |||
List<String> exclusionsList = exclusions != null ? Arrays.asList(exclusions) : null; | |||
List<String> exclusionsList = exclusions != null ? Arrays.asList(exclusions) : null; | |||
ExcelExportEntity excelEntity; | |||
// 遍历整个filed | |||
for (int i = 0; i < fields.length; i++) { | |||
@@ -147,16 +149,16 @@ public class ExportCommonService { | |||
} | |||
// 首先判断Excel 可能一下特殊数据用户回自定义处理 | |||
if (field.getAnnotation(Excel.class) != null) { | |||
Excel excel = field.getAnnotation(Excel.class); | |||
String name = PoiPublicUtil.getValueByTargetId(excel.name(), targetId, null); | |||
Excel excel = field.getAnnotation(Excel.class); | |||
String name = PoiPublicUtil.getValueByTargetId(excel.name(), targetId, null); | |||
if (StringUtils.isNotBlank(name)) { | |||
excelParams.add(createExcelExportEntity(field, targetId, pojoClass, getMethods, excelGroup)); | |||
} | |||
} else if (PoiPublicUtil.isCollection(field.getType())) { | |||
ExcelCollection excel = field.getAnnotation(ExcelCollection.class); | |||
ParameterizedType pt = (ParameterizedType) field.getGenericType(); | |||
Class<?> clz = (Class<?>) pt.getActualTypeArguments()[0]; | |||
List<ExcelExportEntity> list = new ArrayList<ExcelExportEntity>(); | |||
ExcelCollection excel = field.getAnnotation(ExcelCollection.class); | |||
ParameterizedType pt = (ParameterizedType) field.getGenericType(); | |||
Class<?> clz = (Class<?>) pt.getActualTypeArguments()[0]; | |||
List<ExcelExportEntity> list = new ArrayList<ExcelExportEntity>(); | |||
getAllExcelField(exclusions, | |||
StringUtils.isNotEmpty(excel.id()) ? excel.id() : targetId, | |||
PoiPublicUtil.getClassFields(clz), list, clz, null, null); | |||
@@ -199,8 +201,8 @@ public class ExportCommonService { | |||
value = ((Map<?, ?>) obj).get(entity.getKey()); | |||
} else { | |||
// 考虑直接用对象导出只能每次获取值的办法 | |||
if(entity.getMethods() == null && entity.getMethod() == null){ | |||
value = PoiPublicUtil.getParamsValue(entity.getKey().toString(),obj); | |||
if (entity.getMethods() == null && entity.getMethod() == null) { | |||
value = PoiPublicUtil.getParamsValue(entity.getKey().toString(), obj); | |||
} else { | |||
value = entity.getMethods() != null ? getFieldBySomeMethod(entity.getMethods(), obj) | |||
: entity.getMethod().invoke(obj, new Object[]{}); | |||
@@ -353,8 +355,8 @@ public class ExportCommonService { | |||
Map.Entry<String, List<ExcelExportEntity>> entry = (Map.Entry) it.next(); | |||
Collections.sort(entry.getValue()); | |||
// 插入到excelParams当中 | |||
boolean isInsert = false; | |||
String groupName = "START"; | |||
boolean isInsert = false; | |||
String groupName = "START"; | |||
for (int i = 0; i < excelParams.size(); i++) { | |||
// 跳过groupName 的元素,防止破会内部结构 | |||
if (excelParams.get(i).getOrderNum() > entry.getValue().get(0).getOrderNum() | |||
@@ -410,11 +412,11 @@ public class ExportCommonService { | |||
/** | |||
* 判断表头是只有一行还是多行 | |||
*/ | |||
public int getRowNums(List<ExcelExportEntity> excelParams,boolean isDeep) { | |||
public int getRowNums(List<ExcelExportEntity> excelParams, boolean isDeep) { | |||
for (int i = 0; i < excelParams.size(); i++) { | |||
if (excelParams.get(i).getList() != null | |||
&& StringUtils.isNotBlank(excelParams.get(i).getName())) { | |||
return isDeep? 1 + getRowNums(excelParams.get(i).getList() , isDeep) : 2; | |||
return isDeep ? 1 + getRowNums(excelParams.get(i).getList(), isDeep) : 2; | |||
} | |||
if (StringUtils.isNotEmpty(excelParams.get(i).getGroupName())) { | |||
return 2; | |||
@@ -99,7 +99,11 @@ public class CellValueService { | |||
result = ((Date) result).toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); | |||
} else if (("class java.time.LocalDateTime").equals(classFullName)) { | |||
result = ((Date) result).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); | |||
} else if (("class java.sql.Date").equals(classFullName)) { | |||
} else if (("class java.time.OffsetDateTime").equals(classFullName)) { | |||
result = ((Date) result).toInstant().atZone(ZoneId.systemDefault()).toOffsetDateTime(); | |||
} else if (("class java.time.ZonedDateTime").equals(classFullName)) { | |||
result = ((Date) result).toInstant().atZone(ZoneId.systemDefault()); | |||
} else if (("class java.sql.Date").equals(classFullName)) { | |||
result = new java.sql.Date(((Date) result).getTime()); | |||
} else if (("class java.sql.Time").equals(classFullName)) { | |||
result = new Time(((Date) result).getTime()); | |||
@@ -45,12 +45,17 @@ public class SheetHandler extends DefaultHandler { | |||
private StylesTable stylesTable; | |||
private String lastContents; | |||
/** 当前行**/ | |||
/** | |||
* 当前行 | |||
**/ | |||
private int curRow = 0; | |||
/**当前列 **/ | |||
/** | |||
* 当前列 | |||
**/ | |||
private int curCol = 0; | |||
private CellValueType type; | |||
private String currentLocation, prevLocation; | |||
private ISaxRowRead read; | |||
@@ -69,6 +74,8 @@ public class SheetHandler extends DefaultHandler { | |||
lastContents = ""; | |||
if (COL.equals(name)) { | |||
String cellType = attributes.getValue(TYPE); | |||
prevLocation = currentLocation; | |||
currentLocation = attributes.getValue(ROW_COL); | |||
if (STRING.equals(cellType)) { | |||
type = CellValueType.String; | |||
return; | |||
@@ -128,7 +135,10 @@ public class SheetHandler extends DefaultHandler { | |||
} catch (Exception e) { | |||
} | |||
} | |||
//t元素也包含字符串 | |||
if (VALUE.equals(name) && StringUtils.isNotEmpty(prevLocation)) { | |||
addNullCell(prevLocation, currentLocation); | |||
} | |||
//t元素也包含字符串 | |||
if (CellValueType.TElement.equals(type)) { | |||
String value = lastContents.trim(); | |||
rowList.add(curCol, new SaxReadCellEntity(CellValueType.String, value)); | |||
@@ -162,6 +172,50 @@ public class SheetHandler extends DefaultHandler { | |||
} | |||
private void addNullCell(String prevLocation, String currentLocation) { | |||
// 拆分行和列 | |||
String[] prev = getRowCell(prevLocation); | |||
String[] current = getRowCell(currentLocation); | |||
if (prev[1].equalsIgnoreCase(current[1])) { | |||
int prevCell = getCellNum(prev[0]) + 1; | |||
int currentCell = getCellNum(current[0]); | |||
for (int i = prevCell; i < currentCell; i++) { | |||
rowList.add(curCol, new SaxReadCellEntity(CellValueType.String, "")); | |||
curCol++; | |||
} | |||
} | |||
} | |||
private int getCellNum(String cell) { | |||
if (StringUtils.isEmpty(cell)) { | |||
return 0; | |||
} | |||
char[] chars = cell.toUpperCase().toCharArray(); | |||
int n = 0; | |||
for (int i = cell.length() - 1, j = 1; i >= 0; i--, j *= 26) { | |||
char c = (chars[i]); | |||
if (c < 'A' || c > 'Z') { | |||
return 0; | |||
} | |||
n += ((int) c - 64) * j; | |||
} | |||
return n; | |||
} | |||
private String[] getRowCell(String prevLocation) { | |||
StringBuilder row = new StringBuilder(); | |||
StringBuilder cell = new StringBuilder(); | |||
char[] chars = prevLocation.toCharArray(); | |||
for (int i = 0; i < chars.length; i++) { | |||
if (chars[i] >= '0' && chars[i] <= '9') { | |||
cell.append(chars[i]); | |||
} else { | |||
row.append(chars[i]); | |||
} | |||
} | |||
return new String[]{row.toString(), cell.toString()}; | |||
} | |||
@Override | |||
public void characters(char[] ch, int start, int length) throws SAXException { | |||
//得到单元格内容的值 | |||
@@ -204,6 +204,13 @@ | |||
<version>3.2.6</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.projectlombok</groupId> | |||
<artifactId>lombok</artifactId> | |||
<version>1.16.20</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<!-- 模块版本 --> | |||
<dependency> | |||
<groupId>cn.afterturn</groupId> | |||