Browse Source

修改导入导出分开celldata

pull/2074/head
Jiaju Zhuang 4 years ago
parent
commit
74562ee5c9
  1. 139
      src/main/java/com/alibaba/excel/EasyExcelFactory.java
  2. 181
      src/main/java/com/alibaba/excel/ExcelReader.java
  3. 238
      src/main/java/com/alibaba/excel/ExcelWriter.java
  4. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/BlankRecordHandler.java
  5. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/BoolErrRecordHandler.java
  6. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/DummyRecordHandler.java
  7. 26
      src/main/java/com/alibaba/excel/analysis/v03/handlers/FormulaRecordHandler.java
  8. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/LabelRecordHandler.java
  9. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/LabelSstRecordHandler.java
  10. 12
      src/main/java/com/alibaba/excel/analysis/v03/handlers/NumberRecordHandler.java
  11. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/RkRecordHandler.java
  12. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/StringRecordHandler.java
  13. 2
      src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractCellValueTagHandler.java
  14. 10
      src/main/java/com/alibaba/excel/analysis/v07/handlers/CellFormulaTagHandler.java
  15. 6
      src/main/java/com/alibaba/excel/analysis/v07/handlers/CellInlineStringValueTagHandler.java
  16. 11
      src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java
  17. 2
      src/main/java/com/alibaba/excel/analysis/v07/handlers/CellValueTagHandler.java
  18. 10
      src/main/java/com/alibaba/excel/context/AnalysisContext.java
  19. 26
      src/main/java/com/alibaba/excel/context/AnalysisContextImpl.java
  20. 2
      src/main/java/com/alibaba/excel/context/WriteContextImpl.java
  21. 27
      src/main/java/com/alibaba/excel/converters/AutoConverter.java
  22. 31
      src/main/java/com/alibaba/excel/converters/Converter.java
  23. 30
      src/main/java/com/alibaba/excel/converters/ReadConverterContext.java
  24. 31
      src/main/java/com/alibaba/excel/converters/WriteConverterContext.java
  25. 11
      src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalBooleanConverter.java
  26. 7
      src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalNumberConverter.java
  27. 7
      src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalStringConverter.java
  28. 9
      src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanBooleanConverter.java
  29. 11
      src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanNumberConverter.java
  30. 9
      src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanStringConverter.java
  31. 26
      src/main/java/com/alibaba/excel/converters/bytearray/BoxingByteArrayImageConverter.java
  32. 28
      src/main/java/com/alibaba/excel/converters/bytearray/ByteArrayImageConverter.java
  33. 11
      src/main/java/com/alibaba/excel/converters/byteconverter/ByteBooleanConverter.java
  34. 14
      src/main/java/com/alibaba/excel/converters/byteconverter/ByteNumberConverter.java
  35. 7
      src/main/java/com/alibaba/excel/converters/byteconverter/ByteStringConverter.java
  36. 24
      src/main/java/com/alibaba/excel/converters/date/DateDateConverter.java
  37. 15
      src/main/java/com/alibaba/excel/converters/date/DateNumberConverter.java
  38. 11
      src/main/java/com/alibaba/excel/converters/date/DateStringConverter.java
  39. 11
      src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleBooleanConverter.java
  40. 14
      src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleNumberConverter.java
  41. 7
      src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleStringConverter.java
  42. 25
      src/main/java/com/alibaba/excel/converters/file/FileImageConverter.java
  43. 11
      src/main/java/com/alibaba/excel/converters/floatconverter/FloatBooleanConverter.java
  44. 12
      src/main/java/com/alibaba/excel/converters/floatconverter/FloatNumberConverter.java
  45. 7
      src/main/java/com/alibaba/excel/converters/floatconverter/FloatStringConverter.java
  46. 26
      src/main/java/com/alibaba/excel/converters/inputstream/InputStreamImageConverter.java
  47. 11
      src/main/java/com/alibaba/excel/converters/integer/IntegerBooleanConverter.java
  48. 12
      src/main/java/com/alibaba/excel/converters/integer/IntegerNumberConverter.java
  49. 7
      src/main/java/com/alibaba/excel/converters/integer/IntegerStringConverter.java
  50. 11
      src/main/java/com/alibaba/excel/converters/longconverter/LongBooleanConverter.java
  51. 12
      src/main/java/com/alibaba/excel/converters/longconverter/LongNumberConverter.java
  52. 7
      src/main/java/com/alibaba/excel/converters/longconverter/LongStringConverter.java
  53. 11
      src/main/java/com/alibaba/excel/converters/shortconverter/ShortBooleanConverter.java
  54. 14
      src/main/java/com/alibaba/excel/converters/shortconverter/ShortNumberConverter.java
  55. 7
      src/main/java/com/alibaba/excel/converters/shortconverter/ShortStringConverter.java
  56. 9
      src/main/java/com/alibaba/excel/converters/string/StringBooleanConverter.java
  57. 9
      src/main/java/com/alibaba/excel/converters/string/StringErrorConverter.java
  58. 26
      src/main/java/com/alibaba/excel/converters/string/StringImageConverter.java
  59. 22
      src/main/java/com/alibaba/excel/converters/string/StringNumberConverter.java
  60. 9
      src/main/java/com/alibaba/excel/converters/string/StringStringConverter.java
  61. 20
      src/main/java/com/alibaba/excel/converters/url/UrlImageConverter.java
  62. 4
      src/main/java/com/alibaba/excel/enums/CellDataTypeEnum.java
  63. 8
      src/main/java/com/alibaba/excel/event/AbstractIgnoreExceptionReadListener.java
  64. 4
      src/main/java/com/alibaba/excel/event/AnalysisEventListener.java
  65. 38
      src/main/java/com/alibaba/excel/event/WriteHandler.java
  66. 4
      src/main/java/com/alibaba/excel/exception/ExcelDataConvertException.java
  67. 40
      src/main/java/com/alibaba/excel/metadata/BaseRowModel.java
  68. 63
      src/main/java/com/alibaba/excel/metadata/BasicParameter.java
  69. 193
      src/main/java/com/alibaba/excel/metadata/CellData.java
  70. 10
      src/main/java/com/alibaba/excel/metadata/HyperlinkData.java
  71. 13
      src/main/java/com/alibaba/excel/metadata/ReadCellData.java
  72. 162
      src/main/java/com/alibaba/excel/metadata/Sheet.java
  73. 62
      src/main/java/com/alibaba/excel/metadata/Table.java
  74. 65
      src/main/java/com/alibaba/excel/metadata/TableStyle.java
  75. 42
      src/main/java/com/alibaba/excel/metadata/WriteCellData.java
  76. 76
      src/main/java/com/alibaba/excel/metadata/data/CellData.java
  77. 40
      src/main/java/com/alibaba/excel/metadata/data/ClientAnchorData.java
  78. 4
      src/main/java/com/alibaba/excel/metadata/data/CommentData.java
  79. 28
      src/main/java/com/alibaba/excel/metadata/data/CoordinateData.java
  80. 5
      src/main/java/com/alibaba/excel/metadata/data/DataFormatData.java
  81. 2
      src/main/java/com/alibaba/excel/metadata/data/FormulaData.java
  82. 53
      src/main/java/com/alibaba/excel/metadata/data/HyperlinkData.java
  83. 2
      src/main/java/com/alibaba/excel/metadata/data/ImageData.java
  84. 111
      src/main/java/com/alibaba/excel/metadata/data/ReadCellData.java
  85. 2
      src/main/java/com/alibaba/excel/metadata/data/RichTextStringData.java
  86. 101
      src/main/java/com/alibaba/excel/metadata/data/WriteCellData.java
  87. 58
      src/main/java/com/alibaba/excel/parameter/AnalysisParam.java
  88. 71
      src/main/java/com/alibaba/excel/parameter/GenerateParam.java
  89. 38
      src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java
  90. 24
      src/main/java/com/alibaba/excel/read/listener/ReadListener.java
  91. 21
      src/main/java/com/alibaba/excel/read/metadata/ReadBasicParameter.java
  92. 4
      src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
  93. 2
      src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java
  94. 90
      src/main/java/com/alibaba/excel/read/metadata/holder/ReadSheetHolder.java
  95. 2
      src/main/java/com/alibaba/excel/read/processor/DefaultAnalysisEventProcessor.java
  96. 3
      src/main/java/com/alibaba/excel/util/ClassUtils.java
  97. 40
      src/main/java/com/alibaba/excel/util/ConverterUtils.java
  98. 46
      src/main/java/com/alibaba/excel/util/FileTypeUtils.java
  99. 36
      src/main/java/com/alibaba/excel/util/MapUtils.java
  100. 16
      src/main/java/com/alibaba/excel/util/NumberUtils.java
  101. Some files were not shown because too many files have changed in this diff Show More

139
src/main/java/com/alibaba/excel/EasyExcelFactory.java

