From a9f12c078b5ad60a36904d24fbc9d548ed950491 Mon Sep 17 00:00:00 2001 From: zhuangjiaju Date: Tue, 30 Jul 2019 10:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=BB=E5=86=99=E7=9A=84?= =?UTF-8?q?=E5=86=99=E6=B3=95=EF=BC=8C=E6=96=B9=E4=BE=BF=E8=AF=BB=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 ---- .../excel/analysis/v07/XlsxSaxAnalyser.java | 2 ++ .../v07/handlers/DefaultCellHandler.java | 15 ++++++-- .../excel/annotation/ExcelProperty.java | 16 +++++++-- .../excel/converters/AutoConverter.java | 36 +++++++++++++++++++ .../alibaba/excel/converters/Converter.java | 19 ++++++---- .../BigDecimalBooleanConverter.java | 7 ++-- .../bigdecimal/BigDecimalNumberConverter.java | 7 ++-- .../bigdecimal/BigDecimalStringConverter.java | 7 ++-- .../BooleanBooleanConverter.java | 7 ++-- .../BooleanNumberConverter.java | 7 ++-- .../BooleanStringConverter.java | 7 ++-- .../byteconverter/ByteBooleanConverter.java | 7 ++-- .../byteconverter/ByteNumberConverter.java | 7 ++-- .../byteconverter/ByteStringConverter.java | 7 ++-- .../converters/date/DateNumberConverter.java | 15 ++++---- .../converters/date/DateStringConverter.java | 7 ++-- .../DoubleBooleanConverter.java | 7 ++-- .../DoubleNumberConverter.java | 7 ++-- .../DoubleStringConverter.java | 7 ++-- .../floatconverter/FloatBooleanConverter.java | 7 ++-- .../floatconverter/FloatNumberConverter.java | 7 ++-- .../floatconverter/FloatStringConverter.java | 7 ++-- .../integer/IntegerBooleanConverter.java | 7 ++-- .../integer/IntegerNumberConverter.java | 7 ++-- .../integer/IntegerStringConverter.java | 7 ++-- .../longconverter/LongBooleanConverter.java | 7 ++-- .../longconverter/LongNumberConverter.java | 7 ++-- .../longconverter/LongStringConverter.java | 7 ++-- .../shortconverter/ShortBooleanConverter.java | 7 ++-- .../shortconverter/ShortNumberConverter.java | 7 ++-- .../shortconverter/ShortStringConverter.java | 7 ++-- .../string/StringBooleanConverter.java | 7 ++-- .../string/StringErrorConverter.java | 7 ++-- .../string/StringNumberConverter.java | 7 ++-- .../string/StringStringConverter.java | 7 ++-- .../excel/metadata/AbstractHolder.java | 2 +- .../excel/metadata/ConfigurationHolder.java | 36 +++++++++++++++++++ .../com/alibaba/excel/metadata/Holder.java | 30 ++-------------- .../property/ExcelContentProperty.java | 21 +++++------ .../metadata/property/ExcelHeadProperty.java | 14 ++++++++ .../excel/parameter/GenerateParam.java | 3 +- .../listener/ModelBuildEventListener.java | 22 ++++++++---- .../listener/ReadListenerRegistryCenter.java | 1 + .../listener/event/AnalysisFinishEvent.java | 11 ++++++ .../metadata/holder/AbstractReadHolder.java | 2 +- .../read/metadata/holder/ReadHolder.java | 12 +++---- .../read/metadata/holder/ReadRowHolder.java | 9 ++++- .../com/alibaba/excel/util/WorkBookUtil.java | 2 +- .../alibaba/excel/write/ExcelBuilderImpl.java | 13 ++++--- .../write/metadata/holder/WriteHolder.java | 14 ++++---- 51 files changed, 351 insertions(+), 154 deletions(-) create mode 100644 src/main/java/com/alibaba/excel/converters/AutoConverter.java create mode 100644 src/main/java/com/alibaba/excel/metadata/ConfigurationHolder.java diff --git a/pom.xml b/pom.xml index 9ccb242f..6bbbf7e1 100644 --- a/pom.xml +++ b/pom.xml @@ -56,13 +56,6 @@ - - - commons-io - commons-io - 2.6 - - org.apache.poi poi diff --git a/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java b/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java index a2f37305..a59060f3 100644 --- a/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java +++ b/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java @@ -83,6 +83,8 @@ public class XlsxSaxAnalyser implements ExcelExecutor { CTWorkbookPr prefix = wb.getWorkbookPr(); if (prefix != null && prefix.getDate1904()) { readWorkbookHolder.getGlobalConfiguration().setUse1904windowing(Boolean.TRUE); + } else { + readWorkbookHolder.getGlobalConfiguration().setUse1904windowing(Boolean.FALSE); } } diff --git a/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java b/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java index 2319f674..985548bf 100644 --- a/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java +++ b/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java @@ -21,6 +21,7 @@ import com.alibaba.excel.read.metadata.holder.ReadRowHolder; import com.alibaba.excel.util.BooleanUtils; import com.alibaba.excel.util.PositionUtils; import com.alibaba.excel.util.StringUtils; + /** * Cell Handler * @@ -84,8 +85,12 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder ensureSize(); // Have to go "sharedStrings.xml" and get it if (currentCellData.getType() == CellDataTypeEnum.STRING) { - currentCellData.setStringValue(analysisContext.readWorkbookHolder().getReadCache() - .get(Integer.valueOf(currentCellData.getStringValue()))); + String stringValue = analysisContext.readWorkbookHolder().getReadCache() + .get(Integer.valueOf(currentCellData.getStringValue())); + if (stringValue != null && analysisContext.currentReadHolder().globalConfiguration().getAutoTrim()) { + stringValue = stringValue.trim(); + } + currentCellData.setStringValue(stringValue); } curRowContent[curCol] = currentCellData; } @@ -93,7 +98,11 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder if (CELL_INLINE_STRING_VALUE_TAG.equals(name)) { ensureSize(); XSSFRichTextString richTextString = new XSSFRichTextString(currentCellData.getStringValue()); - currentCellData.setStringValue(richTextString.toString()); + String stringValue = richTextString.toString(); + if (stringValue != null && analysisContext.currentReadHolder().globalConfiguration().getAutoTrim()) { + stringValue = stringValue.trim(); + } + currentCellData.setStringValue(stringValue); curRowContent[curCol] = currentCellData; } } diff --git a/src/main/java/com/alibaba/excel/annotation/ExcelProperty.java b/src/main/java/com/alibaba/excel/annotation/ExcelProperty.java index a977aa28..bbeb4f3a 100644 --- a/src/main/java/com/alibaba/excel/annotation/ExcelProperty.java +++ b/src/main/java/com/alibaba/excel/annotation/ExcelProperty.java @@ -6,6 +6,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import com.alibaba.excel.converters.AutoConverter; +import com.alibaba.excel.converters.Converter; + /** * @author jipengfei */ @@ -16,10 +19,10 @@ public @interface ExcelProperty { /** * The name of the sheet header. - * + * *
  • write: It automatically merges when you have more than one head *
  • read: When you have multiple heads, take the first one - * + * * @return */ String[] value() default {""}; @@ -28,11 +31,18 @@ public @interface ExcelProperty { * Index of column * * Read or write it on the index of column,If it's equal to -1, it's sorted by Java class - * + * * @return */ int index() default -1; + /** + * Force the current field to use this converter. + * + * @return + */ + Class converter() default AutoConverter.class; + /** * * default @see com.alibaba.excel.util.TypeUtil if default is not meet you can set format diff --git a/src/main/java/com/alibaba/excel/converters/AutoConverter.java b/src/main/java/com/alibaba/excel/converters/AutoConverter.java new file mode 100644 index 00000000..12dbbb30 --- /dev/null +++ b/src/main/java/com/alibaba/excel/converters/AutoConverter.java @@ -0,0 +1,36 @@ +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 zhuangjiaju + */ +public class AutoConverter implements Converter { + + @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; + } +} diff --git a/src/main/java/com/alibaba/excel/converters/Converter.java b/src/main/java/com/alibaba/excel/converters/Converter.java index 16c36eae..3b867cca 100644 --- a/src/main/java/com/alibaba/excel/converters/Converter.java +++ b/src/main/java/com/alibaba/excel/converters/Converter.java @@ -2,13 +2,14 @@ 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; import com.sun.istack.internal.NotNull; import com.sun.istack.internal.Nullable; /** * Convert between Java objects and excel objects - * + * * @author Dan Zheng * @param */ @@ -16,35 +17,39 @@ public interface Converter { /** * Back to object types in Java - * + * * @return */ Class supportJavaTypeKey(); /** * Back to object enum in excel - * + * * @return */ CellDataTypeEnum supportExcelTypeKey(); /** * Convert excel objects to Java objects - * + * * @param cellData * @param contentProperty + * @param globalConfiguration * @return * @throws Exception */ - T convertToJavaData(@NotNull CellData cellData, @Nullable ExcelContentProperty contentProperty) throws Exception; + T convertToJavaData(@NotNull CellData cellData, @Nullable ExcelContentProperty contentProperty, + @NotNull GlobalConfiguration globalConfiguration) throws Exception; /** * Convert Java objects to excel objects - * + * * @param value * @param contentProperty + * @param globalConfiguration * @return * @throws Exception */ - CellData convertToExcelData(@NotNull T value, @Nullable ExcelContentProperty contentProperty) throws Exception; + CellData convertToExcelData(@NotNull T value, @Nullable ExcelContentProperty contentProperty, + @NotNull GlobalConfiguration globalConfiguration) throws Exception; } diff --git a/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalBooleanConverter.java index bba16ac1..7d35d39b 100644 --- a/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalBooleanConverter.java @@ -5,6 +5,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class BigDecimalBooleanConverter implements Converter { } @Override - public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return BigDecimal.ONE; } @@ -33,7 +35,8 @@ public class BigDecimalBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (BigDecimal.ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalNumberConverter.java b/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalNumberConverter.java index 1a21e315..8d61af15 100644 --- a/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalNumberConverter.java @@ -5,6 +5,7 @@ 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.property.ExcelContentProperty; /** @@ -25,12 +26,14 @@ public class BigDecimalNumberConverter implements Converter { } @Override - public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return BigDecimal.valueOf(cellData.getDoubleValue()); } @Override - public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.doubleValue()); } } diff --git a/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalStringConverter.java b/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalStringConverter.java index 4f7c26b9..babdf7fd 100644 --- a/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/bigdecimal/BigDecimalStringConverter.java @@ -5,6 +5,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -26,12 +27,14 @@ public class BigDecimalStringConverter implements Converter { } @Override - public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public BigDecimal convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new BigDecimal(cellData.getStringValue()); } @Override - public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } } diff --git a/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanBooleanConverter.java index 2d014099..294a7544 100644 --- a/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class BooleanBooleanConverter implements Converter { } @Override - public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getBooleanValue(); } @Override - public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value); } diff --git a/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanNumberConverter.java b/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanNumberConverter.java index 02d297fe..9bdf88e5 100644 --- a/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -26,7 +27,8 @@ public class BooleanNumberConverter implements Converter { } @Override - public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(cellData.getDoubleValue())) { return Boolean.TRUE; } @@ -34,7 +36,8 @@ public class BooleanNumberConverter implements Converter { } @Override - public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (value) { return new CellData(ONE); } diff --git a/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanStringConverter.java b/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanStringConverter.java index 6a4fcff6..3b681909 100644 --- a/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/booleanconverter/BooleanStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class BooleanStringConverter implements Converter { } @Override - public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Boolean.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.toString()); } diff --git a/src/main/java/com/alibaba/excel/converters/byteconverter/ByteBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/byteconverter/ByteBooleanConverter.java index cf115e4e..ba4f1836 100644 --- a/src/main/java/com/alibaba/excel/converters/byteconverter/ByteBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/byteconverter/ByteBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class ByteBooleanConverter implements Converter { } @Override - public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return ONE; } @@ -33,7 +35,8 @@ public class ByteBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/byteconverter/ByteNumberConverter.java b/src/main/java/com/alibaba/excel/converters/byteconverter/ByteNumberConverter.java index d80bc3ec..4b676dd4 100644 --- a/src/main/java/com/alibaba/excel/converters/byteconverter/ByteNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/byteconverter/ByteNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class ByteNumberConverter implements Converter { } @Override - public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getDoubleValue().byteValue(); } @Override - public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.doubleValue()); } diff --git a/src/main/java/com/alibaba/excel/converters/byteconverter/ByteStringConverter.java b/src/main/java/com/alibaba/excel/converters/byteconverter/ByteStringConverter.java index 0db51f7d..b9c2a922 100644 --- a/src/main/java/com/alibaba/excel/converters/byteconverter/ByteStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/byteconverter/ByteStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -24,12 +25,14 @@ public class ByteStringConverter implements Converter { } @Override - public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Byte convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Byte.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Byte value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } diff --git a/src/main/java/com/alibaba/excel/converters/date/DateNumberConverter.java b/src/main/java/com/alibaba/excel/converters/date/DateNumberConverter.java index 2a63e57e..125e1649 100644 --- a/src/main/java/com/alibaba/excel/converters/date/DateNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/date/DateNumberConverter.java @@ -7,11 +7,12 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil; 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.property.ExcelContentProperty; /** * Date and number converter - * + * * @author zhuangjiaju */ public class DateNumberConverter implements Converter { @@ -27,13 +28,10 @@ public class DateNumberConverter implements Converter { } @Override - public Date convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Date convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) { - Boolean use1904windowing = Boolean.FALSE; - if (contentProperty != null && contentProperty.getUse1904windowing() != null) { - use1904windowing = contentProperty.getUse1904windowing(); - } - return HSSFDateUtil.getJavaDate(cellData.getDoubleValue(), use1904windowing, null); + return HSSFDateUtil.getJavaDate(cellData.getDoubleValue(), globalConfiguration.getUse1904windowing(), null); } else { return HSSFDateUtil.getJavaDate(cellData.getDoubleValue(), contentProperty.getDateTimeFormatProperty().getUse1904windowing(), null); @@ -41,7 +39,8 @@ public class DateNumberConverter implements Converter { } @Override - public CellData convertToExcelData(Date value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Date value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData((double)(value.getTime())); } } diff --git a/src/main/java/com/alibaba/excel/converters/date/DateStringConverter.java b/src/main/java/com/alibaba/excel/converters/date/DateStringConverter.java index adc79539..6c10aa32 100644 --- a/src/main/java/com/alibaba/excel/converters/date/DateStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/date/DateStringConverter.java @@ -6,6 +6,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.DateUtils; @@ -26,7 +27,8 @@ public class DateStringConverter implements Converter { } @Override - public Date convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) throws ParseException { + public Date convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) throws ParseException { if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) { return DateUtils.parseDate(cellData.getStringValue(), null); } else { @@ -36,7 +38,8 @@ public class DateStringConverter implements Converter { } @Override - public CellData convertToExcelData(Date value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Date value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (contentProperty == null || contentProperty.getDateTimeFormatProperty() == null) { return new CellData(DateUtils.format(value, null)); } else { diff --git a/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleBooleanConverter.java index 83296115..bf04229c 100644 --- a/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class DoubleBooleanConverter implements Converter { } @Override - public Double convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Double convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return ONE; } @@ -33,7 +35,8 @@ public class DoubleBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(Double value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Double value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleNumberConverter.java b/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleNumberConverter.java index 8031498d..89f7df49 100644 --- a/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class DoubleNumberConverter implements Converter { } @Override - public Double convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Double convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getDoubleValue(); } @Override - public CellData convertToExcelData(Double value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Double value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value); } diff --git a/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleStringConverter.java b/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleStringConverter.java index 508fd776..76b6e474 100644 --- a/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/doubleconverter/DoubleStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -24,12 +25,14 @@ public class DoubleStringConverter implements Converter { } @Override - public Double convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Double convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Double.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Double value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Double value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } } diff --git a/src/main/java/com/alibaba/excel/converters/floatconverter/FloatBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/floatconverter/FloatBooleanConverter.java index 789dcbe6..439178d3 100644 --- a/src/main/java/com/alibaba/excel/converters/floatconverter/FloatBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/floatconverter/FloatBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class FloatBooleanConverter implements Converter { } @Override - public Float convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Float convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return ONE; } @@ -33,7 +35,8 @@ public class FloatBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(Float value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Float value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/floatconverter/FloatNumberConverter.java b/src/main/java/com/alibaba/excel/converters/floatconverter/FloatNumberConverter.java index e190d113..4db19528 100644 --- a/src/main/java/com/alibaba/excel/converters/floatconverter/FloatNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/floatconverter/FloatNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class FloatNumberConverter implements Converter { } @Override - public Float convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Float convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getDoubleValue().floatValue(); } @Override - public CellData convertToExcelData(Float value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Float value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.doubleValue()); } diff --git a/src/main/java/com/alibaba/excel/converters/floatconverter/FloatStringConverter.java b/src/main/java/com/alibaba/excel/converters/floatconverter/FloatStringConverter.java index fbf92d2e..fe5bf6a6 100644 --- a/src/main/java/com/alibaba/excel/converters/floatconverter/FloatStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/floatconverter/FloatStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -24,12 +25,14 @@ public class FloatStringConverter implements Converter { } @Override - public Float convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Float convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Float.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Float value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Float value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } } diff --git a/src/main/java/com/alibaba/excel/converters/integer/IntegerBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/integer/IntegerBooleanConverter.java index 0d4a9515..08929ce4 100644 --- a/src/main/java/com/alibaba/excel/converters/integer/IntegerBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/integer/IntegerBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class IntegerBooleanConverter implements Converter { } @Override - public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return ONE; } @@ -33,7 +35,8 @@ public class IntegerBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/integer/IntegerNumberConverter.java b/src/main/java/com/alibaba/excel/converters/integer/IntegerNumberConverter.java index 89763abb..0ce0ae38 100644 --- a/src/main/java/com/alibaba/excel/converters/integer/IntegerNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/integer/IntegerNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class IntegerNumberConverter implements Converter { } @Override - public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getDoubleValue().intValue(); } @Override - public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.doubleValue()); } diff --git a/src/main/java/com/alibaba/excel/converters/integer/IntegerStringConverter.java b/src/main/java/com/alibaba/excel/converters/integer/IntegerStringConverter.java index 329713f0..6b2dd7b4 100644 --- a/src/main/java/com/alibaba/excel/converters/integer/IntegerStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/integer/IntegerStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -24,12 +25,14 @@ public class IntegerStringConverter implements Converter { } @Override - public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Integer.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } } diff --git a/src/main/java/com/alibaba/excel/converters/longconverter/LongBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/longconverter/LongBooleanConverter.java index 0d500e1d..5c943cb5 100644 --- a/src/main/java/com/alibaba/excel/converters/longconverter/LongBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/longconverter/LongBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class LongBooleanConverter implements Converter { } @Override - public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return ONE; } @@ -33,7 +35,8 @@ public class LongBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/longconverter/LongNumberConverter.java b/src/main/java/com/alibaba/excel/converters/longconverter/LongNumberConverter.java index 6b2d756e..642d9a9e 100644 --- a/src/main/java/com/alibaba/excel/converters/longconverter/LongNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/longconverter/LongNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class LongNumberConverter implements Converter { } @Override - public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getDoubleValue().longValue(); } @Override - public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.doubleValue()); } diff --git a/src/main/java/com/alibaba/excel/converters/longconverter/LongStringConverter.java b/src/main/java/com/alibaba/excel/converters/longconverter/LongStringConverter.java index ebcc2117..4954c1cb 100644 --- a/src/main/java/com/alibaba/excel/converters/longconverter/LongStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/longconverter/LongStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -24,12 +25,14 @@ public class LongStringConverter implements Converter { } @Override - public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Long convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Long.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Long value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } } diff --git a/src/main/java/com/alibaba/excel/converters/shortconverter/ShortBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/shortconverter/ShortBooleanConverter.java index 246f2e93..65d53162 100644 --- a/src/main/java/com/alibaba/excel/converters/shortconverter/ShortBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/shortconverter/ShortBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -25,7 +26,8 @@ public class ShortBooleanConverter implements Converter { } @Override - public Short convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Short convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (cellData.getBooleanValue()) { return ONE; } @@ -33,7 +35,8 @@ public class ShortBooleanConverter implements Converter { } @Override - public CellData convertToExcelData(Short value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Short value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { if (ONE.equals(value)) { return new CellData(Boolean.TRUE); } diff --git a/src/main/java/com/alibaba/excel/converters/shortconverter/ShortNumberConverter.java b/src/main/java/com/alibaba/excel/converters/shortconverter/ShortNumberConverter.java index 03435c83..0c539294 100644 --- a/src/main/java/com/alibaba/excel/converters/shortconverter/ShortNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/shortconverter/ShortNumberConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class ShortNumberConverter implements Converter { } @Override - public Short convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Short convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getDoubleValue().shortValue(); } @Override - public CellData convertToExcelData(Short value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Short value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value.doubleValue()); } diff --git a/src/main/java/com/alibaba/excel/converters/shortconverter/ShortStringConverter.java b/src/main/java/com/alibaba/excel/converters/shortconverter/ShortStringConverter.java index 40917b21..c5aa255f 100644 --- a/src/main/java/com/alibaba/excel/converters/shortconverter/ShortStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/shortconverter/ShortStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; import com.alibaba.excel.util.NumberUtils; @@ -24,12 +25,14 @@ public class ShortStringConverter implements Converter { } @Override - public Short convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public Short convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return Short.valueOf(cellData.getStringValue()); } @Override - public CellData convertToExcelData(Short value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(Short value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return NumberUtils.formatToCellData(value, contentProperty); } } diff --git a/src/main/java/com/alibaba/excel/converters/string/StringBooleanConverter.java b/src/main/java/com/alibaba/excel/converters/string/StringBooleanConverter.java index 138df61e..230205bc 100644 --- a/src/main/java/com/alibaba/excel/converters/string/StringBooleanConverter.java +++ b/src/main/java/com/alibaba/excel/converters/string/StringBooleanConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -23,12 +24,14 @@ public class StringBooleanConverter implements Converter { } @Override - public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getBooleanValue().toString(); } @Override - public CellData convertToExcelData(String value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(Boolean.valueOf(value)); } diff --git a/src/main/java/com/alibaba/excel/converters/string/StringErrorConverter.java b/src/main/java/com/alibaba/excel/converters/string/StringErrorConverter.java index 47439a04..8246aae4 100644 --- a/src/main/java/com/alibaba/excel/converters/string/StringErrorConverter.java +++ b/src/main/java/com/alibaba/excel/converters/string/StringErrorConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -22,12 +23,14 @@ public class StringErrorConverter implements Converter { } @Override - public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getStringValue(); } @Override - public CellData convertToExcelData(String value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(CellDataTypeEnum.ERROR, value); } diff --git a/src/main/java/com/alibaba/excel/converters/string/StringNumberConverter.java b/src/main/java/com/alibaba/excel/converters/string/StringNumberConverter.java index 8ad48938..c5144156 100644 --- a/src/main/java/com/alibaba/excel/converters/string/StringNumberConverter.java +++ b/src/main/java/com/alibaba/excel/converters/string/StringNumberConverter.java @@ -5,6 +5,7 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil; 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.property.ExcelContentProperty; import com.alibaba.excel.util.DateUtils; import com.alibaba.excel.util.NumberUtils; @@ -27,7 +28,8 @@ public class StringNumberConverter implements Converter { } @Override - public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { // If there are "DateTimeFormat", read as date if (contentProperty != null && contentProperty.getDateTimeFormatProperty() != null) { return DateUtils.format( @@ -40,7 +42,8 @@ public class StringNumberConverter implements Converter { } @Override - public CellData convertToExcelData(String value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(Double.valueOf(value)); } } diff --git a/src/main/java/com/alibaba/excel/converters/string/StringStringConverter.java b/src/main/java/com/alibaba/excel/converters/string/StringStringConverter.java index 3b2a49d1..f92094ac 100644 --- a/src/main/java/com/alibaba/excel/converters/string/StringStringConverter.java +++ b/src/main/java/com/alibaba/excel/converters/string/StringStringConverter.java @@ -3,6 +3,7 @@ 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.property.ExcelContentProperty; /** @@ -22,12 +23,14 @@ public class StringStringConverter implements Converter { } @Override - public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty) { + public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return cellData.getStringValue(); } @Override - public CellData convertToExcelData(String value, ExcelContentProperty contentProperty) { + public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, + GlobalConfiguration globalConfiguration) { return new CellData(value); } diff --git a/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java b/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java index 7d2edef5..de546ac8 100644 --- a/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java +++ b/src/main/java/com/alibaba/excel/metadata/AbstractHolder.java @@ -10,7 +10,7 @@ import com.alibaba.excel.converters.Converter; * * @author zhuangjiaju */ -public abstract class AbstractHolder implements Holder { +public abstract class AbstractHolder implements ConfigurationHolder { /** * Record whether it's new or from cache */ diff --git a/src/main/java/com/alibaba/excel/metadata/ConfigurationHolder.java b/src/main/java/com/alibaba/excel/metadata/ConfigurationHolder.java new file mode 100644 index 00000000..d83d1a0b --- /dev/null +++ b/src/main/java/com/alibaba/excel/metadata/ConfigurationHolder.java @@ -0,0 +1,36 @@ +package com.alibaba.excel.metadata; + +import java.util.Map; + +import com.alibaba.excel.converters.Converter; + +/** + * + * Get the corresponding holder + * + * @author zhuangjiaju + **/ +public interface ConfigurationHolder extends Holder { + + /** + * + * Record whether it's new or from cache + * + * @return + */ + boolean isNew(); + + /** + * Some global variables + * + * @return + */ + GlobalConfiguration globalConfiguration(); + + /** + * What converter does the currently operated cell need to execute + * + * @return + */ + Map converterMap(); +} diff --git a/src/main/java/com/alibaba/excel/metadata/Holder.java b/src/main/java/com/alibaba/excel/metadata/Holder.java index 15da0dca..e256dc27 100644 --- a/src/main/java/com/alibaba/excel/metadata/Holder.java +++ b/src/main/java/com/alibaba/excel/metadata/Holder.java @@ -1,44 +1,20 @@ package com.alibaba.excel.metadata; -import java.util.Map; - -import com.alibaba.excel.converters.Converter; import com.alibaba.excel.enums.HolderEnum; /** - * + * * Get the corresponding holder - * + * * @author zhuangjiaju **/ public interface Holder { /** * What holder is the return - * + * * @return */ HolderEnum holderType(); - /** - * - * Record whether it's new or from cache - * - * @return - */ - boolean isNew(); - - /** - * Some global variables - * - * @return - */ - GlobalConfiguration globalConfiguration(); - - /** - * What converter does the currently operated cell need to execute - * - * @return - */ - Map converterMap(); } diff --git a/src/main/java/com/alibaba/excel/metadata/property/ExcelContentProperty.java b/src/main/java/com/alibaba/excel/metadata/property/ExcelContentProperty.java index 0bdabeb0..db7a8b96 100644 --- a/src/main/java/com/alibaba/excel/metadata/property/ExcelContentProperty.java +++ b/src/main/java/com/alibaba/excel/metadata/property/ExcelContentProperty.java @@ -2,6 +2,7 @@ package com.alibaba.excel.metadata.property; import java.lang.reflect.Field; +import com.alibaba.excel.converters.Converter; import com.alibaba.excel.metadata.Head; /** @@ -16,17 +17,13 @@ public class ExcelContentProperty { * Excel head */ private Head head; + /** + * Custom defined converters + */ + private Converter converter; private CellStyleProperty cellStyleProperty; private DateTimeFormatProperty dateTimeFormatProperty; private NumberFormatProperty numberFormatProperty; - /** - * true if date uses 1904 windowing, or false if using 1900 date windowing. - * - * default is false - * - * @return - */ - private Boolean use1904windowing; public Field getField() { return field; @@ -68,11 +65,11 @@ public class ExcelContentProperty { this.numberFormatProperty = numberFormatProperty; } - public Boolean getUse1904windowing() { - return use1904windowing; + public Converter getConverter() { + return converter; } - public void setUse1904windowing(Boolean use1904windowing) { - this.use1904windowing = use1904windowing; + public void setConverter(Converter converter) { + this.converter = converter; } } diff --git a/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java b/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java index f7af03b6..4b8fcf4a 100644 --- a/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java +++ b/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java @@ -14,7 +14,10 @@ import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.format.DateTimeFormat; import com.alibaba.excel.annotation.format.NumberFormat; +import com.alibaba.excel.converters.AutoConverter; +import com.alibaba.excel.converters.Converter; import com.alibaba.excel.enums.HeadKindEnum; +import com.alibaba.excel.exception.ExcelCommonException; import com.alibaba.excel.exception.ExcelGenerateException; import com.alibaba.excel.metadata.Head; import com.alibaba.excel.util.StringUtils; @@ -162,6 +165,17 @@ public class ExcelHeadProperty { } Head head = new Head(index, field.getName(), tmpHeadList, forceIndex); ExcelContentProperty excelContentProperty = new ExcelContentProperty(); + if (excelProperty != null && excelProperty.converter() != null) { + Class convertClazz = excelProperty.converter(); + if (convertClazz != AutoConverter.class) { + try { + Converter converter = convertClazz.newInstance(); + excelContentProperty.setConverter(converter); + } catch (Exception e) { + throw new ExcelCommonException("Can not instance custom converter:" + convertClazz.getName()); + } + } + } excelContentProperty.setHead(head); excelContentProperty.setField(field); excelContentProperty diff --git a/src/main/java/com/alibaba/excel/parameter/GenerateParam.java b/src/main/java/com/alibaba/excel/parameter/GenerateParam.java index 0760007e..acbcfbde 100644 --- a/src/main/java/com/alibaba/excel/parameter/GenerateParam.java +++ b/src/main/java/com/alibaba/excel/parameter/GenerateParam.java @@ -6,7 +6,8 @@ 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 diff --git a/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java b/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java index 0603cafb..8f147025 100644 --- a/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java +++ b/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java @@ -13,6 +13,7 @@ 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.GlobalConfiguration; import com.alibaba.excel.metadata.Head; import com.alibaba.excel.metadata.property.ExcelContentProperty; import com.alibaba.excel.read.metadata.holder.ReadHolder; @@ -22,7 +23,7 @@ import net.sf.cglib.beans.BeanMap; /** * Convert to the object the user needs - * + * * @author jipengfei */ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener> { @@ -40,7 +41,8 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener private Object buildStringList(List data, ReadHolder currentReadHolder) { List list = new ArrayList(); for (CellData cellData : data) { - list.add((String)convertValue(cellData, String.class, null, currentReadHolder.converterMap())); + list.add((String)convertValue(cellData, String.class, null, currentReadHolder.converterMap(), + currentReadHolder.globalConfiguration())); } return list; } @@ -54,8 +56,8 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener throw new ExcelDataConvertException( "Can not instance class: " + excelReadHeadProperty.getHeadClazz().getName(), e); } - Map map = new HashMap(); Map headMap = excelReadHeadProperty.getHeadMap(); + Map map = new HashMap(headMap.size() * 4 / 3 + 1); Map contentPropertyMap = excelReadHeadProperty.getContentPropertyMap(); for (Map.Entry entry : headMap.entrySet()) { Integer index = entry.getKey(); @@ -68,7 +70,7 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener } ExcelContentProperty excelContentProperty = contentPropertyMap.get(index); Object value = convertValue(cellData, excelContentProperty.getField().getType(), excelContentProperty, - currentReadHolder.converterMap()); + currentReadHolder.converterMap(), currentReadHolder.globalConfiguration()); if (value != null) { map.put(excelContentProperty.getField().getName(), value); } @@ -78,14 +80,20 @@ public class ModelBuildEventListener extends AbstractIgnoreExceptionReadListener } private Object convertValue(CellData cellData, Class clazz, ExcelContentProperty contentProperty, - Map converterMap) { - Converter converter = converterMap.get(ConverterKeyBuild.buildKey(clazz, cellData.getType())); + Map converterMap, GlobalConfiguration globalConfiguration) { + Converter converter = null; + if (contentProperty != null) { + converter = contentProperty.getConverter(); + } + if (converter == null) { + converter = converterMap.get(ConverterKeyBuild.buildKey(clazz, cellData.getType())); + } if (converter == null) { throw new ExcelDataConvertException( "Converter not found, convert " + cellData.getType() + " to " + clazz.getName()); } try { - return converter.convertToJavaData(cellData, contentProperty); + return converter.convertToJavaData(cellData, contentProperty, globalConfiguration); } catch (Exception e) { throw new ExcelDataConvertException("Convert data " + cellData + " to " + clazz + " error ", e); } diff --git a/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java b/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java index b92a3d1b..58baeae9 100644 --- a/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java +++ b/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java @@ -28,6 +28,7 @@ public interface ReadListenerRegistryCenter { void notifyEndOneRow(AnalysisFinishEvent event, AnalysisContext analysisContext); /** + * Notify after all analysed * * @param analysisContext */ diff --git a/src/main/java/com/alibaba/excel/read/listener/event/AnalysisFinishEvent.java b/src/main/java/com/alibaba/excel/read/listener/event/AnalysisFinishEvent.java index fb935429..e90d9c31 100644 --- a/src/main/java/com/alibaba/excel/read/listener/event/AnalysisFinishEvent.java +++ b/src/main/java/com/alibaba/excel/read/listener/event/AnalysisFinishEvent.java @@ -1,5 +1,16 @@ package com.alibaba.excel.read.listener.event; +/** + * + * Event + * + * @author jipengfei + */ public interface AnalysisFinishEvent { + /** + * Get result + * + * @return + */ Object getAnalysisResult(); } diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java index 257882a7..97cd2822 100644 --- a/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java +++ b/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java @@ -189,7 +189,7 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH "Converter not found, convert " + cellData.getType() + " to String"); } try { - list.add((String)(converter.convertToJavaData(cellData, null))); + list.add((String)(converter.convertToJavaData(cellData, null, readHolder.globalConfiguration()))); } catch (Exception e) { throw new ExcelDataConvertException("Convert data " + cellData + " to String error ", e); } diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java index d235afb5..8a78fbf3 100644 --- a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java +++ b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java @@ -2,27 +2,27 @@ package com.alibaba.excel.read.metadata.holder; import java.util.List; -import com.alibaba.excel.metadata.Holder; +import com.alibaba.excel.metadata.ConfigurationHolder; import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.metadata.property.ExcelReadHeadProperty; /** - * + * * Get the corresponding Holder - * + * * @author zhuangjiaju **/ -public interface ReadHolder extends Holder { +public interface ReadHolder extends ConfigurationHolder { /** * What handler does the currently operated cell need to execute - * + * * @return */ List readListenerList(); /** * What 'ExcelReadHeadProperty' does the currently operated cell need to execute - * + * * @return */ ExcelReadHeadProperty excelReadHeadProperty(); diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadRowHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadRowHolder.java index 467c5a1f..ed9a53da 100644 --- a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadRowHolder.java +++ b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadRowHolder.java @@ -1,13 +1,15 @@ package com.alibaba.excel.read.metadata.holder; +import com.alibaba.excel.enums.HolderEnum; import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.Holder; /** * sheet holder * * @author zhuangjiaju */ -public class ReadRowHolder { +public class ReadRowHolder implements Holder { /** * Returns row index of a row in the sheet that contains this cell.Start form 0. */ @@ -50,4 +52,9 @@ public class ReadRowHolder { public void setRowIndex(int rowIndex) { this.rowIndex = rowIndex; } + + @Override + public HolderEnum holderType() { + return HolderEnum.ROW; + } } diff --git a/src/main/java/com/alibaba/excel/util/WorkBookUtil.java b/src/main/java/com/alibaba/excel/util/WorkBookUtil.java index c65ec8a5..71bbffd6 100644 --- a/src/main/java/com/alibaba/excel/util/WorkBookUtil.java +++ b/src/main/java/com/alibaba/excel/util/WorkBookUtil.java @@ -17,7 +17,7 @@ import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; /** - * + * * @author jipengfei */ public class WorkBookUtil { diff --git a/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java b/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java index 5f5318f0..30faf857 100644 --- a/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java +++ b/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java @@ -76,7 +76,6 @@ public class ExcelBuilderImpl implements ExcelBuilder { @Override public void addContent(List data, WriteSheet writeSheet, WriteTable writeTable) { try { - context.currentSheet(writeSheet); context.currentTable(writeTable); doAddContent(data); @@ -254,15 +253,21 @@ public class ExcelBuilderImpl implements ExcelBuilder { if (value == null) { return; } - Converter converter = currentWriteHolder.converterMap().get(ConverterKeyBuild.buildKey(clazz)); + if (value instanceof String && currentWriteHolder.globalConfiguration().getAutoTrim()) { + value = ((String)value).trim(); + } + Converter converter = excelContentProperty.getConverter(); + if (converter == null) { + converter = currentWriteHolder.converterMap().get(ConverterKeyBuild.buildKey(clazz)); + } if (converter == null) { throw new ExcelDataConvertException( "Can not find 'Converter' support class " + clazz.getSimpleName() + "."); } - CellData cellData; try { - cellData = converter.convertToExcelData(value, excelContentProperty); + cellData = + converter.convertToExcelData(value, excelContentProperty, currentWriteHolder.globalConfiguration()); } catch (Exception e) { throw new ExcelDataConvertException("Convert data:" + value + " error,at row:" + cell.getRow().getRowNum(), e); diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteHolder.java index eba71df0..6880504b 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteHolder.java @@ -3,17 +3,17 @@ package com.alibaba.excel.write.metadata.holder; import java.util.List; import java.util.Map; -import com.alibaba.excel.metadata.Holder; +import com.alibaba.excel.metadata.ConfigurationHolder; import com.alibaba.excel.write.handler.WriteHandler; import com.alibaba.excel.write.property.ExcelWriteHeadProperty; /** - * + * * Get the corresponding Holder - * + * * @author zhuangjiaju **/ -public interface WriteHolder extends Holder { +public interface WriteHolder extends ConfigurationHolder { /** * What 'ExcelWriteHeadProperty' does the currently operated cell need to execute */ @@ -21,21 +21,21 @@ public interface WriteHolder extends Holder { /** * What handler does the currently operated cell need to execute - * + * * @return */ Map, List> writeHandlerMap(); /** * Whether a header is required for the currently operated cell - * + * * @return */ boolean needHead(); /** * Writes the head relative to the existing contents of the sheet. Indexes are zero-based. - * + * * @return */ int relativeHeadRowIndex();