@ -3,17 +3,10 @@ package com.alibaba.excel;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.event.WriteHandler;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.builder.ExcelWriterTableBuilder;
@ -39,138 +32,6 @@ import com.alibaba.excel.write.builder.ExcelWriterTableBuilder;
*/
public class EasyExcelFactory {
/**
* Quickly read small filesno more than 10,000 lines.
*
* @param in
* the POI filesystem that contains the Workbook stream.
* @param sheet
* read sheet.
* @return analysis result.
* @deprecated please use 'EasyExcel.read(in).sheet(sheetNo).doReadSync();'
*/
@Deprecated
public static List<Object> read(InputStream in, Sheet sheet) {
final List<Object> rows = new ArrayList<Object>();
new ExcelReader(in, null, new AnalysisEventListener<Object>() {
@Override
public void invoke(Object object, AnalysisContext context) {
rows.add(object);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {}
}, false).read(sheet);
return rows;
}
/**
* Parsing large file
*
* @param in
* the POI filesystem that contains the Workbook stream.
* @param sheet
* read sheet.
* @param listener
* Callback method after each row is parsed.
* @deprecated please use 'EasyExcel.read(in,head,listener).sheet(sheetNo).doRead();'
*/
@Deprecated
public static void readBySax(InputStream in, Sheet sheet, AnalysisEventListener listener) {
new ExcelReader(in, null, listener).read(sheet);
}
/**
* Get ExcelReader.
*
* @param in
* the POI filesystem that contains the Workbook stream.
* @param listener
* Callback method after each row is parsed.
* @return ExcelReader.
* @deprecated please use {@link EasyExcel#read()} build 'ExcelReader'
*/
@Deprecated
public static ExcelReader getReader(InputStream in, AnalysisEventListener listener) {
return new ExcelReader(in, null, listener);
}
/**
* Get ExcelWriter
*
* @param outputStream
* the java OutputStream you wish to write the value to.
* @return new ExcelWriter.
* @deprecated please use {@link EasyExcel#write()}
*/
@Deprecated
public static ExcelWriter getWriter(OutputStream outputStream) {
return write().file(outputStream).autoCloseStream(Boolean.FALSE).convertAllFiled(Boolean.FALSE).build();
}
/**
* Get ExcelWriter
*
* @param outputStream
* the java OutputStream you wish to write the value to.
* @param typeEnum
* 03 or 07
* @param needHead
* Do you need to write the header to the file?
* @return new ExcelWriter
* @deprecated please use {@link EasyExcel#write()}
*/
@Deprecated
public static ExcelWriter getWriter(OutputStream outputStream, ExcelTypeEnum typeEnum, boolean needHead) {
return write().file(outputStream).excelType(typeEnum).needHead(needHead).autoCloseStream(Boolean.FALSE)
.convertAllFiled(Boolean.FALSE).build();
}
/**
* Get ExcelWriter with a template file
*
* @param temp
* Append value after a POI file , Can be nullthe template POI filesystem that contains the Workbook
* stream)
* @param outputStream
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
* @param needHead
* Whether a write header is required
* @return new ExcelWriter
* @deprecated please use {@link EasyExcel#write()}
*/
@Deprecated
public static ExcelWriter getWriterWithTemp(InputStream temp, OutputStream outputStream, ExcelTypeEnum typeEnum,
boolean needHead) {
return write().withTemplate(temp).file(outputStream).excelType(typeEnum).needHead(needHead)
.autoCloseStream(Boolean.FALSE).convertAllFiled(Boolean.FALSE).build();
}
/**
* Get ExcelWriter with a template file
*
* @param temp
* Append value after a POI file , Can be nullthe template POI filesystem that contains the Workbook
* stream)
* @param outputStream
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
* @param needHead
* Whether a write header is required
* @param handler
* User-defined callback
* @return new ExcelWriter
* @deprecated please use {@link EasyExcel#write()}
*/
@Deprecated
public static ExcelWriter getWriterWithTempAndHandler(InputStream temp, OutputStream outputStream,
ExcelTypeEnum typeEnum, boolean needHead, WriteHandler handler) {
return write().withTemplate(temp).file(outputStream).excelType(typeEnum).needHead(needHead)
.registerWriteHandler(handler).autoCloseStream(Boolean.FALSE).convertAllFiled(Boolean.FALSE).build();
}
/**
* Build excel the write

181
src/main/java/com/alibaba/excel/ExcelReader.java

@ -1,25 +1,17 @@
package com.alibaba.excel;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.excel.analysis.ExcelAnalyser;
import com.alibaba.excel.analysis.ExcelAnalyserImpl;
import com.alibaba.excel.analysis.ExcelReadExecutor;
import com.alibaba.excel.cache.MapCache;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.excel.parameter.AnalysisParam;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.read.metadata.ReadWorkbook;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Excel readers are all read in event mode.
@ -34,113 +26,6 @@ public class ExcelReader {
*/
private ExcelAnalyser excelAnalyser;
/**
* Create new reader
*
* @param in
* the POI filesystem that contains the Workbook stream
* @param excelTypeEnum
* 03 or 07
* @param customContent
* {@link AnalysisEventListener#invoke(Object, AnalysisContext) }AnalysisContext
* @param eventListener
* Callback method after each row is parsed.
* @deprecated please use {@link EasyExcelFactory#read()} build 'ExcelReader'
*/
@Deprecated
public ExcelReader(InputStream in, ExcelTypeEnum excelTypeEnum, Object customContent,
AnalysisEventListener eventListener) {
this(in, excelTypeEnum, customContent, eventListener, true);
}
/**
* Create new reader
*
* @param in
* the POI filesystem that contains the Workbook stream
* @param customContent
* {@link AnalysisEventListener#invoke(Object, AnalysisContext) }AnalysisContext
* @param eventListener
* Callback method after each row is parsed
* @deprecated please use {@link EasyExcelFactory#read()} build 'ExcelReader'
*/
@Deprecated
public ExcelReader(InputStream in, Object customContent, AnalysisEventListener eventListener) {
this(in, customContent, eventListener, true);
}
/**
* Create new reader
*
* @param param
* old param Deprecated
* @param eventListener
* Callback method after each row is parsed.
* @deprecated please use {@link EasyExcelFactory#read()} build 'ExcelReader'
*/
@Deprecated
public ExcelReader(AnalysisParam param, AnalysisEventListener eventListener) {
this(param.getIn(), param.getExcelTypeEnum(), param.getCustomContent(), eventListener, true);
}
/**
* Create new reader
*
* @param in
* @param customContent
* {@link AnalysisEventListener#invoke(Object, AnalysisContext) }AnalysisContext
* @param eventListener
* @param trim
* The content of the form is empty and needs to be empty. The purpose is to be fault-tolerant, because
* there are often table contents with spaces that can not be converted into custom types. For example:
* '1234 ' contain a space cannot be converted to int.
* @deprecated please use {@link EasyExcelFactory#read()} build 'ExcelReader'
*/
@Deprecated
public ExcelReader(InputStream in, Object customContent, AnalysisEventListener eventListener, boolean trim) {
this(in, null, customContent, eventListener, trim);
}
/**
* Create new reader
*
* @param in
* the POI filesystem that contains the Workbook stream
* @param excelTypeEnum
* 03 or 07
* @param customContent
* {@link AnalysisEventListener#invoke(Object, AnalysisContext) }AnalysisContext
* @param eventListener
* Callback method after each row is parsed.
* @param trim
* The content of the form is empty and needs to be empty. The purpose is to be fault-tolerant, because
* there are often table contents with spaces that can not be converted into custom types. For example:
* '1234 ' contain a space cannot be converted to int.
* @deprecated please use {@link EasyExcelFactory#read()} build 'ExcelReader'
*/
@Deprecated
public ExcelReader(InputStream in, ExcelTypeEnum excelTypeEnum, Object customContent,
AnalysisEventListener eventListener, boolean trim) {
ReadWorkbook readWorkbook = new ReadWorkbook();
readWorkbook.setInputStream(in);
readWorkbook.setExcelType(excelTypeEnum);
readWorkbook.setCustomObject(customContent);
if (eventListener != null) {
List<ReadListener> customReadListenerList = new ArrayList<ReadListener>();
customReadListenerList.add(eventListener);
readWorkbook.setCustomReadListenerList(customReadListenerList);
}
readWorkbook.setAutoTrim(trim);
readWorkbook.setAutoCloseStream(Boolean.FALSE);
readWorkbook.setMandatoryUseInputStream(Boolean.TRUE);
readWorkbook.setReadCache(new MapCache());
readWorkbook.setConvertAllFiled(Boolean.FALSE);
readWorkbook.setDefaultReturnMap(Boolean.FALSE);
// The previous logic was that Article 0 started reading
readWorkbook.setHeadRowNumber(0);
excelAnalyser = new ExcelAnalyserImpl(readWorkbook);
}
public ExcelReader(ReadWorkbook readWorkbook) {
excelAnalyser = new ExcelAnalyserImpl(readWorkbook);
}
@ -183,44 +68,6 @@ public class ExcelReader {
return this;
}
/**
* Parse the specified sheetSheetNo start from 1
*
* @param sheet
* Read sheet
* @deprecated please us {@link #read(ReadSheet...)}
*/
@Deprecated
public void read(Sheet sheet) {
ReadSheet readSheet = null;
if (sheet != null) {
readSheet = new ReadSheet();
readSheet.setSheetNo(sheet.getSheetNo() - 1);
readSheet.setSheetName(sheet.getSheetName());
readSheet.setClazz(sheet.getClazz());
readSheet.setHead(sheet.getHead());
readSheet.setHeadRowNumber(sheet.getHeadLineMun());
}
read(readSheet);
}
/**
* Parse the specified sheet
*
* @param sheet
* Read sheet
* @param clazz
* object parsed into each row of value
*
* @deprecated Set the class in the sheet before read
*/
@Deprecated
public void read(Sheet sheet, Class clazz) {
if (sheet != null) {
sheet.setClazz(clazz);
}
read(sheet);
}
/**
* Context for the entire execution process
@ -240,28 +87,6 @@ public class ExcelReader {
return excelAnalyser.excelExecutor();
}
/**
* Parse the workBook get all sheets
*
* @return workBook all sheets
*
* @deprecated please use {@link #excelExecutor()}
*/
@Deprecated
public List<Sheet> getSheets() {
List<ReadSheet> sheetList = excelExecutor().sheetList();
List<Sheet> sheets = new ArrayList<Sheet>();
if (sheetList == null || sheetList.isEmpty()) {
return sheets;
}
for (ReadSheet readSheet : sheetList) {
Sheet sheet = new Sheet(readSheet.getSheetNo() + 1);
sheet.setSheetName(readSheet.getSheetName());
sheets.add(sheet);
}
return sheets;
}
/**
*
* @return

238
src/main/java/com/alibaba/excel/ExcelWriter.java

@ -1,29 +1,18 @@
package com.alibaba.excel;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.excel.context.WriteContext;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.excel.metadata.Table;
import com.alibaba.excel.parameter.GenerateParam;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.ExcelBuilder;
import com.alibaba.excel.write.ExcelBuilderImpl;
import com.alibaba.excel.write.handler.WriteHandler;
import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.excel.write.metadata.WriteWorkbook;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Excel Writer This tool is used to write value out to Excel via POI. This object can perform the following two
* functions.
@ -49,92 +38,6 @@ public class ExcelWriter {
excelBuilder = new ExcelBuilderImpl(writeWorkbook);
}
/**
* Create new writer
*
* @param outputStream
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
* @deprecated please use {@link com.alibaba.excel.write.builder.ExcelWriterBuilder} build ExcelWriter
*/
@Deprecated
public ExcelWriter(OutputStream outputStream, ExcelTypeEnum typeEnum) {
this(outputStream, typeEnum, true);
}
/**
*
* Create new writer
*
* @param outputStream
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
* @param needHead
* Do you need to write the header to the file?
* @deprecated please use {@link com.alibaba.excel.write.builder.ExcelWriterBuilder} build ExcelWriter
*/
@Deprecated
public ExcelWriter(OutputStream outputStream, ExcelTypeEnum typeEnum, boolean needHead) {
this(null, outputStream, typeEnum, needHead, null);
}
/**
* Create new writer
*
* @param templateInputStream
* Append value after a POI file ,Can be nullthe template POI filesystem that contains the Workbook
* stream)
* @param outputStream
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
* @deprecated please use {@link com.alibaba.excel.write.builder.ExcelWriterBuilder} build ExcelWriter
*/
@Deprecated
public ExcelWriter(InputStream templateInputStream, OutputStream outputStream, ExcelTypeEnum typeEnum,
Boolean needHead) {
this(templateInputStream, outputStream, typeEnum, needHead, null);
}
/**
* Create new writer
*
* @param templateInputStream
* Append value after a POI file ,Can be nullthe template POI filesystem that contains the Workbook
* stream)
* @param outputStream
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
* @param writeHandler
* User-defined callback
* @deprecated please use {@link com.alibaba.excel.write.builder.ExcelWriterBuilder} build ExcelWriter
*/
@Deprecated
public ExcelWriter(InputStream templateInputStream, OutputStream outputStream, ExcelTypeEnum typeEnum,
Boolean needHead, WriteHandler writeHandler) {
List<WriteHandler> customWriteHandlerList = new ArrayList<WriteHandler>();
customWriteHandlerList.add(writeHandler);
WriteWorkbook writeWorkbook = new WriteWorkbook();
writeWorkbook.setTemplateInputStream(templateInputStream);
writeWorkbook.setOutputStream(outputStream);
writeWorkbook.setExcelType(typeEnum);
writeWorkbook.setNeedHead(needHead);
writeWorkbook.setCustomWriteHandlerList(customWriteHandlerList);
excelBuilder = new ExcelBuilderImpl(writeWorkbook);
}
/**
* @param generateParam
* @deprecated please use {@link com.alibaba.excel.write.builder.ExcelWriterBuilder} build ExcelWriter
*/
@Deprecated
public ExcelWriter(GenerateParam generateParam) {
this(generateParam.getOutputStream(), generateParam.getType(), true);
}
/**
* Write data to a sheet
*
@ -188,141 +91,6 @@ public class ExcelWriter {
return this;
}
/**
* Write data to a sheet
*
* @param data
* Data to be written
* @param sheet
* Write to this sheet
* @return this current writer
* @deprecated please use {@link ExcelWriter#write(Collection, WriteSheet)}
*/
@Deprecated
public ExcelWriter write(List data, Sheet sheet) {
return write(data, sheet, null);
}
/**
* Write value to a sheet
*
* @param data
* Data to be written
* @param sheet
* Write to this sheet
* @param table
* Write to this table
* @return this
* @deprecated * @deprecated please use {@link ExcelWriter#write(Collection, WriteSheet,WriteTable)}
*/
@Deprecated
public ExcelWriter write(List data, Sheet sheet, Table table) {
WriteSheet writeSheet = null;
if (sheet != null) {
writeSheet = new WriteSheet();
writeSheet.setSheetNo(sheet.getSheetNo() - 1);
writeSheet.setSheetName(sheet.getSheetName());
writeSheet.setClazz(sheet.getClazz());
writeSheet.setHead(sheet.getHead());
writeSheet.setTableStyle(sheet.getTableStyle());
writeSheet.setRelativeHeadRowIndex(sheet.getStartRow());
writeSheet.setColumnWidthMap(sheet.getColumnWidthMap());
}
WriteTable writeTable = null;
if (table != null) {
writeTable = new WriteTable();
writeTable.setTableNo(table.getTableNo());
writeTable.setClazz(table.getClazz());
writeTable.setHead(table.getHead());
writeTable.setTableStyle(table.getTableStyle());
}
return write(data, writeSheet, writeTable);
}
/**
* Write data to a sheet
*
* @param data
* Data to be written
* @param sheet
* Write to this sheet
* @return this current writer
* @deprecated please use {@link ExcelWriter#write(Collection, WriteSheet)}
*/
@Deprecated
public ExcelWriter write0(List data, Sheet sheet) {
return write(data, sheet, null);
}
/**
* Write value to a sheet
*
* @param data
* Data to be written
* @param sheet
* Write to this sheet
* @param table
* Write to this table
* @return this
* @deprecated * @deprecated please use {@link ExcelWriter#write(Collection, WriteSheet,WriteTable)}
*/
@Deprecated
public ExcelWriter write0(List data, Sheet sheet, Table table) {
return write(data, sheet, table);
}
/**
* Write data to a sheet
*
* @param data
* Data to be written
* @param sheet
* Write to this sheet
* @return this current writer
* @deprecated please use {@link ExcelWriter#write(Collection, WriteSheet)}
*/
@Deprecated
public ExcelWriter write1(List data, Sheet sheet) {
return write(data, sheet, null);
}
/**
* Write value to a sheet
*
* @param data
* Data to be written
* @param sheet
* Write to this sheet
* @param table
* Write to this table
* @return this
* @deprecated * @deprecated please use {@link ExcelWriter#write(Collection, WriteSheet,WriteTable)}
*/
@Deprecated
public ExcelWriter write1(List data, Sheet sheet, Table table) {
return write(data, sheet, table);
}
/**
* Merge CellsIndexes are zero-based.
*
* @param firstRow
* Index of first row
* @param lastRow
* Index of last row (inclusive), must be equal to or larger than {@code firstRow}
* @param firstCol
* Index of first column
* @param lastCol
* Index of last column (inclusive), must be equal to or larger than {@code firstCol}
* @deprecated please use{@link OnceAbsoluteMergeStrategy}
*/
@Deprecated
public ExcelWriter merge(int firstRow, int lastRow, int firstCol, int lastCol) {
excelBuilder.merge(firstRow, lastRow, firstCol, lastCol);
return this;
}
/**
* Close IO
*/

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/BlankRecordHandler.java

@ -5,7 +5,7 @@ import org.apache.poi.hssf.record.Record;
import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
/**
* Record handler

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/BoolErrRecordHandler.java

@ -6,7 +6,7 @@ import org.apache.poi.hssf.record.Record;
import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
/**
* Record handler

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/DummyRecordHandler.java

@ -10,7 +10,7 @@ import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.read.metadata.holder.xls.XlsReadSheetHolder;

26
src/main/java/com/alibaba/excel/analysis/v03/handlers/FormulaRecordHandler.java

@ -9,29 +9,30 @@ import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.DataFormatData;
import com.alibaba.excel.metadata.data.FormulaData;
import com.alibaba.excel.metadata.data.ReadCellData;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.ss.usermodel.CellType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Record handler
*
* @author Dan Zheng
*/
@Slf4j
public class FormulaRecordHandler extends AbstractXlsRecordHandler implements IgnorableXlsRecordHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(FormulaRecordHandler.class);
private static final String ERROR = "#VALUE!";
@Override
public void processRecord(XlsReadContext xlsReadContext, Record record) {
FormulaRecord frec = (FormulaRecord)record;
Map<Integer, Cell> cellMap = xlsReadContext.xlsReadSheetHolder().getCellMap();
CellData<?> tempCellData = new CellData<>();
ReadCellData<?> tempCellData = new ReadCellData<>();
tempCellData.setRowIndex(frec.getRow());
tempCellData.setColumnIndex((int)frec.getColumn());
CellType cellType = CellType.forInt(frec.getCachedResultType());
@ -40,10 +41,11 @@ public class FormulaRecordHandler extends AbstractXlsRecordHandler implements Ig
formulaValue = HSSFFormulaParser.toFormulaString(xlsReadContext.xlsReadWorkbookHolder().getHssfWorkbook(),
frec.getParsedExpression());
} catch (Exception e) {
LOGGER.debug("Get formula value error.", e);
log.debug("Get formula value error.", e);
}
tempCellData.setFormula(Boolean.TRUE);
tempCellData.setFormulaValue(formulaValue);
FormulaData formulaData = new FormulaData();
formulaData.setFormulaValue(formulaValue);
tempCellData.setFormulaData(formulaData);
xlsReadContext.xlsReadSheetHolder().setTempRowType(RowTypeEnum.DATA);
switch (cellType) {
case STRING:
@ -55,11 +57,11 @@ public class FormulaRecordHandler extends AbstractXlsRecordHandler implements Ig
case NUMERIC:
tempCellData.setType(CellDataTypeEnum.NUMBER);
tempCellData.setNumberValue(BigDecimal.valueOf(frec.getValue()));
Integer dataFormat =
int dataFormat =
xlsReadContext.xlsReadWorkbookHolder().getFormatTrackingHSSFListener().getFormatIndex(frec);
Short dataFormatShort = dataFormat.shortValue();
tempCellData.setDataFormat(dataFormatShort);
tempCellData.setDataFormatString(BuiltinFormats.getBuiltinFormat(dataFormatShort,
DataFormatData dataFormatData = new DataFormatData();
dataFormatData.setIndex((short)dataFormat);
dataFormatData.setFormat(BuiltinFormats.getBuiltinFormat(dataFormatData.getIndex(),
xlsReadContext.xlsReadWorkbookHolder().getFormatTrackingHSSFListener().getFormatString(frec),
xlsReadContext.readSheetHolder().getGlobalConfiguration().getLocale()));
cellMap.put((int)frec.getColumn(), tempCellData);

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/LabelRecordHandler.java

@ -6,7 +6,7 @@ import org.apache.poi.hssf.record.Record;
import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
/**
* Record handler

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/LabelSstRecordHandler.java

@ -10,7 +10,7 @@ import com.alibaba.excel.cache.ReadCache;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
/**
* Record handler

12
src/main/java/com/alibaba/excel/analysis/v03/handlers/NumberRecordHandler.java

@ -6,7 +6,8 @@ import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.constant.BuiltinFormats;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.DataFormatData;
import com.alibaba.excel.metadata.data.ReadCellData;
import org.apache.poi.hssf.record.NumberRecord;
import org.apache.poi.hssf.record.Record;
@ -21,13 +22,16 @@ public class NumberRecordHandler extends AbstractXlsRecordHandler implements Ign
@Override
public void processRecord(XlsReadContext xlsReadContext, Record record) {
NumberRecord nr = (NumberRecord)record;
CellData<?>cellData = CellData.newInstance(BigDecimal.valueOf(nr.getValue()), nr.getRow(), (int)nr.getColumn());
ReadCellData<?> cellData = ReadCellData.newInstance(BigDecimal.valueOf(nr.getValue()), nr.getRow(),
(int)nr.getColumn());
short dataFormat = (short)xlsReadContext.xlsReadWorkbookHolder().getFormatTrackingHSSFListener().getFormatIndex(
nr);
cellData.setDataFormat(dataFormat);
cellData.setDataFormatString(BuiltinFormats.getBuiltinFormat(dataFormat,
DataFormatData dataFormatData = new DataFormatData();
dataFormatData.setIndex(dataFormat);
dataFormatData.setFormat(BuiltinFormats.getBuiltinFormat(dataFormat,
xlsReadContext.xlsReadWorkbookHolder().getFormatTrackingHSSFListener().getFormatString(nr),
xlsReadContext.readSheetHolder().getGlobalConfiguration().getLocale()));
cellData.setDataFormatData(dataFormatData);
xlsReadContext.xlsReadSheetHolder().getCellMap().put((int)nr.getColumn(), cellData);
xlsReadContext.xlsReadSheetHolder().setTempRowType(RowTypeEnum.DATA);
}

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/RkRecordHandler.java

@ -5,7 +5,7 @@ import org.apache.poi.hssf.record.Record;
import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
/**
* Record handler

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/StringRecordHandler.java

@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory;
import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.read.metadata.holder.xls.XlsReadSheetHolder;
/**

2
src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractCellValueTagHandler.java

@ -4,7 +4,7 @@ import java.math.BigDecimal;
import com.alibaba.excel.context.xlsx.XlsxReadContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder;
import com.alibaba.excel.util.BooleanUtils;
import com.alibaba.excel.util.StringUtils;

10
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellFormulaTagHandler.java

@ -1,10 +1,11 @@
package com.alibaba.excel.analysis.v07.handlers;
import org.xml.sax.Attributes;
import com.alibaba.excel.context.xlsx.XlsxReadContext;
import com.alibaba.excel.metadata.data.FormulaData;
import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder;
import org.xml.sax.Attributes;
/**
* Cell Handler
*
@ -15,14 +16,15 @@ public class CellFormulaTagHandler extends AbstractXlsxTagHandler {
@Override
public void startElement(XlsxReadContext xlsxReadContext, String name, Attributes attributes) {
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder();
xlsxReadSheetHolder.getTempCellData().setFormula(Boolean.TRUE);
xlsxReadSheetHolder.setTempFormula(new StringBuilder());
}
@Override
public void endElement(XlsxReadContext xlsxReadContext, String name) {
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder();
xlsxReadSheetHolder.getTempCellData().setFormulaValue(xlsxReadSheetHolder.getTempFormula().toString());
FormulaData formulaData = new FormulaData();
formulaData.setFormulaValue(xlsxReadSheetHolder.getTempFormula().toString());
xlsxReadSheetHolder.getTempCellData().setFormulaData(formulaData);
}
@Override

6
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellInlineStringValueTagHandler.java

@ -1,9 +1,9 @@
package com.alibaba.excel.analysis.v07.handlers;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import com.alibaba.excel.context.xlsx.XlsxReadContext;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
/**
* Cell inline string value handler

11
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java

@ -4,7 +4,8 @@ import com.alibaba.excel.constant.BuiltinFormats;
import com.alibaba.excel.constant.ExcelXmlConstants;
import com.alibaba.excel.context.xlsx.XlsxReadContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.DataFormatData;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder;
import com.alibaba.excel.util.PositionUtils;
import com.alibaba.excel.util.StringUtils;
@ -36,7 +37,7 @@ public class CellTagHandler extends AbstractXlsxTagHandler {
// t="n" ,it's means Number
// t is null ,it's means Empty or Number
CellDataTypeEnum type = CellDataTypeEnum.buildFromCellType(attributes.getValue(ExcelXmlConstants.ATTRIBUTE_T));
xlsxReadSheetHolder.setTempCellData(new CellData(type));
xlsxReadSheetHolder.setTempCellData(new ReadCellData<>(type));
xlsxReadSheetHolder.setTempData(new StringBuilder());
// Put in data transformation information
@ -53,9 +54,11 @@ public class CellTagHandler extends AbstractXlsxTagHandler {
}
XSSFCellStyle xssfCellStyle = stylesTable.getStyleAt(dateFormatIndexInteger);
short dataFormat = xssfCellStyle.getDataFormat();
xlsxReadSheetHolder.getTempCellData().setDataFormat(dataFormat);
xlsxReadSheetHolder.getTempCellData().setDataFormatString(BuiltinFormats.getBuiltinFormat(dataFormat,
DataFormatData dataFormatData = new DataFormatData();
dataFormatData.setIndex(dataFormat);
dataFormatData.setFormat(BuiltinFormats.getBuiltinFormat(dataFormat,
xssfCellStyle.getDataFormatString(), xlsxReadSheetHolder.getGlobalConfiguration().getLocale()));
xlsxReadSheetHolder.getTempCellData().setDataFormatData(dataFormatData);
}
}

2
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellValueTagHandler.java

@ -2,7 +2,7 @@ package com.alibaba.excel.analysis.v07.handlers;
import com.alibaba.excel.context.xlsx.XlsxReadContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.util.StringUtils;
/**

10
src/main/java/com/alibaba/excel/context/AnalysisContext.java

@ -4,7 +4,6 @@ import java.io.InputStream;
import java.util.List;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.read.metadata.holder.ReadHolder;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
@ -92,15 +91,6 @@ public interface AnalysisContext {
*/
void readSheetList(List<ReadSheet> readSheetList);
/**
* get current sheet
*
* @return current analysis sheet
* @deprecated please use {@link #readSheetHolder()}
*/
@Deprecated
Sheet getCurrentSheet();
/**
*
* get excel type

26
src/main/java/com/alibaba/excel/context/AnalysisContextImpl.java

@ -3,11 +3,7 @@ package com.alibaba.excel.context;
import java.io.InputStream;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.read.metadata.ReadWorkbook;
import com.alibaba.excel.read.metadata.holder.ReadHolder;
@ -22,12 +18,13 @@ import com.alibaba.excel.read.processor.AnalysisEventProcessor;
import com.alibaba.excel.read.processor.DefaultAnalysisEventProcessor;
import com.alibaba.excel.support.ExcelTypeEnum;
import lombok.extern.slf4j.Slf4j;
/**
*
* @author jipengfei
*/
@Slf4j
public class AnalysisContextImpl implements AnalysisContext {
private static final Logger LOGGER = LoggerFactory.getLogger(AnalysisContextImpl.class);
/**
* The Workbook currently written
*/
@ -65,8 +62,8 @@ public class AnalysisContextImpl implements AnalysisContext {
}
currentReadHolder = readWorkbookHolder;
analysisEventProcessor = new DefaultAnalysisEventProcessor();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Initialization 'AnalysisContextImpl' complete");
if (log.isDebugEnabled()) {
log.debug("Initialization 'AnalysisContextImpl' complete");
}
}
@ -87,8 +84,8 @@ public class AnalysisContextImpl implements AnalysisContext {
throw new ExcelAnalysisException("Cannot read sheet repeatedly.");
}
readWorkbookHolder.getHasReadSheet().add(readSheetHolder.getSheetNo());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Began to read:{}", readSheetHolder);
if (log.isDebugEnabled()) {
log.debug("Began to read:{}", readSheetHolder);
}
}
@ -137,15 +134,6 @@ public class AnalysisContextImpl implements AnalysisContext {
}
@Override
public Sheet getCurrentSheet() {
Sheet sheet = new Sheet(readSheetHolder.getSheetNo() + 1);
sheet.setSheetName(readSheetHolder.getSheetName());
sheet.setHead(readSheetHolder.getHead());
sheet.setClazz(readSheetHolder.getClazz());
sheet.setHeadLineMun(readSheetHolder.getHeadRowNumber());
return sheet;
}
@Override
public ExcelTypeEnum getExcelType() {

2
src/main/java/com/alibaba/excel/context/WriteContextImpl.java

@ -8,7 +8,7 @@ import java.util.UUID;
import com.alibaba.excel.enums.WriteTypeEnum;
import com.alibaba.excel.exception.ExcelGenerateException;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.util.DateUtils;

27
src/main/java/com/alibaba/excel/converters/AutoConverter.java

@ -1,36 +1,9 @@
package com.alibaba.excel.converters;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
* An empty converter.It's automatically converted by type.
*
* @author Jiaju Zhuang
*/
public class AutoConverter implements Converter<Object> {
@Override
public Class<?> supportJavaTypeKey() {
return null;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return null;
}
@Override
public Object convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return null;
}
@Override
public CellData<?> convertToExcelData(Object value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return null;
}
}

31
src/main/java/com/alibaba/excel/converters/Converter.java

@ -1,13 +1,10 @@
package com.alibaba.excel.converters;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
/**
* Convert between Java objects and excel objects
@ -44,7 +41,7 @@ public interface Converter<T> {
* @return Data to put into a Java object
* @throws Exception Exception.
*/
default T convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
default T convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception {
throw new UnsupportedOperationException("The current operation is not supported by the current converter.");
}
@ -52,15 +49,13 @@ public interface Converter<T> {
/**
* Convert excel objects to Java objects
*
* @param cellData Excel cell data.NotNull.
* @param contentProperty Content property.Nullable.
* @param readSheetHolder .NotNull.
* @param context read converter context
* @return Data to put into a Java object
* @throws Exception Exception.
*/
default T convertToJavaData(CellData<?> cellData,
ExcelContentProperty contentProperty, ReadSheetHolder readSheetHolder) throws Exception {
return convertToJavaData(cellData, contentProperty, readSheetHolder.globalConfiguration());
default T convertToJavaData(ReadConverterContext<?> context) throws Exception {
return convertToJavaData(context.getReadCellData(), context.getContentProperty(),
context.getAnalysisContext().currentReadHolder().globalConfiguration());
}
/**
@ -72,7 +67,7 @@ public interface Converter<T> {
* @return Data to put into a Excel
* @throws Exception Exception.
*/
default CellData<?> convertToExcelData(T value, ExcelContentProperty contentProperty,
default WriteCellData<?> convertToExcelData(T value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception {
throw new UnsupportedOperationException("The current operation is not supported by the current converter.");
}
@ -80,14 +75,12 @@ public interface Converter<T> {
/**
* Convert Java objects to excel objects
*
* @param value Java Data.NotNull.
* @param contentProperty Content property.Nullable.
* @param currentWriteHolder He would be {@link WriteSheetHolder} or {@link WriteTableHolder}.NotNull.
* @param context write context
* @return Data to put into a Excel
* @throws Exception Exception.
*/
default CellData<?> convertToExcelData(T value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) throws Exception {
return convertToExcelData(value, contentProperty, currentWriteHolder.globalConfiguration());
default WriteCellData<?> convertToExcelData(WriteConverterContext<T> context) throws Exception {
return convertToExcelData(context.getValue(), context.getContentProperty(),
context.getWriteContext().currentWriteHolder().globalConfiguration());
}
}

30
src/main/java/com/alibaba/excel/converters/ReadConverterContext.java

@ -0,0 +1,30 @@
package com.alibaba.excel.converters;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* read converter context
*
* @author Jiaju Zhuang
*/
@Data
@AllArgsConstructor
public class ReadConverterContext<T> {
/**
* Excel cell data.NotNull.
*/
private ReadCellData<T> readCellData;
/**
* Content property.Nullable.
*/
private ExcelContentProperty contentProperty;
/**
* context.NotNull.
*/
private AnalysisContext analysisContext;
}

31
src/main/java/com/alibaba/excel/converters/WriteConverterContext.java

@ -0,0 +1,31 @@
package com.alibaba.excel.converters;
import com.alibaba.excel.context.WriteContext;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import lombok.Data;
/**
* write converter context
*
* @author Jiaju Zhuang
*/
@Data
@AllArgsConstructor
public class WriteConverterContext<T> {
/**
* Java Data.NotNull.
*/
private T value;
/**
* Content property.Nullable.
*/
private ExcelContentProperty contentProperty;
/**
* write context
*/
private WriteContext writeContext;
}

11
src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalBooleanConverter.java

@ -4,8 +4,9 @@ import java.math.BigDecimal;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class BigDecimalBooleanConverter implements Converter<BigDecimal> {
}
@Override
public BigDecimal convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public BigDecimal convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return BigDecimal.ONE;
@ -35,12 +36,12 @@ public class BigDecimalBooleanConverter implements Converter<BigDecimal> {
}
@Override
public CellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (BigDecimal.ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

7
src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalNumberConverter.java

@ -4,8 +4,9 @@ import java.math.BigDecimal;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
@ -28,13 +29,13 @@ public class BigDecimalNumberConverter implements Converter<BigDecimal> {
}
@Override
public BigDecimal convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public BigDecimal convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue();
}
@Override
public CellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
}

7
src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalStringConverter.java

@ -5,8 +5,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -28,13 +29,13 @@ public class BigDecimalStringConverter implements Converter<BigDecimal> {
}
@Override
public BigDecimal convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public BigDecimal convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseBigDecimal(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

9
src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.booleanconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -24,15 +25,15 @@ public class BooleanBooleanConverter implements Converter<Boolean> {
}
@Override
public Boolean convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Boolean convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getBooleanValue();
}
@Override
public CellData<?> convertToExcelData(Boolean value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Boolean value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData<>(value);
return new WriteCellData<>(value);
}
}

11
src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanNumberConverter.java

@ -4,8 +4,9 @@ import java.math.BigDecimal;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -25,7 +26,7 @@ public class BooleanNumberConverter implements Converter<Boolean> {
}
@Override
public Boolean convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Boolean convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (BigDecimal.ONE.compareTo(cellData.getNumberValue()) == 0) {
return Boolean.TRUE;
@ -34,12 +35,12 @@ public class BooleanNumberConverter implements Converter<Boolean> {
}
@Override
public CellData<?> convertToExcelData(Boolean value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Boolean value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value) {
return new CellData<>(BigDecimal.ONE);
return new WriteCellData<>(BigDecimal.ONE);
}
return new CellData<>(BigDecimal.ZERO);
return new WriteCellData<>(BigDecimal.ZERO);
}
}

9
src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanStringConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.booleanconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -24,15 +25,15 @@ public class BooleanStringConverter implements Converter<Boolean> {
}
@Override
public Boolean convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Boolean convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return Boolean.valueOf(cellData.getStringValue());
}
@Override
public CellData<?> convertToExcelData(Boolean value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Boolean value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData<>(value.toString());
return new WriteCellData<>(value.toString());
}
}

26
src/main/java/com/alibaba/excel/converters/bytearray/BoxingByteArrayImageConverter.java

@ -1,12 +1,8 @@
package com.alibaba.excel.converters.bytearray;
import java.lang.annotation.Annotation;
import com.alibaba.excel.annotation.write.style.ImagePosition;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -21,29 +17,13 @@ public class BoxingByteArrayImageConverter implements Converter<Byte[]> {
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.IMAGE;
}
@Override
public Byte[] convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
throw new UnsupportedOperationException("Cannot convert images to byte arrays");
}
@Override
public CellData<?> convertToExcelData(Byte[] value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Byte[] value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
byte[] byteValue = new byte[value.length];
for (int i = 0; i < value.length; i++) {
byteValue[i] = value[i];
}
ImagePosition imagePosition = contentProperty.getField().getAnnotation(ImagePosition.class);
if (imagePosition != null) {
return new CellData(byteValue, imagePosition);
} else {
return new CellData(byteValue);
}
return new WriteCellData<>(byteValue);
}
}

28
src/main/java/com/alibaba/excel/converters/bytearray/ByteArrayImageConverter.java

@ -1,12 +1,8 @@
package com.alibaba.excel.converters.bytearray;
import java.lang.annotation.Annotation;
import com.alibaba.excel.annotation.write.style.ImagePosition;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -15,32 +11,16 @@ import com.alibaba.excel.metadata.property.ExcelContentProperty;
* @author Jiaju Zhuang
*/
public class ByteArrayImageConverter implements Converter<byte[]> {
@Override
public Class<byte[]> supportJavaTypeKey() {
return byte[].class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.IMAGE;
}
@Override
public byte[] convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(byte[] value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
throw new UnsupportedOperationException("Cannot convert images to byte arrays");
}
@Override
public CellData convertToExcelData(byte[] value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
ImagePosition imagePosition = contentProperty.getField().getAnnotation(ImagePosition.class);
if (imagePosition != null) {
return new CellData(value, imagePosition);
} else {
return new CellData(value);
}
return new WriteCellData<>(value);
}
}

11
src/main/java/com/alibaba/excel/converters/byteconverter/ByteBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.byteconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class ByteBooleanConverter implements Converter<Byte> {
}
@Override
public Byte convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Byte convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return ONE;
@ -35,12 +36,12 @@ public class ByteBooleanConverter implements Converter<Byte> {
}
@Override
public CellData<?> convertToExcelData(Byte value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Byte value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

14
src/main/java/com/alibaba/excel/converters/byteconverter/ByteNumberConverter.java

@ -1,14 +1,12 @@
package com.alibaba.excel.converters.byteconverter;
import java.math.BigDecimal;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Byte and number converter
@ -28,15 +26,15 @@ public class ByteNumberConverter implements Converter<Byte> {
}
@Override
public Byte convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Byte convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue().byteValue();
}
@Override
public CellData<?> convertToExcelData(Byte value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
public WriteCellData<?> convertToExcelData(Byte value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellData(value, contentProperty);
}
}

7
src/main/java/com/alibaba/excel/converters/byteconverter/ByteStringConverter.java

@ -4,8 +4,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -27,13 +28,13 @@ public class ByteStringConverter implements Converter<Byte> {
}
@Override
public Byte convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Byte convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseByte(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(Byte value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Byte value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

24
src/main/java/com/alibaba/excel/converters/date/DateDateConverter.java

@ -3,12 +3,10 @@ package com.alibaba.excel.converters.date;
import java.util.Date;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.WorkBookUtil;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Date and date converter
@ -22,26 +20,14 @@ public class DateDateConverter implements Converter<Date> {
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.DATE;
}
@Override
public Date convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getDateValue();
}
@Override
public CellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) throws Exception {
CellData<?> cellData = new CellData<>(value);
public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws Exception {
WriteCellData<?> cellData = new WriteCellData<>(value);
if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null
|| contentProperty.getDateTimeFormatProperty().getFormat() == null) {
return cellData;
}
WorkBookUtil.fillDataFormat(cellData, currentWriteHolder,
contentProperty.getDateTimeFormatProperty().getFormat());
WorkBookUtil.fillDataFormat(cellData, contentProperty.getDateTimeFormatProperty().getFormat());
return cellData;
}
}

15
src/main/java/com/alibaba/excel/converters/date/DateNumberConverter.java

@ -3,14 +3,15 @@ package com.alibaba.excel.converters.date;
import java.math.BigDecimal;
import java.util.Date;
import org.apache.poi.ss.usermodel.DateUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.apache.poi.ss.usermodel.DateUtil;
/**
* Date and number converter
*
@ -29,7 +30,7 @@ public class DateNumberConverter implements Converter<Date> {
}
@Override
public Date convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Date convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) {
return DateUtil.getJavaDate(cellData.getNumberValue().doubleValue(),
@ -41,13 +42,13 @@ public class DateNumberConverter implements Converter<Date> {
}
@Override
public CellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) {
return new CellData<>(
return new WriteCellData<>(
BigDecimal.valueOf(DateUtil.getExcelDate(value, globalConfiguration.getUse1904windowing())));
} else {
return new CellData<>(BigDecimal.valueOf(
return new WriteCellData<>(BigDecimal.valueOf(
DateUtil.getExcelDate(value, contentProperty.getDateTimeFormatProperty().getUse1904windowing())));
}
}

11
src/main/java/com/alibaba/excel/converters/date/DateStringConverter.java

@ -5,8 +5,9 @@ import java.util.Date;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.DateUtils;
@ -27,7 +28,7 @@ public class DateStringConverter implements Converter<Date> {
}
@Override
public Date convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Date convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) {
return DateUtils.parseDate(cellData.getStringValue(), null);
@ -38,12 +39,12 @@ public class DateStringConverter implements Converter<Date> {
}
@Override
public CellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) {
return new CellData<>(DateUtils.format(value, null));
return new WriteCellData<>(DateUtils.format(value, null));
} else {
return new CellData<>(DateUtils.format(value, contentProperty.getDateTimeFormatProperty().getFormat()));
return new WriteCellData<>(DateUtils.format(value, contentProperty.getDateTimeFormatProperty().getFormat()));
}
}
}

11
src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.doubleconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class DoubleBooleanConverter implements Converter<Double> {
}
@Override
public Double convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Double convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return ONE;
@ -35,12 +36,12 @@ public class DoubleBooleanConverter implements Converter<Double> {
}
@Override
public CellData<?> convertToExcelData(Double value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Double value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

14
src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleNumberConverter.java

@ -1,14 +1,12 @@
package com.alibaba.excel.converters.doubleconverter;
import java.math.BigDecimal;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Double and number converter
@ -28,14 +26,14 @@ public class DoubleNumberConverter implements Converter<Double> {
}
@Override
public Double convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Double convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue().doubleValue();
}
@Override
public CellData<?> convertToExcelData(Double value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
public WriteCellData<?> convertToExcelData(Double value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellData(value, contentProperty);
}
}

7
src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleStringConverter.java

@ -4,8 +4,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -27,13 +28,13 @@ public class DoubleStringConverter implements Converter<Double> {
}
@Override
public Double convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Double convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseDouble(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(Double value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Double value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

25
src/main/java/com/alibaba/excel/converters/file/FileImageConverter.java

@ -2,11 +2,10 @@ package com.alibaba.excel.converters.file;
import java.io.File;
import java.io.IOException;
import com.alibaba.excel.annotation.write.style.ImagePosition;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.FileUtils;
@ -22,24 +21,8 @@ public class FileImageConverter implements Converter<File> {
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.IMAGE;
}
@Override
public File convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
throw new UnsupportedOperationException("Cannot convert images to file");
}
@Override
public CellData<?> convertToExcelData(File value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(File value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws IOException {
ImagePosition imagePosition = contentProperty.getField().getAnnotation(ImagePosition.class);
if (imagePosition != null) {
return new CellData(FileUtils.readFileToByteArray(value), imagePosition);
} else {
return new CellData(FileUtils.readFileToByteArray(value));
}
return new WriteCellData<>(FileUtils.readFileToByteArray(value));
}
}

11
src/main/java/com/alibaba/excel/converters/floatconverter/FloatBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.floatconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class FloatBooleanConverter implements Converter<Float> {
}
@Override
public Float convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Float convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return ONE;
@ -35,12 +36,12 @@ public class FloatBooleanConverter implements Converter<Float> {
}
@Override
public CellData<?> convertToExcelData(Float value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Float value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

12
src/main/java/com/alibaba/excel/converters/floatconverter/FloatNumberConverter.java

@ -1,12 +1,13 @@
package com.alibaba.excel.converters.floatconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Float and number converter
@ -26,14 +27,13 @@ public class FloatNumberConverter implements Converter<Float> {
}
@Override
public Float convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Float convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue().floatValue();
}
@Override
public CellData<?> convertToExcelData(Float value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
public WriteCellData<?> convertToExcelData(WriteConverterContext<Float> context) {
return NumberUtils.formatToCellData(context.getValue(), context.getContentProperty());
}
}

7
src/main/java/com/alibaba/excel/converters/floatconverter/FloatStringConverter.java

@ -4,8 +4,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -27,13 +28,13 @@ public class FloatStringConverter implements Converter<Float> {
}
@Override
public Float convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Float convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseFloat(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(Float value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Float value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

26
src/main/java/com/alibaba/excel/converters/inputstream/InputStreamImageConverter.java

@ -2,15 +2,11 @@ package com.alibaba.excel.converters.inputstream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import com.alibaba.excel.annotation.write.style.ImagePosition;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.FileUtils;
import com.alibaba.excel.util.IoUtils;
/**
@ -25,25 +21,9 @@ public class InputStreamImageConverter implements Converter<InputStream> {
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.IMAGE;
}
@Override
public InputStream convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
throw new UnsupportedOperationException("Cannot convert images to input stream");
}
@Override
public CellData<?> convertToExcelData(InputStream value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(InputStream value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws IOException {
ImagePosition imagePosition = contentProperty.getField().getAnnotation(ImagePosition.class);
if (imagePosition != null) {
return new CellData(IoUtils.toByteArray(value), imagePosition);
} else {
return new CellData(IoUtils.toByteArray(value));
}
return new WriteCellData<>(IoUtils.toByteArray(value));
}
}

11
src/main/java/com/alibaba/excel/converters/integer/IntegerBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.integer;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class IntegerBooleanConverter implements Converter<Integer> {
}
@Override
public Integer convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return ONE;
@ -35,12 +36,12 @@ public class IntegerBooleanConverter implements Converter<Integer> {
}
@Override
public CellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

12
src/main/java/com/alibaba/excel/converters/integer/IntegerNumberConverter.java

@ -1,12 +1,13 @@
package com.alibaba.excel.converters.integer;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Integer and number converter
@ -26,15 +27,14 @@ public class IntegerNumberConverter implements Converter<Integer> {
}
@Override
public Integer convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue().intValue();
}
@Override
public CellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
public WriteCellData<?> convertToExcelData(WriteConverterContext<Integer> context) {
return NumberUtils.formatToCellData(context.getValue(), context.getContentProperty());
}
}

7
src/main/java/com/alibaba/excel/converters/integer/IntegerStringConverter.java

@ -4,8 +4,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -27,13 +28,13 @@ public class IntegerStringConverter implements Converter<Integer> {
}
@Override
public Integer convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseInteger(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

11
src/main/java/com/alibaba/excel/converters/longconverter/LongBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.longconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class LongBooleanConverter implements Converter<Long> {
}
@Override
public Long convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Long convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return ONE;
@ -35,12 +36,12 @@ public class LongBooleanConverter implements Converter<Long> {
}
@Override
public CellData<?> convertToExcelData(Long value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Long value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

12
src/main/java/com/alibaba/excel/converters/longconverter/LongNumberConverter.java

@ -1,12 +1,13 @@
package com.alibaba.excel.converters.longconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Long and number converter
@ -26,15 +27,14 @@ public class LongNumberConverter implements Converter<Long> {
}
@Override
public Long convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Long convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue().longValue();
}
@Override
public CellData<?> convertToExcelData(Long value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
public WriteCellData<?> convertToExcelData(WriteConverterContext<Long> context) {
return NumberUtils.formatToCellData(context.getValue(), context.getContentProperty());
}
}

7
src/main/java/com/alibaba/excel/converters/longconverter/LongStringConverter.java

@ -4,8 +4,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -27,13 +28,13 @@ public class LongStringConverter implements Converter<Long> {
}
@Override
public Long convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Long convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseLong(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(Long value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Long value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

11
src/main/java/com/alibaba/excel/converters/shortconverter/ShortBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.shortconverter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -26,7 +27,7 @@ public class ShortBooleanConverter implements Converter<Short> {
}
@Override
public Short convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Short convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (cellData.getBooleanValue()) {
return ONE;
@ -35,12 +36,12 @@ public class ShortBooleanConverter implements Converter<Short> {
}
@Override
public CellData<?> convertToExcelData(Short value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Short value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (ONE.equals(value)) {
return new CellData<>(Boolean.TRUE);
return new WriteCellData<>(Boolean.TRUE);
}
return new CellData<>(Boolean.FALSE);
return new WriteCellData<>(Boolean.FALSE);
}
}

14
src/main/java/com/alibaba/excel/converters/shortconverter/ShortNumberConverter.java

@ -1,14 +1,13 @@
package com.alibaba.excel.converters.shortconverter;
import java.math.BigDecimal;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Short and number converter
@ -28,14 +27,13 @@ public class ShortNumberConverter implements Converter<Short> {
}
@Override
public Short convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public Short convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getNumberValue().shortValue();
}
@Override
public CellData<?> convertToExcelData(Short value, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
return NumberUtils.formatToCellData(value, contentProperty, currentWriteHolder);
public WriteCellData<?> convertToExcelData(WriteConverterContext<Short> context) {
return NumberUtils.formatToCellData(context.getValue(), context.getContentProperty());
}
}

7
src/main/java/com/alibaba/excel/converters/shortconverter/ShortStringConverter.java

@ -4,8 +4,9 @@ import java.text.ParseException;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.NumberUtils;
@ -27,13 +28,13 @@ public class ShortStringConverter implements Converter<Short> {
}
@Override
public Short convertToJavaData(CellData<?>cellData, ExcelContentProperty contentProperty,
public Short convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws ParseException {
return NumberUtils.parseShort(cellData.getStringValue(), contentProperty);
}
@Override
public CellData<?>convertToExcelData(Short value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(Short value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return NumberUtils.formatToCellDataString(value, contentProperty);
}

9
src/main/java/com/alibaba/excel/converters/string/StringBooleanConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.string;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -24,15 +25,15 @@ public class StringBooleanConverter implements Converter<String> {
}
@Override
public String convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getBooleanValue().toString();
}
@Override
public CellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData<>(Boolean.valueOf(value));
return new WriteCellData<>(Boolean.valueOf(value));
}
}

9
src/main/java/com/alibaba/excel/converters/string/StringErrorConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.string;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -23,15 +24,15 @@ public class StringErrorConverter implements Converter<String> {
}
@Override
public String convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getStringValue();
}
@Override
public CellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData<>(CellDataTypeEnum.ERROR, value);
return new WriteCellData<>(CellDataTypeEnum.ERROR, value);
}
}

26
src/main/java/com/alibaba/excel/converters/string/StringImageConverter.java

@ -2,16 +2,12 @@ package com.alibaba.excel.converters.string;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import com.alibaba.excel.annotation.write.style.ImagePosition;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.FileUtils;
import com.alibaba.excel.util.IoUtils;
/**
* String and image converter
@ -25,25 +21,9 @@ public class StringImageConverter implements Converter<String> {
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.IMAGE;
}
@Override
public String convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
throw new UnsupportedOperationException("Cannot convert images to string");
}
@Override
public CellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws IOException {
ImagePosition imagePosition = contentProperty.getField().getAnnotation(ImagePosition.class);
if (imagePosition != null) {
return new CellData(FileUtils.readFileToByteArray(new File(value)), imagePosition);
} else {
return new CellData(FileUtils.readFileToByteArray(new File(value)));
}
return new WriteCellData<>(FileUtils.readFileToByteArray(new File(value)));
}
}

22
src/main/java/com/alibaba/excel/converters/string/StringNumberConverter.java

@ -2,18 +2,19 @@ package com.alibaba.excel.converters.string;
import java.math.BigDecimal;
import org.apache.poi.ss.usermodel.DateUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.DateUtils;
import com.alibaba.excel.util.NumberDataFormatterUtils;
import com.alibaba.excel.util.NumberUtils;
import com.alibaba.excel.util.StringUtils;
import org.apache.poi.ss.usermodel.DateUtil;
/**
* String and number converter
*
@ -32,7 +33,7 @@ public class StringNumberConverter implements Converter<String> {
}
@Override
public String convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
// If there are "DateTimeFormat", read as date
if (contentProperty != null && contentProperty.getDateTimeFormatProperty() != null) {
@ -46,17 +47,20 @@ public class StringNumberConverter implements Converter<String> {
return NumberUtils.format(cellData.getNumberValue(), contentProperty);
}
// Excel defines formatting
if (cellData.getDataFormat() != null && !StringUtils.isEmpty(cellData.getDataFormatString())) {
return NumberDataFormatterUtils.format(cellData.getNumberValue().doubleValue(), cellData.getDataFormat(),
cellData.getDataFormatString(), globalConfiguration);
boolean hasDataFormatData = cellData.getDataFormatData() != null
&& cellData.getDataFormatData().getIndex() != null && !StringUtils.isEmpty(
cellData.getDataFormatData().getFormat());
if (hasDataFormatData) {
return NumberDataFormatterUtils.format(cellData.getNumberValue().doubleValue(),
cellData.getDataFormatData().getIndex(), cellData.getDataFormatData().getFormat(), globalConfiguration);
}
// Default conversion number
return NumberUtils.format(cellData.getNumberValue(), contentProperty);
}
@Override
public CellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData<>(new BigDecimal(value));
return new WriteCellData<>(new BigDecimal(value));
}
}

9
src/main/java/com/alibaba/excel/converters/string/StringStringConverter.java

@ -2,8 +2,9 @@ package com.alibaba.excel.converters.string;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
/**
@ -23,15 +24,15 @@ public class StringStringConverter implements Converter<String> {
}
@Override
public String convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return cellData.getStringValue();
}
@Override
public CellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
return new CellData<>(value);
return new WriteCellData<>(value);
}
}

20
src/main/java/com/alibaba/excel/converters/url/UrlImageConverter.java

@ -5,17 +5,16 @@ import java.io.InputStream;
import java.net.URL;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.util.IoUtils;
/**
* Url and image converter
*
* @since 2.1.1
* @author Jiaju Zhuang
* @since 2.1.1
*/
public class UrlImageConverter implements Converter<URL> {
@Override
@ -24,24 +23,13 @@ public class UrlImageConverter implements Converter<URL> {
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.IMAGE;
}
@Override
public URL convertToJavaData(CellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
throw new UnsupportedOperationException("Cannot convert images to url.");
}
@Override
public CellData<?> convertToExcelData(URL value, ExcelContentProperty contentProperty,
public WriteCellData<?> convertToExcelData(URL value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) throws IOException {
InputStream inputStream = null;
try {
inputStream = value.openStream();
byte[] bytes = IoUtils.toByteArray(inputStream);
return new CellData<>(bytes);
return new WriteCellData<>(bytes);
} finally {
if (inputStream != null) {
inputStream.close();

4
src/main/java/com/alibaba/excel/enums/CellDataTypeEnum.java

@ -36,10 +36,6 @@ public enum CellDataTypeEnum {
* error
*/
ERROR,
/**
* image. Support only when writing.
*/
IMAGE,
/**
* date. Support only when writing.
*/

8
src/main/java/com/alibaba/excel/event/AbstractIgnoreExceptionReadListener.java

@ -8,7 +8,9 @@ import com.alibaba.excel.read.listener.ReadListener;
* Receives the return of each piece of data parsed
*
* @author jipengfei
* @deprecated Use directly {@link ReadListener}
*/
@Deprecated
public abstract class AbstractIgnoreExceptionReadListener<T> implements ReadListener<T> {
/**
@ -24,10 +26,8 @@ public abstract class AbstractIgnoreExceptionReadListener<T> implements ReadList
/**
* The current method is called when extra information is returned
*
* @param extra
* extra information
* @param context
* analysis context
* @param extra extra information
* @param context analysis context
*/
@Override
public void extra(CellExtra extra, AnalysisContext context) {}

4
src/main/java/com/alibaba/excel/event/AnalysisEventListener.java

@ -3,8 +3,8 @@ package com.alibaba.excel.event;
import java.util.Map;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.CellExtra;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.util.ConverterUtils;
@ -16,7 +16,7 @@ import com.alibaba.excel.util.ConverterUtils;
public abstract class AnalysisEventListener<T> implements ReadListener<T> {
@Override
public void invokeHead(Map<Integer, CellData<?>> headMap, AnalysisContext context) {
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
invokeHeadMap(ConverterUtils.convertToStringMap(headMap, context), context);
}

38
src/main/java/com/alibaba/excel/event/WriteHandler.java

@ -1,38 +0,0 @@
package com.alibaba.excel.event;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
/**
*
* @author jipengfei
* @deprecated please use {@link com.alibaba.excel.write.handler.WriteHandler}
*/
@Deprecated
public interface WriteHandler {
/**
* Custom operation after creating each sheet
*
* @param sheetNo
* @param sheet
*/
void sheet(int sheetNo, Sheet sheet);
/**
* Custom operation after creating each row
*
* @param rowNum
* @param row
*/
void row(int rowNum, Row row);
/**
* Custom operation after creating each cell
*
* @param cellNum
* @param cell
*/
void cell(int cellNum, Cell cell);
}

4
src/main/java/com/alibaba/excel/exception/ExcelDataConvertException.java

@ -1,12 +1,10 @@
package com.alibaba.excel.exception;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
/**
* Data convert exception

40
src/main/java/com/alibaba/excel/metadata/BaseRowModel.java

@ -1,40 +0,0 @@
package com.alibaba.excel.metadata;
import java.util.HashMap;
import java.util.Map;
import org.apache.poi.ss.usermodel.CellStyle;
import com.alibaba.excel.annotation.ExcelIgnore;
/**
* Excel基础模型
*
* @author jipengfei
* @deprecated Now you don't need to extend any classes
*/
@Deprecated
public class BaseRowModel {
/**
* 每列样式
*/
@ExcelIgnore
private Map<Integer, CellStyle> cellStyleMap = new HashMap<Integer, CellStyle>();
public void addStyle(Integer row, CellStyle cellStyle) {
cellStyleMap.put(row, cellStyle);
}
public CellStyle getStyle(Integer row) {
return cellStyleMap.get(row);
}
public Map<Integer, CellStyle> getCellStyleMap() {
return cellStyleMap;
}
public void setCellStyleMap(Map<Integer, CellStyle> cellStyleMap) {
this.cellStyleMap = cellStyleMap;
}
}

63
src/main/java/com/alibaba/excel/metadata/BasicParameter.java

@ -5,11 +5,14 @@ import java.util.Locale;
import com.alibaba.excel.converters.Converter;
import lombok.Data;
/**
* Basic parameter
*
* @author Jiaju Zhuang
**/
@Data
public class BasicParameter {
/**
* You can only choose one of the {@link BasicParameter#head} and {@link BasicParameter#clazz}
@ -18,11 +21,11 @@ public class BasicParameter {
/**
* You can only choose one of the {@link BasicParameter#head} and {@link BasicParameter#clazz}
*/
private Class clazz;
private Class<?> clazz;
/**
* Custom type conversions override the default
*/
private List<Converter> customConverterList;
private List<Converter<?>> customConverterList;
/**
* Automatic trim includes sheet name and content
*/
@ -47,60 +50,4 @@ public class BasicParameter {
* default is false
*/
private Boolean useScientificFormat;
public List<List<String>> getHead() {
return head;
}
public void setHead(List<List<String>> head) {
this.head = head;
}
public Class getClazz() {
return clazz;
}
public void setClazz(Class clazz) {
this.clazz = clazz;
}
public List<Converter> getCustomConverterList() {
return customConverterList;
}
public void setCustomConverterList(List<Converter> customConverterList) {
this.customConverterList = customConverterList;
}
public Boolean getAutoTrim() {
return autoTrim;
}
public void setAutoTrim(Boolean autoTrim) {
this.autoTrim = autoTrim;
}
public Boolean getUse1904windowing() {
return use1904windowing;
}
public void setUse1904windowing(Boolean use1904windowing) {
this.use1904windowing = use1904windowing;
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
public Boolean getUseScientificFormat() {
return useScientificFormat;
}
public void setUseScientificFormat(Boolean useScientificFormat) {
this.useScientificFormat = useScientificFormat;
}
}

193
src/main/java/com/alibaba/excel/metadata/CellData.java

@ -1,193 +0,0 @@
package com.alibaba.excel.metadata;
import java.math.BigDecimal;
import java.util.Date;
import com.alibaba.excel.annotation.write.style.ImagePosition;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.property.ImagePositionProperty;
import com.alibaba.excel.util.StringUtils;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import lombok.Data;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.RichTextString;
/**
* Excel internal cell data.
*
* <p>
*
* @author Jiaju Zhuang
*/
@Data
public class CellData<T> extends AbstractCell {
private CellDataTypeEnum type;
/**
* {@link CellDataTypeEnum#NUMBER}
*/
private BigDecimal numberValue;
/**
* {@link CellDataTypeEnum#STRING} and{@link CellDataTypeEnum#ERROR}
*/
private String stringValue;
/**
* {@link CellDataTypeEnum#BOOLEAN}
*/
private Boolean booleanValue;
/**
* The resulting converted data.
*/
private T data;
/**
* formula
*/
private FormulaData formulaData;
/**
* data format
*/
private DataFormat dataFormat;
public CellData() {}
public CellData(T data) {
this.data = data;
}
public CellData(String stringValue) {
this(CellDataTypeEnum.STRING, stringValue);
}
public CellData(CellDataTypeEnum type, String stringValue) {
if (type != CellDataTypeEnum.STRING && type != CellDataTypeEnum.ERROR) {
throw new IllegalArgumentException("Only support CellDataTypeEnum.STRING and CellDataTypeEnum.ERROR");
}
if (stringValue == null) {
throw new IllegalArgumentException("StringValue can not be null");
}
this.type = type;
this.stringValue = stringValue;
}
public CellData(BigDecimal numberValue) {
if (numberValue == null) {
throw new IllegalArgumentException("DoubleValue can not be null");
}
this.type = CellDataTypeEnum.NUMBER;
this.numberValue = numberValue;
}
public CellData(byte[] imageValue) {
if (imageValue == null) {
throw new IllegalArgumentException("ImageValue can not be null");
}
this.type = CellDataTypeEnum.IMAGE;
this.imageValue = imageValue;
}
public CellData(byte[] imageValue, ImagePosition imagePosition) {
if (imageValue == null) {
throw new IllegalArgumentException("ImageValue can not be null");
}
if (imagePosition == null) {
throw new IllegalArgumentException("ImagePosition can not be null");
}
this.type = CellDataTypeEnum.IMAGE;
this.imageValue = imageValue;
this.imagePositionProperty = ImagePositionProperty.build(imagePosition);
this.useImagePositionProperty = true;
this.formula = Boolean.FALSE;
}
public CellData(Boolean booleanValue) {
if (booleanValue == null) {
throw new IllegalArgumentException("BooleanValue can not be null");
}
this.type = CellDataTypeEnum.BOOLEAN;
this.booleanValue = booleanValue;
}
public CellData(Date dateValue) {
if (dateValue == null) {
throw new IllegalArgumentException("DateValue can not be null");
}
this.type = CellDataTypeEnum.DATE;
this.dateValue = dateValue;
this.formula = Boolean.FALSE;
}
public CellData(CellDataTypeEnum type) {
if (type == null) {
throw new IllegalArgumentException("Type can not be null");
}
this.type = type;
}
/**
* Ensure that the object does not appear null
*/
public void checkEmpty() {
if (type == null) {
type = CellDataTypeEnum.EMPTY;
}
switch (type) {
case STRING:
case ERROR:
if (StringUtils.isEmpty(stringValue)) {
type = CellDataTypeEnum.EMPTY;
}
return;
case NUMBER:
if (numberValue == null) {
type = CellDataTypeEnum.EMPTY;
}
return;
case BOOLEAN:
if (booleanValue == null) {
type = CellDataTypeEnum.EMPTY;
}
return;
default:
}
}
public static CellData<?> newEmptyInstance() {
return newEmptyInstance(null, null);
}
public static CellData<?> newEmptyInstance(Integer rowIndex, Integer columnIndex) {
CellData<?> cellData = new CellData<>(CellDataTypeEnum.EMPTY);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static CellData<?> newInstance(Boolean booleanValue) {
return newInstance(booleanValue, null, null);
}
public static CellData<?> newInstance(Boolean booleanValue, Integer rowIndex, Integer columnIndex) {
CellData<?> cellData = new CellData<>(booleanValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static CellData<?> newInstance(String stringValue, Integer rowIndex, Integer columnIndex) {
CellData<?> cellData = new CellData<>(stringValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static CellData<?> newInstance(BigDecimal numberValue, Integer rowIndex, Integer columnIndex) {
CellData<?> cellData = new CellData<>(numberValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
}

10
src/main/java/com/alibaba/excel/metadata/HyperlinkData.java

@ -1,10 +0,0 @@
package com.alibaba.excel.metadata;
/**
* TODO
*
* @author Jiaju Zhuang
*/
public class HyperlinkData {
}

13
src/main/java/com/alibaba/excel/metadata/ReadCellData.java

@ -1,13 +0,0 @@
package com.alibaba.excel.metadata;
import lombok.Data;
/**
* TODO
*
* @author Jiaju Zhuang
*/
@Data
public class ReadCellData<T> extends CellData<T>{
}

162
src/main/java/com/alibaba/excel/metadata/Sheet.java

@ -1,162 +0,0 @@
package com.alibaba.excel.metadata;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author jipengfei
* @deprecated pleas use {@link com.alibaba.excel.write.metadata.WriteSheet} or
* {@link com.alibaba.excel.read.metadata.ReadSheet}
*/
@Deprecated
public class Sheet {
/**
*/
private int headLineMun;
/**
* Starting from 1
*/
private int sheetNo;
/**
*/
private String sheetName;
/**
*/
private Class<? extends BaseRowModel> clazz;
/**
*/
private List<List<String>> head;
/**
*
*/
private TableStyle tableStyle;
/**
* column with
*/
private Map<Integer, Integer> columnWidthMap = new HashMap<Integer, Integer>();
/**
*
*/
private Boolean autoWidth = Boolean.FALSE;
/**
*
*/
private int startRow = 0;
public Sheet(int sheetNo) {
this.sheetNo = sheetNo;
}
public Sheet(int sheetNo, int headLineMun) {
this.sheetNo = sheetNo;
this.headLineMun = headLineMun;
}
public Sheet(int sheetNo, int headLineMun, Class<? extends BaseRowModel> clazz) {
this.sheetNo = sheetNo;
this.headLineMun = headLineMun;
this.clazz = clazz;
}
public Sheet(int sheetNo, int headLineMun, Class<? extends BaseRowModel> clazz, String sheetName,
List<List<String>> head) {
this.sheetNo = sheetNo;
this.clazz = clazz;
this.headLineMun = headLineMun;
this.sheetName = sheetName;
this.head = head;
}
public List<List<String>> getHead() {
return head;
}
public void setHead(List<List<String>> head) {
this.head = head;
}
public Class<? extends BaseRowModel> getClazz() {
return clazz;
}
public void setClazz(Class<? extends BaseRowModel> clazz) {
this.clazz = clazz;
if (headLineMun == 0) {
this.headLineMun = 1;
}
}
public int getHeadLineMun() {
return headLineMun;
}
public void setHeadLineMun(int headLineMun) {
this.headLineMun = headLineMun;
}
public int getSheetNo() {
return sheetNo;
}
public void setSheetNo(int sheetNo) {
this.sheetNo = sheetNo;
}
public String getSheetName() {
return sheetName;
}
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
public TableStyle getTableStyle() {
return tableStyle;
}
public void setTableStyle(TableStyle tableStyle) {
this.tableStyle = tableStyle;
}
public Map<Integer, Integer> getColumnWidthMap() {
return columnWidthMap;
}
public void setColumnWidthMap(Map<Integer, Integer> columnWidthMap) {
this.columnWidthMap = columnWidthMap;
}
@Override
public String toString() {
return "Sheet{" + "headLineMun=" + headLineMun + ", sheetNo=" + sheetNo + ", sheetName='" + sheetName + '\''
+ ", clazz=" + clazz + ", head=" + head + ", tableStyle=" + tableStyle + ", columnWidthMap="
+ columnWidthMap + '}';
}
public Boolean getAutoWidth() {
return autoWidth;
}
public void setAutoWidth(Boolean autoWidth) {
this.autoWidth = autoWidth;
}
public int getStartRow() {
return startRow;
}
public void setStartRow(int startRow) {
this.startRow = startRow;
}
}

62
src/main/java/com/alibaba/excel/metadata/Table.java

@ -1,62 +0,0 @@
package com.alibaba.excel.metadata;
import java.util.List;
/**
* @author jipengfei
* @deprecated please use {@link com.alibaba.excel.write.metadata.WriteTable}
*/
@Deprecated
public class Table {
/**
*/
private Class<? extends BaseRowModel> clazz;
/**
*/
private List<List<String>> head;
/**
*/
private int tableNo;
/**
*/
private TableStyle tableStyle;
public Table(Integer tableNo) {
this.tableNo = tableNo;
}
public TableStyle getTableStyle() {
return tableStyle;
}
public void setTableStyle(TableStyle tableStyle) {
this.tableStyle = tableStyle;
}
public Class<? extends BaseRowModel> getClazz() {
return clazz;
}
public void setClazz(Class<? extends BaseRowModel> clazz) {
this.clazz = clazz;
}
public List<List<String>> getHead() {
return head;
}
public void setHead(List<List<String>> head) {
this.head = head;
}
public int getTableNo() {
return tableNo;
}
public void setTableNo(int tableNo) {
this.tableNo = tableNo;
}
}

65
src/main/java/com/alibaba/excel/metadata/TableStyle.java

@ -1,65 +0,0 @@
package com.alibaba.excel.metadata;
import org.apache.poi.ss.usermodel.IndexedColors;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
/**
* @author jipengfei
* @deprecated please use {@link HorizontalCellStyleStrategy}
*/
@Deprecated
public class TableStyle {
/**
* 表头背景颜色
*/
private IndexedColors tableHeadBackGroundColor;
/**
* 表头字体样式
*/
private Font tableHeadFont;
/**
* 表格内容字体样式
*/
private Font tableContentFont;
/**
* 表格内容背景颜色
*/
private IndexedColors tableContentBackGroundColor;
public IndexedColors getTableHeadBackGroundColor() {
return tableHeadBackGroundColor;
}
public void setTableHeadBackGroundColor(IndexedColors tableHeadBackGroundColor) {
this.tableHeadBackGroundColor = tableHeadBackGroundColor;
}
public Font getTableHeadFont() {
return tableHeadFont;
}
public void setTableHeadFont(Font tableHeadFont) {
this.tableHeadFont = tableHeadFont;
}
public Font getTableContentFont() {
return tableContentFont;
}
public void setTableContentFont(Font tableContentFont) {
this.tableContentFont = tableContentFont;
}
public IndexedColors getTableContentBackGroundColor() {
return tableContentBackGroundColor;
}
public void setTableContentBackGroundColor(IndexedColors tableContentBackGroundColor) {
this.tableContentBackGroundColor = tableContentBackGroundColor;
}
}

42
src/main/java/com/alibaba/excel/metadata/WriteCellData.java

@ -1,42 +0,0 @@
package com.alibaba.excel.metadata;
import java.util.Date;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import lombok.Data;
/**
* TODO
*
* @author Jiaju Zhuang
*/
@Data
public class WriteCellData<T> extends CellData<T> {
/**
* Support only when writing.{@link CellDataTypeEnum#DATE}
*/
private Date dateValue;
/**
* {@link CellDataTypeEnum#IMAGE}
*/
private ImageData imageDataValue;
/**
* rich text.{@link CellDataTypeEnum#RICH_TEXT_STRING}
*/
private RichTextStringData richTextStringDataValue;
/**
* comment
*/
private CommentData commentData;
/**
* hyper link
*/
private HyperlinkData hyperlinkData;
/**
* sytle
*/
private WriteCellStyle writeCellStyle;
}

76
src/main/java/com/alibaba/excel/metadata/data/CellData.java

@ -0,0 +1,76 @@
package com.alibaba.excel.metadata.data;
import java.math.BigDecimal;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.AbstractCell;
import com.alibaba.excel.util.StringUtils;
import lombok.Data;
/**
* Excel internal cell data.
*
* <p>
*
* @author Jiaju Zhuang
*/
@Data
public class CellData<T> extends AbstractCell {
/**
* cell type
*/
private CellDataTypeEnum type;
/**
* {@link CellDataTypeEnum#NUMBER}
*/
private BigDecimal numberValue;
/**
* {@link CellDataTypeEnum#STRING} and{@link CellDataTypeEnum#ERROR}
*/
private String stringValue;
/**
* {@link CellDataTypeEnum#BOOLEAN}
*/
private Boolean booleanValue;
/**
* The resulting converted data.
*/
private T data;
/**
* formula
*/
private FormulaData formulaData;
/**
* Ensure that the object does not appear null
*/
public void checkEmpty() {
if (type == null) {
type = CellDataTypeEnum.EMPTY;
}
switch (type) {
case STRING:
case ERROR:
if (StringUtils.isEmpty(stringValue)) {
type = CellDataTypeEnum.EMPTY;
}
return;
case NUMBER:
if (numberValue == null) {
type = CellDataTypeEnum.EMPTY;
}
return;
case BOOLEAN:
if (booleanValue == null) {
type = CellDataTypeEnum.EMPTY;
}
return;
default:
}
}
}

40
src/main/java/com/alibaba/excel/metadata/ClientAnchorData.java → src/main/java/com/alibaba/excel/metadata/data/ClientAnchorData.java

@ -1,4 +1,4 @@
package com.alibaba.excel.metadata;
package com.alibaba.excel.metadata.data;
import lombok.Data;
import org.apache.poi.ss.usermodel.ClientAnchor;
@ -21,47 +21,27 @@ import org.apache.poi.util.Internal;
* @author Jiaju Zhuang
*/
@Data
public class ClientAnchorData {
/**
* The x coordinate within the first cell.
*/
private int dx1;
/**
* The y coordinate within the first cell.
*/
private int dy1;
/**
* The x coordinate within the second cell.
*/
private int dx2;
public class ClientAnchorData extends CoordinateData {
/**
* The y coordinate within the second cell
* top
*/
private int dy2;
private Integer top;
/**
* 0-based column of the first cell.
* right
*/
private short col1;
private Integer right;
/**
* 0-based row of the first cell.
* bottom
*/
private int row1;
private Integer bottom;
/**
* 0-based column of the second cell.
* left
*/
private short col2;
private Integer left;
/**
* 0-based row of the second cell.
*/
private int row2;
/**
* anchor type
*/

4
src/main/java/com/alibaba/excel/metadata/CommentData.java → src/main/java/com/alibaba/excel/metadata/data/CommentData.java

@ -1,9 +1,9 @@
package com.alibaba.excel.metadata;
package com.alibaba.excel.metadata.data;
import lombok.Data;
/**
* TODO
* comment
*
* @author Jiaju Zhuang
*/

28
src/main/java/com/alibaba/excel/metadata/data/CoordinateData.java

@ -0,0 +1,28 @@
package com.alibaba.excel.metadata.data;
import lombok.Data;
/**
* coordinate.
*
* @author Jiaju Zhuang
*/
@Data
public class CoordinateData {
/**
* first row index
*/
private Integer firstRowIndex;
/**
* first column index
*/
private Integer firstColumnIndex;
/**
* last row index
*/
private Integer lastRowIndex;
/**
* last column index
*/
private Integer lastColumnIndex;
}

5
src/main/java/com/alibaba/excel/metadata/DataFormat.java → src/main/java/com/alibaba/excel/metadata/data/DataFormatData.java

@ -1,4 +1,4 @@
package com.alibaba.excel.metadata;
package com.alibaba.excel.metadata.data;
import lombok.Data;
@ -8,11 +8,12 @@ import lombok.Data;
* @author Jiaju Zhuang
*/
@Data
public class DataFormat {
public class DataFormatData {
/**
* index
*/
private Short index;
/**
* format
*/

2
src/main/java/com/alibaba/excel/metadata/FormulaData.java → src/main/java/com/alibaba/excel/metadata/data/FormulaData.java

@ -1,4 +1,4 @@
package com.alibaba.excel.metadata;
package com.alibaba.excel.metadata.data;
import lombok.Data;

53
src/main/java/com/alibaba/excel/metadata/data/HyperlinkData.java

@ -0,0 +1,53 @@
package com.alibaba.excel.metadata.data;
import lombok.Data;
/**
* hyperlink
*
* @author Jiaju Zhuang
*/
@Data
public class HyperlinkData extends CoordinateData {
/**
* Depending on the hyperlink type it can be URL, e-mail, path to a file, etc
*/
private String address;
/**
* hyperlink type
*/
private HyperlinkType hyperlinkType;
public enum HyperlinkType {
/**
* Not a hyperlink
*/
NONE(-1),
/**
* Link to an existing file or web page
*/
URL(1),
/**
* Link to a place in this document
*/
DOCUMENT(2),
/**
* Link to an E-mail address
*/
EMAIL(3),
/**
* Link to a file
*/
FILE(4);
public final int value;
HyperlinkType(int value) {
this.value = value;
}
}
}

2
src/main/java/com/alibaba/excel/metadata/ImageData.java → src/main/java/com/alibaba/excel/metadata/data/ImageData.java

@ -1,4 +1,4 @@
package com.alibaba.excel.metadata;
package com.alibaba.excel.metadata.data;
import lombok.Data;

111
src/main/java/com/alibaba/excel/metadata/data/ReadCellData.java

@ -0,0 +1,111 @@
package com.alibaba.excel.metadata.data;
import java.math.BigDecimal;
import com.alibaba.excel.enums.CellDataTypeEnum;
import lombok.Data;
/**
* read cell data
*
* @author Jiaju Zhuang
*/
@Data
public class ReadCellData<T> extends CellData<T> {
/**
* data format.
*/
private DataFormatData dataFormatData;
public ReadCellData(CellDataTypeEnum type) {
super();
if (type == null) {
throw new IllegalArgumentException("Type can not be null");
}
setType(type);
}
public ReadCellData(T data) {
super();
setData(data);
}
public ReadCellData(String stringValue) {
this(CellDataTypeEnum.STRING, stringValue);
}
public ReadCellData(CellDataTypeEnum type, String stringValue) {
super();
if (type != CellDataTypeEnum.STRING && type != CellDataTypeEnum.ERROR) {
throw new IllegalArgumentException("Only support CellDataTypeEnum.STRING and CellDataTypeEnum.ERROR");
}
if (stringValue == null) {
throw new IllegalArgumentException("StringValue can not be null");
}
setType(type);
setStringValue(stringValue);
}
public ReadCellData(BigDecimal numberValue) {
super();
if (numberValue == null) {
throw new IllegalArgumentException("DoubleValue can not be null");
}
setType(CellDataTypeEnum.NUMBER);
setNumberValue(numberValue);
}
public ReadCellData(Boolean booleanValue) {
super();
if (booleanValue == null) {
throw new IllegalArgumentException("BooleanValue can not be null");
}
setType(CellDataTypeEnum.BOOLEAN);
setBooleanValue(booleanValue);
}
public static ReadCellData<?> newEmptyInstance() {
return newEmptyInstance(null, null);
}
public static ReadCellData<?> newEmptyInstance(Integer rowIndex, Integer columnIndex) {
ReadCellData<?> cellData = new ReadCellData<>(CellDataTypeEnum.EMPTY);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static ReadCellData<?> newInstance(Boolean booleanValue) {
return newInstance(booleanValue, null, null);
}
public static ReadCellData<?> newInstance(Boolean booleanValue, Integer rowIndex, Integer columnIndex) {
ReadCellData<?> cellData = new ReadCellData<>(booleanValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static ReadCellData<?> newInstance(String stringValue, Integer rowIndex, Integer columnIndex) {
ReadCellData<?> cellData = new ReadCellData<>(stringValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
public static ReadCellData<?> newInstance(BigDecimal numberValue, Integer rowIndex, Integer columnIndex) {
ReadCellData<?> cellData = new ReadCellData<>(numberValue);
cellData.setRowIndex(rowIndex);
cellData.setColumnIndex(columnIndex);
return cellData;
}
@Override
public ReadCellData<Object> clone(){
return new ReadCellData<>("");
}
}

2
src/main/java/com/alibaba/excel/metadata/RichTextStringData.java → src/main/java/com/alibaba/excel/metadata/data/RichTextStringData.java

@ -1,4 +1,4 @@
package com.alibaba.excel.metadata;
package com.alibaba.excel.metadata.data;
import java.util.List;

101
src/main/java/com/alibaba/excel/metadata/data/WriteCellData.java

@ -0,0 +1,101 @@
package com.alibaba.excel.metadata.data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import lombok.Data;
/**
* wirte cell data
*
* @author Jiaju Zhuang
*/
@Data
public class WriteCellData<T> extends CellData<T> {
/**
* Support only when writing.{@link CellDataTypeEnum#DATE}
*/
private Date dateValue;
/**
* rich text.{@link CellDataTypeEnum#RICH_TEXT_STRING}
*/
private RichTextStringData richTextStringDataValue;
/**
* image
*/
private List<ImageData> imageDataList;
/**
* comment
*/
private CommentData commentData;
/**
* hyper link
*/
private HyperlinkData hyperlinkData;
/**
* sytle
*/
private WriteCellStyle writeCellStyle;
public WriteCellData(String stringValue) {
this(CellDataTypeEnum.STRING, stringValue);
}
public WriteCellData(CellDataTypeEnum type, String stringValue) {
super();
if (type != CellDataTypeEnum.STRING && type != CellDataTypeEnum.ERROR) {
throw new IllegalArgumentException("Only support CellDataTypeEnum.STRING and CellDataTypeEnum.ERROR");
}
if (stringValue == null) {
throw new IllegalArgumentException("StringValue can not be null");
}
setType(type);
setStringValue(stringValue);
}
public WriteCellData(BigDecimal numberValue) {
super();
if (numberValue == null) {
throw new IllegalArgumentException("DoubleValue can not be null");
}
setType(CellDataTypeEnum.NUMBER);
setNumberValue(numberValue);
}
public WriteCellData(Boolean booleanValue) {
super();
if (booleanValue == null) {
throw new IllegalArgumentException("BooleanValue can not be null");
}
setType(CellDataTypeEnum.BOOLEAN);
setBooleanValue(booleanValue);
}
public WriteCellData(Date dateValue) {
super();
if (dateValue == null) {
throw new IllegalArgumentException("DateValue can not be null");
}
setType(CellDataTypeEnum.DATE);
this.dateValue = dateValue;
}
public WriteCellData(byte[] image) {
super();
if (image == null) {
throw new IllegalArgumentException("Image can not be null");
}
setType(CellDataTypeEnum.EMPTY);
this.imageDataList= ListUtils.newArrayList();
ImageData imageData = new ImageData();
imageData.setImage(image);
imageDataList.add(imageData);
}
}

58
src/main/java/com/alibaba/excel/parameter/AnalysisParam.java

@ -1,58 +0,0 @@
package com.alibaba.excel.parameter;
import com.alibaba.excel.support.ExcelTypeEnum;
import java.io.InputStream;
/**
*
* @author jipengfei
*/
@Deprecated
public class AnalysisParam {
/**
* @see ExcelTypeEnum
*/
private ExcelTypeEnum excelTypeEnum;
/**
* the POI filesystem that contains the Workbook stream
*/
private InputStream in;
/**
* user defined param to listener use
*/
private Object customContent;
public AnalysisParam(InputStream in, ExcelTypeEnum excelTypeEnum, Object customContent) {
this.in = in;
this.excelTypeEnum = excelTypeEnum;
this.customContent = customContent;
}
public ExcelTypeEnum getExcelTypeEnum() {
return excelTypeEnum;
}
public void setExcelTypeEnum(ExcelTypeEnum excelTypeEnum) {
this.excelTypeEnum = excelTypeEnum;
}
public Object getCustomContent() {
return customContent;
}
public void setCustomContent(Object customContent) {
this.customContent = customContent;
}
public InputStream getIn() {
return in;
}
public void setIn(InputStream in) {
this.in = in;
}
}

71
src/main/java/com/alibaba/excel/parameter/GenerateParam.java

@ -1,71 +0,0 @@
package com.alibaba.excel.parameter;
import java.io.OutputStream;
import com.alibaba.excel.support.ExcelTypeEnum;
/**
* Created by jipengfei on 17/2/19.
*
* @author jipengfei
* @deprecated please use {@link com.alibaba.excel.write.builder.ExcelWriterBuilder} build ExcelWriter
*/
@Deprecated
public class GenerateParam {
private OutputStream outputStream;
private String sheetName;
private Class clazz;
private ExcelTypeEnum type;
private boolean needHead = true;
public GenerateParam(String sheetName, Class clazz, OutputStream outputStream) {
this.outputStream = outputStream;
this.sheetName = sheetName;
this.clazz = clazz;
}
public OutputStream getOutputStream() {
return outputStream;
}
public void setOutputStream(OutputStream outputStream) {
this.outputStream = outputStream;
}
public String getSheetName() {
return sheetName;
}
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
public Class getClazz() {
return clazz;
}
public void setClazz(Class clazz) {
this.clazz = clazz;
}
public ExcelTypeEnum getType() {
return type;
}
public void setType(ExcelTypeEnum type) {
this.type = type;
}
public boolean isNeedHead() {
return needHead;
}
public void setNeedHead(boolean needHead) {
this.needHead = needHead;
}
}

38
src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java

@ -1,23 +1,21 @@
package com.alibaba.excel.read.listener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.enums.HeadKindEnum;
import com.alibaba.excel.event.AbstractIgnoreExceptionReadListener;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
import com.alibaba.excel.read.metadata.property.ExcelReadHeadProperty;
import com.alibaba.excel.util.ConverterUtils;
import com.alibaba.excel.util.FieldUtils;
import com.alibaba.excel.util.MapUtils;
import net.sf.cglib.beans.BeanMap;
@ -26,13 +24,13 @@ import net.sf.cglib.beans.BeanMap;
*
* @author jipengfei
*/
public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener<Map<Integer, CellData<?>>> {
public class ModelBuildEventListener implements ReadListener<Map<Integer, ReadCellData<?>>> {
@Override
public void invokeHead(Map<Integer, CellData<?>> cellDataMap, AnalysisContext context) {}
public void invokeHead(Map<Integer, ReadCellData<?>> cellDataMap, AnalysisContext context) {}
@Override
public void invoke(Map<Integer, CellData<?>> cellDataMap, AnalysisContext context) {
public void invoke(Map<Integer, ReadCellData<?>> cellDataMap, AnalysisContext context) {
ReadSheetHolder readSheetHolder = context.readSheetHolder();
if (HeadKindEnum.CLASS.equals(readSheetHolder.excelReadHeadProperty().getHeadKind())) {
context.readRowHolder()
@ -42,14 +40,14 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
context.readRowHolder().setCurrentRowAnalysisResult(buildStringList(cellDataMap, readSheetHolder, context));
}
private Object buildStringList(Map<Integer, CellData<?>> cellDataMap, ReadSheetHolder readSheetHolder,
private Object buildStringList(Map<Integer, ReadCellData<?>> cellDataMap, ReadSheetHolder readSheetHolder,
AnalysisContext context) {
int index = 0;
if (context.readWorkbookHolder().getDefaultReturnMap()) {
Map<Integer, String> map = new LinkedHashMap<Integer, String>(cellDataMap.size() * 4 / 3 + 1);
for (Map.Entry<Integer, CellData<?>> entry : cellDataMap.entrySet()) {
Map<Integer, String> map = MapUtils.newLinkedHashMapWithExpectedSize(cellDataMap.size());
for (Map.Entry<Integer, ReadCellData<?>> entry : cellDataMap.entrySet()) {
Integer key = entry.getKey();
CellData cellData = entry.getValue();
ReadCellData<?> cellData = entry.getValue();
while (index < key) {
map.put(index, null);
index++;
@ -61,7 +59,7 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
}
map.put(key,
(String)ConverterUtils.convertToJavaObject(cellData, null, null, readSheetHolder.converterMap(),
readSheetHolder, context.readRowHolder().getRowIndex(), key));
context, context.readRowHolder().getRowIndex(), key));
}
int headSize = readSheetHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) {
@ -72,9 +70,9 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
} else {
// Compatible with the old code the old code returns a list
List<String> list = new ArrayList<>();
for (Map.Entry<Integer, CellData<?>> entry : cellDataMap.entrySet()) {
for (Map.Entry<Integer, ReadCellData<?>> entry : cellDataMap.entrySet()) {
Integer key = entry.getKey();
CellData<?> cellData = entry.getValue();
ReadCellData<?> cellData = entry.getValue();
while (index < key) {
list.add(null);
index++;
@ -86,7 +84,7 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
}
list.add(
(String)ConverterUtils.convertToJavaObject(cellData, null, null, readSheetHolder.converterMap(),
readSheetHolder, context.readRowHolder().getRowIndex(), key));
context, context.readRowHolder().getRowIndex(), key));
}
int headSize = readSheetHolder.excelReadHeadProperty().getHeadMap().size();
while (index < headSize) {
@ -97,7 +95,7 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
}
}
private Object buildUserModel(Map<Integer, CellData<?>> cellDataMap, ReadSheetHolder readSheetHolder,
private Object buildUserModel(Map<Integer, ReadCellData<?>> cellDataMap, ReadSheetHolder readSheetHolder,
AnalysisContext context) {
ExcelReadHeadProperty excelReadHeadProperty = readSheetHolder.excelReadHeadProperty();
Object resultModel;
@ -105,24 +103,24 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener
resultModel = excelReadHeadProperty.getHeadClazz().newInstance();
} catch (Exception e) {
throw new ExcelDataConvertException(context.readRowHolder().getRowIndex(), 0,
new CellData<>(CellDataTypeEnum.EMPTY), null,
new ReadCellData<>(CellDataTypeEnum.EMPTY), null,
"Can not instance class: " + excelReadHeadProperty.getHeadClazz().getName(), e);
}
Map<Integer, Head> headMap = excelReadHeadProperty.getHeadMap();
Map<String, Object> map = new HashMap<String, Object>(headMap.size() * 4 / 3 + 1);
Map<String, Object> map = MapUtils.newHashMapWithExpectedSize(headMap.size());
Map<Integer, ExcelContentProperty> contentPropertyMap = excelReadHeadProperty.getContentPropertyMap();
for (Map.Entry<Integer, Head> entry : headMap.entrySet()) {
Integer index = entry.getKey();
if (!cellDataMap.containsKey(index)) {
continue;
}
CellData<?> cellData = cellDataMap.get(index);
ReadCellData<?> cellData = cellDataMap.get(index);
if (cellData.getType() == CellDataTypeEnum.EMPTY) {
continue;
}
ExcelContentProperty excelContentProperty = contentPropertyMap.get(index);
Object value = ConverterUtils.convertToJavaObject(cellData, excelContentProperty.getField(),
excelContentProperty, readSheetHolder.converterMap(), readSheetHolder,
excelContentProperty, readSheetHolder.converterMap(), context,
context.readRowHolder().getRowIndex(), index);
if (value != null) {
map.put(FieldUtils.resolveCglibFieldName(excelContentProperty.getField()), value);

24
src/main/java/com/alibaba/excel/read/listener/ReadListener.java

@ -4,8 +4,8 @@ import java.util.Map;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.Listener;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.CellExtra;
import com.alibaba.excel.metadata.data.ReadCellData;
/**
* Interface to listen for read results
@ -21,7 +21,7 @@ public interface ReadListener<T> extends Listener {
* @param context
* @throws Exception
*/
void onException(Exception exception, AnalysisContext context) throws Exception;
default void onException(Exception exception, AnalysisContext context) throws Exception {}
/**
* When analysis one head row trigger invoke function.
@ -29,27 +29,23 @@ public interface ReadListener<T> extends Listener {
* @param headMap
* @param context
*/
void invokeHead(Map<Integer, CellData<?>> headMap, AnalysisContext context);
default void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {}
/**
* When analysis one row trigger invoke function.
*
* @param data
* one row value. Is is same as {@link AnalysisContext#readRowHolder()}
* @param context
* analysis context
* @param data one row value. Is is same as {@link AnalysisContext#readRowHolder()}
* @param context analysis context
*/
void invoke(T data, AnalysisContext context);
/**
* The current method is called when extra information is returned
*
* @param extra
* extra information
* @param context
* analysis context
* @param extra extra information
* @param context analysis context
*/
void extra(CellExtra extra, AnalysisContext context);
default void extra(CellExtra extra, AnalysisContext context) {}
/**
* if have something to do after all analysis
@ -64,5 +60,7 @@ public interface ReadListener<T> extends Listener {
* @param context
* @return
*/
boolean hasNext(AnalysisContext context);
default boolean hasNext(AnalysisContext context) {
return true;
}
}

21
src/main/java/com/alibaba/excel/read/metadata/ReadBasicParameter.java

@ -6,11 +6,14 @@ import java.util.List;
import com.alibaba.excel.metadata.BasicParameter;
import com.alibaba.excel.read.listener.ReadListener;
import lombok.Data;
/**
* Read basic parameter
*
* @author Jiaju Zhuang
**/
@Data
public class ReadBasicParameter extends BasicParameter {
/**
* Count the number of added heads when read sheet.
@ -26,21 +29,9 @@ public class ReadBasicParameter extends BasicParameter {
/**
* Custom type listener run after default
*/
private List<ReadListener> customReadListenerList = new ArrayList<ReadListener>();
public Integer getHeadRowNumber() {
return headRowNumber;
}
public void setHeadRowNumber(Integer headRowNumber) {
this.headRowNumber = headRowNumber;
}
public List<ReadListener> getCustomReadListenerList() {
return customReadListenerList;
}
private List<ReadListener<?>> customReadListenerList;
public void setCustomReadListenerList(List<ReadListener> customReadListenerList) {
this.customReadListenerList = customReadListenerList;
public ReadBasicParameter() {
customReadListenerList = new ArrayList<>();
}
}

4
src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java

@ -42,7 +42,7 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
/**
* Read listener
*/
private List<ReadListener> readListenerList;
private List<ReadListener<?>> readListenerList;
public AbstractReadHolder(ReadBasicParameter readBasicParameter, AbstractReadHolder parentAbstractReadHolder,
Boolean convertAllFiled) {
@ -114,7 +114,7 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
@Override
public List<ReadListener> readListenerList() {
public List<ReadListener<?>> readListenerList() {
return getReadListenerList();
}

2
src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java

@ -18,7 +18,7 @@ public interface ReadHolder extends ConfigurationHolder {
*
* @return Current {@link ReadListener}
*/
List<ReadListener> readListenerList();
List<ReadListener<?>> readListenerList();
/**
* What {@link ExcelReadHeadProperty} does the currently operated cell need to execute

90
src/main/java/com/alibaba/excel/read/metadata/holder/ReadSheetHolder.java

@ -5,15 +5,18 @@ import java.util.Map;
import com.alibaba.excel.enums.HolderEnum;
import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.CellExtra;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.metadata.ReadSheet;
import lombok.Data;
/**
* sheet holder
*
* @author Jiaju Zhuang
*/
@Data
public class ReadSheetHolder extends AbstractReadHolder {
/**
@ -51,7 +54,7 @@ public class ReadSheetHolder extends AbstractReadHolder {
/**
* Current CellData
*/
private CellData<?> tempCellData;
private ReadCellData<?> tempCellData;
public ReadSheetHolder(ReadSheet readSheet, ReadWorkbookHolder readWorkbookHolder) {
super(readSheet, readWorkbookHolder, readWorkbookHolder.getReadWorkbook().getConvertAllFiled());
@ -59,42 +62,10 @@ public class ReadSheetHolder extends AbstractReadHolder {
this.parentReadWorkbookHolder = readWorkbookHolder;
this.sheetNo = readSheet.getSheetNo();
this.sheetName = readSheet.getSheetName();
this.cellMap = new LinkedHashMap<Integer, Cell>();
this.cellMap = new LinkedHashMap<>();
this.rowIndex = -1;
}
public ReadSheet getReadSheet() {
return readSheet;
}
public void setReadSheet(ReadSheet readSheet) {
this.readSheet = readSheet;
}
public ReadWorkbookHolder getParentReadWorkbookHolder() {
return parentReadWorkbookHolder;
}
public void setParentReadWorkbookHolder(ReadWorkbookHolder parentReadWorkbookHolder) {
this.parentReadWorkbookHolder = parentReadWorkbookHolder;
}
public Integer getSheetNo() {
return sheetNo;
}
public void setSheetNo(Integer sheetNo) {
this.sheetNo = sheetNo;
}
public String getSheetName() {
return sheetName;
}
public void setSheetName(String sheetName) {
this.sheetName = sheetName;
}
/**
* Approximate total number of rows
*
@ -106,58 +77,9 @@ public class ReadSheetHolder extends AbstractReadHolder {
return approximateTotalRowNumber;
}
/**
* Approximate total number of rows
*
* @return
*/
public Integer getApproximateTotalRowNumber() {
return approximateTotalRowNumber;
}
public void setApproximateTotalRowNumber(Integer approximateTotalRowNumber) {
this.approximateTotalRowNumber = approximateTotalRowNumber;
}
public Map<Integer, Cell> getCellMap() {
return cellMap;
}
public void setCellMap(Map<Integer, Cell> cellMap) {
this.cellMap = cellMap;
}
public Integer getRowIndex() {
return rowIndex;
}
public void setRowIndex(Integer rowIndex) {
this.rowIndex = rowIndex;
}
public CellData<?> getTempCellData() {
return tempCellData;
}
public void setTempCellData(CellData<?> tempCellData) {
this.tempCellData = tempCellData;
}
public CellExtra getCellExtra() {
return cellExtra;
}
public void setCellExtra(CellExtra cellExtra) {
this.cellExtra = cellExtra;
}
@Override
public HolderEnum holderType() {
return HolderEnum.SHEET;
}
@Override
public String toString() {
return "ReadSheetHolder{" + "sheetNo=" + sheetNo + ", sheetName='" + sheetName + '\'' + "} " + super.toString();
}
}

2
src/main/java/com/alibaba/excel/read/processor/DefaultAnalysisEventProcessor.java

@ -12,7 +12,7 @@ import com.alibaba.excel.enums.HeadKindEnum;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.exception.ExcelAnalysisStopException;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.read.listener.ReadListener;

3
src/main/java/com/alibaba/excel/util/ClassUtils.java

@ -16,11 +16,8 @@ import java.util.concurrent.ConcurrentHashMap;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.event.Handler;
import com.alibaba.excel.exception.ExcelCommonException;
import com.alibaba.excel.metadata.BaseRowModel;
import com.alibaba.excel.metadata.Holder;
import com.alibaba.excel.write.handler.WriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**

40
src/main/java/com/alibaba/excel/util/ConverterUtils.java

@ -8,11 +8,12 @@ import java.util.Map;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ConverterKeyBuild;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.read.metadata.holder.ReadHolder;
import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
/**
@ -31,13 +32,14 @@ public class ConverterUtils {
* @param context
* @return
*/
public static Map<Integer, String> convertToStringMap(Map<Integer, CellData<?>> cellDataMap, AnalysisContext context) {
public static Map<Integer, String> convertToStringMap(Map<Integer, ReadCellData<?>> cellDataMap,
AnalysisContext context) {
Map<Integer, String> stringMap = MapUtils.newHashMapWithExpectedSize(cellDataMap.size());
ReadSheetHolder readSheetHolder = context.readSheetHolder();
int index = 0;
for (Map.Entry<Integer, CellData<?>> entry : cellDataMap.entrySet()) {
for (Map.Entry<Integer, ReadCellData<?>> entry : cellDataMap.entrySet()) {
Integer key = entry.getKey();
CellData<?> cellData = entry.getValue();
ReadCellData<?> cellData = entry.getValue();
while (index < key) {
stringMap.put(index, null);
index++;
@ -55,7 +57,7 @@ public class ConverterUtils {
}
try {
stringMap.put(key,
(String)(converter.convertToJavaData(cellData, null, readSheetHolder)));
(String)(converter.convertToJavaData(new ReadConverterContext<>(cellData, null, context))));
} catch (Exception e) {
throw new ExcelDataConvertException(context.readRowHolder().getRowIndex(), key, cellData, null,
"Convert data " + cellData + " to String error ", e);
@ -71,14 +73,14 @@ public class ConverterUtils {
* @param field
* @param contentProperty
* @param converterMap
* @param readSheetHolder
* @param context
* @param rowIndex
* @param columnIndex
* @return
*/
public static Object convertToJavaObject(CellData<?> cellData, Field field, ExcelContentProperty contentProperty,
Map<String, Converter<?>> converterMap, ReadSheetHolder readSheetHolder, Integer rowIndex,
Integer columnIndex) {
public static Object convertToJavaObject(ReadCellData<?> cellData, Field field,
ExcelContentProperty contentProperty, Map<String, Converter<?>> converterMap, AnalysisContext context,
Integer rowIndex, Integer columnIndex) {
Class<?> clazz;
if (field == null) {
clazz = String.class;
@ -94,12 +96,13 @@ public class ConverterUtils {
} else {
classGeneric = String.class;
}
CellData<Object> cellDataReturn = new CellData<Object>(cellData);
ReadCellData<Object> cellDataReturn = cellData.clone();
cellDataReturn.setData(doConvertToJavaObject(cellData, classGeneric, contentProperty, converterMap,
readSheetHolder, rowIndex, columnIndex));
context, rowIndex, columnIndex));
return cellDataReturn;
}
return doConvertToJavaObject(cellData, clazz, contentProperty, converterMap, readSheetHolder, rowIndex,
return doConvertToJavaObject(cellData, clazz, contentProperty, converterMap, context, rowIndex,
columnIndex);
}
@ -108,15 +111,14 @@ public class ConverterUtils {
* @param clazz
* @param contentProperty
* @param converterMap
* @param readSheetHolder
* @param context
* @param rowIndex
* @param columnIndex
* @return
*/
private static Object doConvertToJavaObject(CellData<?> cellData, Class<?> clazz,
ExcelContentProperty contentProperty,
Map<String, Converter<?>> converterMap, ReadSheetHolder readSheetHolder, Integer rowIndex,
Integer columnIndex) {
private static Object doConvertToJavaObject(ReadCellData<?> cellData, Class<?> clazz,
ExcelContentProperty contentProperty, Map<String, Converter<?>> converterMap, AnalysisContext context,
Integer rowIndex, Integer columnIndex) {
Converter<?> converter = null;
if (contentProperty != null) {
converter = contentProperty.getConverter();
@ -129,7 +131,7 @@ public class ConverterUtils {
"Converter not found, convert " + cellData.getType() + " to " + clazz.getName());
}
try {
return converter.convertToJavaData(cellData, contentProperty, readSheetHolder);
return converter.convertToJavaData(new ReadConverterContext<>(cellData, contentProperty, context));
} catch (Exception e) {
throw new ExcelDataConvertException(rowIndex, columnIndex, cellData, contentProperty,
"Convert data " + cellData + " to " + clazz + " error ", e);

46
src/main/java/com/alibaba/excel/util/FileTypeUtils.java

@ -0,0 +1,46 @@
package com.alibaba.excel.util;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.excel.metadata.data.ImageData.ImageType;
/**
* file type utils
*
* @author Jiaju Zhuang
*/
public class FileTypeUtils {
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
'f'};
private static final int IMAGE_TYPE_MARK_LENGTH = 28;
private static final Map<String, ImageType> FILE_TYPE_MAP;
static {
FILE_TYPE_MAP = new HashMap<>();
FILE_TYPE_MAP.put("ffd8ff", ImageType.PICTURE_TYPE_JPEG);
FILE_TYPE_MAP.put("89504e47", ImageType.PICTURE_TYPE_PNG);
}
public static ImageType getImageType(byte[] image) {
if (image == null || image.length <= IMAGE_TYPE_MARK_LENGTH) {
return null;
}
byte[] typeMarkByte = new byte[IMAGE_TYPE_MARK_LENGTH];
System.arraycopy(image, 0, typeMarkByte, 0, IMAGE_TYPE_MARK_LENGTH);
return FILE_TYPE_MAP.get(encodeHexStr(typeMarkByte));
}
private static String encodeHexStr(byte[] data) {
final int len = data.length;
final char[] out = new char[len << 1];
// two characters from the hex value.
for (int i = 0, j = 0; i < len; i++) {
out[j++] = DIGITS[(0xF0 & data[i]) >>> 4];
out[j++] = DIGITS[0x0F & data[i]];
}
return new String(out);
}
}

36
src/main/java/com/alibaba/excel/util/MapUtils.java

@ -1,9 +1,7 @@
package com.alibaba.excel.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.LinkedHashMap;
/**
* Map utils
@ -12,6 +10,7 @@ import java.util.Map;
**/
public class MapUtils {
private MapUtils() {}
/**
* Creates a <i>mutable</i>, empty {@code HashMap} instance.
*
@ -44,6 +43,37 @@ public class MapUtils {
return new HashMap<>(capacity(expectedSize));
}
/**
* Creates a <i>mutable</i>, empty, insertion-ordered {@code LinkedHashMap} instance.
*
* <p><b>Note:</b> if mutability is not required, use {@link ImmutableMap#of()} instead.
*
* <p><b>Note for Java 7 and later:</b> this method is now unnecessary and should be treated as
* deprecated. Instead, use the {@code LinkedHashMap} constructor directly, taking advantage of
* the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>.
*
* @return a new, empty {@code LinkedHashMap}
*/
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() {
return new LinkedHashMap<>();
}
/**
* Creates a {@code LinkedHashMap} instance, with a high enough "initial capacity" that it
* <i>should</i> hold {@code expectedSize} elements without growth. This behavior cannot be
* broadly guaranteed, but it is observed to be true for OpenJDK 1.7. It also can't be guaranteed
* that the method isn't inadvertently <i>oversizing</i> the returned map.
*
* @param expectedSize the number of entries you expect to add to the returned map
* @return a new, empty {@code LinkedHashMap} with enough capacity to hold {@code expectedSize}
* entries without resizing
* @throws IllegalArgumentException if {@code expectedSize} is negative
* @since 19.0
*/
public static <K, V> LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) {
return new LinkedHashMap<>(capacity(expectedSize));
}
/**
* Returns a capacity that is sufficient to keep the map from being resized as long as it grows no
* larger than expectedSize and the load factor is its default (0.75).

16
src/main/java/com/alibaba/excel/util/NumberUtils.java

@ -5,9 +5,8 @@ import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.ParseException;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.write.metadata.holder.WriteHolder;
/**
* Number utils
@ -47,8 +46,8 @@ public class NumberUtils {
* @param contentProperty
* @return
*/
public static CellData<?> formatToCellDataString(Number num, ExcelContentProperty contentProperty) {
return new CellData<>(format(num, contentProperty));
public static WriteCellData<?> formatToCellDataString(Number num, ExcelContentProperty contentProperty) {
return new WriteCellData<>(format(num, contentProperty));
}
/**
@ -56,16 +55,13 @@ public class NumberUtils {
*
* @param num
* @param contentProperty
* @param currentWriteHolder
* @return
*/
public static CellData<?> formatToCellData(Number num, ExcelContentProperty contentProperty,
WriteHolder currentWriteHolder) {
CellData<?> cellData = new CellData<>(BigDecimal.valueOf(num.doubleValue()));
public static WriteCellData<?> formatToCellData(Number num, ExcelContentProperty contentProperty) {
WriteCellData<?> cellData = new WriteCellData<>(BigDecimal.valueOf(num.doubleValue()));
if (contentProperty != null && contentProperty.getNumberFormatProperty() != null
&& StringUtils.isNotBlank(contentProperty.getNumberFormatProperty().getFormat())) {
WorkBookUtil.fillDataFormat(cellData, currentWriteHolder,
contentProperty.getNumberFormatProperty().getFormat());
WorkBookUtil.fillDataFormat(cellData, contentProperty.getNumberFormatProperty().getFormat());
}
return cellData;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save