Search in sources :

Example 1 with StringStringConverter

use of com.alibaba.excel.converters.string.StringStringConverter in project easyexcel by alibaba.

the class DefaultConverterLoader method initDefaultWriteConverter.

private static void initDefaultWriteConverter() {
    defaultWriteConverter = MapUtils.newHashMapWithExpectedSize(40);
    putWriteConverter(new BigDecimalNumberConverter());
    putWriteConverter(new BigIntegerNumberConverter());
    putWriteConverter(new BooleanBooleanConverter());
    putWriteConverter(new ByteNumberConverter());
    putWriteConverter(new DateDateConverter());
    putWriteConverter(new LocalDateTimeDateConverter());
    putWriteConverter(new DoubleNumberConverter());
    putWriteConverter(new FloatNumberConverter());
    putWriteConverter(new IntegerNumberConverter());
    putWriteConverter(new LongNumberConverter());
    putWriteConverter(new ShortNumberConverter());
    putWriteConverter(new StringStringConverter());
    putWriteConverter(new FileImageConverter());
    putWriteConverter(new InputStreamImageConverter());
    putWriteConverter(new ByteArrayImageConverter());
    putWriteConverter(new BoxingByteArrayImageConverter());
    putWriteConverter(new UrlImageConverter());
    // In some cases, it must be converted to string
    putWriteStringConverter(new BigDecimalStringConverter());
    putWriteStringConverter(new BigIntegerStringConverter());
    putWriteStringConverter(new BooleanStringConverter());
    putWriteStringConverter(new ByteStringConverter());
    putWriteStringConverter(new DateStringConverter());
    putWriteStringConverter(new LocalDateTimeStringConverter());
    putWriteStringConverter(new DoubleStringConverter());
    putWriteStringConverter(new FloatStringConverter());
    putWriteStringConverter(new IntegerStringConverter());
    putWriteStringConverter(new LongStringConverter());
    putWriteStringConverter(new ShortStringConverter());
    putWriteStringConverter(new StringStringConverter());
    putWriteStringConverter(new BigIntegerStringConverter());
}
Also used : DateDateConverter(com.alibaba.excel.converters.date.DateDateConverter) IntegerNumberConverter(com.alibaba.excel.converters.integer.IntegerNumberConverter) BigIntegerNumberConverter(com.alibaba.excel.converters.biginteger.BigIntegerNumberConverter) IntegerStringConverter(com.alibaba.excel.converters.integer.IntegerStringConverter) BigIntegerStringConverter(com.alibaba.excel.converters.biginteger.BigIntegerStringConverter) StringStringConverter(com.alibaba.excel.converters.string.StringStringConverter) BoxingByteArrayImageConverter(com.alibaba.excel.converters.bytearray.BoxingByteArrayImageConverter) BooleanStringConverter(com.alibaba.excel.converters.booleanconverter.BooleanStringConverter) BigDecimalStringConverter(com.alibaba.excel.converters.bigdecimal.BigDecimalStringConverter) LongStringConverter(com.alibaba.excel.converters.longconverter.LongStringConverter) BigIntegerNumberConverter(com.alibaba.excel.converters.biginteger.BigIntegerNumberConverter) LongNumberConverter(com.alibaba.excel.converters.longconverter.LongNumberConverter) BigIntegerStringConverter(com.alibaba.excel.converters.biginteger.BigIntegerStringConverter) FloatNumberConverter(com.alibaba.excel.converters.floatconverter.FloatNumberConverter) FileImageConverter(com.alibaba.excel.converters.file.FileImageConverter) BoxingByteArrayImageConverter(com.alibaba.excel.converters.bytearray.BoxingByteArrayImageConverter) ByteArrayImageConverter(com.alibaba.excel.converters.bytearray.ByteArrayImageConverter) DoubleStringConverter(com.alibaba.excel.converters.doubleconverter.DoubleStringConverter) ShortStringConverter(com.alibaba.excel.converters.shortconverter.ShortStringConverter) ShortNumberConverter(com.alibaba.excel.converters.shortconverter.ShortNumberConverter) DoubleNumberConverter(com.alibaba.excel.converters.doubleconverter.DoubleNumberConverter) LocalDateTimeDateConverter(com.alibaba.excel.converters.localdatetime.LocalDateTimeDateConverter) ByteStringConverter(com.alibaba.excel.converters.byteconverter.ByteStringConverter) UrlImageConverter(com.alibaba.excel.converters.url.UrlImageConverter) FloatStringConverter(com.alibaba.excel.converters.floatconverter.FloatStringConverter) BooleanBooleanConverter(com.alibaba.excel.converters.booleanconverter.BooleanBooleanConverter) DateStringConverter(com.alibaba.excel.converters.date.DateStringConverter) InputStreamImageConverter(com.alibaba.excel.converters.inputstream.InputStreamImageConverter) BigDecimalNumberConverter(com.alibaba.excel.converters.bigdecimal.BigDecimalNumberConverter) ByteNumberConverter(com.alibaba.excel.converters.byteconverter.ByteNumberConverter) LocalDateTimeStringConverter(com.alibaba.excel.converters.localdatetime.LocalDateTimeStringConverter)

Example 2 with StringStringConverter

use of com.alibaba.excel.converters.string.StringStringConverter in project easyexcel by alibaba.

the class DefaultConverterLoader method initAllConverter.

private static void initAllConverter() {
    allConverter = MapUtils.newHashMapWithExpectedSize(40);
    putAllConverter(new BigDecimalBooleanConverter());
    putAllConverter(new BigDecimalNumberConverter());
    putAllConverter(new BigDecimalStringConverter());
    putAllConverter(new BigIntegerBooleanConverter());
    putAllConverter(new BigIntegerNumberConverter());
    putAllConverter(new BigIntegerStringConverter());
    putAllConverter(new BooleanBooleanConverter());
    putAllConverter(new BooleanNumberConverter());
    putAllConverter(new BooleanStringConverter());
    putAllConverter(new ByteBooleanConverter());
    putAllConverter(new ByteNumberConverter());
    putAllConverter(new ByteStringConverter());
    putAllConverter(new DateNumberConverter());
    putAllConverter(new DateStringConverter());
    putAllConverter(new LocalDateNumberConverter());
    putAllConverter(new LocalDateTimeStringConverter());
    putAllConverter(new DoubleBooleanConverter());
    putAllConverter(new DoubleNumberConverter());
    putAllConverter(new DoubleStringConverter());
    putAllConverter(new FloatBooleanConverter());
    putAllConverter(new FloatNumberConverter());
    putAllConverter(new FloatStringConverter());
    putAllConverter(new IntegerBooleanConverter());
    putAllConverter(new IntegerNumberConverter());
    putAllConverter(new IntegerStringConverter());
    putAllConverter(new LongBooleanConverter());
    putAllConverter(new LongNumberConverter());
    putAllConverter(new LongStringConverter());
    putAllConverter(new ShortBooleanConverter());
    putAllConverter(new ShortNumberConverter());
    putAllConverter(new ShortStringConverter());
    putAllConverter(new StringBooleanConverter());
    putAllConverter(new StringNumberConverter());
    putAllConverter(new StringStringConverter());
    putAllConverter(new StringErrorConverter());
    putAllConverter(new BigIntegerStringConverter());
}
Also used : IntegerNumberConverter(com.alibaba.excel.converters.integer.IntegerNumberConverter) BigIntegerNumberConverter(com.alibaba.excel.converters.biginteger.BigIntegerNumberConverter) DoubleBooleanConverter(com.alibaba.excel.converters.doubleconverter.DoubleBooleanConverter) BigDecimalBooleanConverter(com.alibaba.excel.converters.bigdecimal.BigDecimalBooleanConverter) IntegerStringConverter(com.alibaba.excel.converters.integer.IntegerStringConverter) BigIntegerStringConverter(com.alibaba.excel.converters.biginteger.BigIntegerStringConverter) StringStringConverter(com.alibaba.excel.converters.string.StringStringConverter) BigIntegerBooleanConverter(com.alibaba.excel.converters.biginteger.BigIntegerBooleanConverter) IntegerBooleanConverter(com.alibaba.excel.converters.integer.IntegerBooleanConverter) BooleanNumberConverter(com.alibaba.excel.converters.booleanconverter.BooleanNumberConverter) BooleanStringConverter(com.alibaba.excel.converters.booleanconverter.BooleanStringConverter) StringBooleanConverter(com.alibaba.excel.converters.string.StringBooleanConverter) BigDecimalStringConverter(com.alibaba.excel.converters.bigdecimal.BigDecimalStringConverter) LongStringConverter(com.alibaba.excel.converters.longconverter.LongStringConverter) BigIntegerNumberConverter(com.alibaba.excel.converters.biginteger.BigIntegerNumberConverter) BigIntegerStringConverter(com.alibaba.excel.converters.biginteger.BigIntegerStringConverter) LongNumberConverter(com.alibaba.excel.converters.longconverter.LongNumberConverter) ByteBooleanConverter(com.alibaba.excel.converters.byteconverter.ByteBooleanConverter) FloatNumberConverter(com.alibaba.excel.converters.floatconverter.FloatNumberConverter) LongBooleanConverter(com.alibaba.excel.converters.longconverter.LongBooleanConverter) DoubleStringConverter(com.alibaba.excel.converters.doubleconverter.DoubleStringConverter) ShortStringConverter(com.alibaba.excel.converters.shortconverter.ShortStringConverter) ShortNumberConverter(com.alibaba.excel.converters.shortconverter.ShortNumberConverter) DoubleNumberConverter(com.alibaba.excel.converters.doubleconverter.DoubleNumberConverter) BigIntegerBooleanConverter(com.alibaba.excel.converters.biginteger.BigIntegerBooleanConverter) ShortBooleanConverter(com.alibaba.excel.converters.shortconverter.ShortBooleanConverter) ByteStringConverter(com.alibaba.excel.converters.byteconverter.ByteStringConverter) FloatStringConverter(com.alibaba.excel.converters.floatconverter.FloatStringConverter) BooleanBooleanConverter(com.alibaba.excel.converters.booleanconverter.BooleanBooleanConverter) DateStringConverter(com.alibaba.excel.converters.date.DateStringConverter) DateNumberConverter(com.alibaba.excel.converters.date.DateNumberConverter) LocalDateNumberConverter(com.alibaba.excel.converters.localdatetime.LocalDateNumberConverter) StringErrorConverter(com.alibaba.excel.converters.string.StringErrorConverter) BigDecimalNumberConverter(com.alibaba.excel.converters.bigdecimal.BigDecimalNumberConverter) FloatBooleanConverter(com.alibaba.excel.converters.floatconverter.FloatBooleanConverter) StringNumberConverter(com.alibaba.excel.converters.string.StringNumberConverter) LocalDateNumberConverter(com.alibaba.excel.converters.localdatetime.LocalDateNumberConverter) ByteNumberConverter(com.alibaba.excel.converters.byteconverter.ByteNumberConverter) LocalDateTimeStringConverter(com.alibaba.excel.converters.localdatetime.LocalDateTimeStringConverter)

Example 3 with StringStringConverter

use of com.alibaba.excel.converters.string.StringStringConverter in project easyexcel by alibaba.

the class ParameterDataTest method readAndWrite7.

private void readAndWrite7(File file, ExcelTypeEnum type) {
    EasyExcel.write(file, ParameterData.class).registerConverter(new StringStringConverter()).sheet().registerConverter(new StringStringConverter()).needHead(Boolean.FALSE).table(0).needHead(Boolean.TRUE).doWrite(data());
    EasyExcel.read(file.getPath()).head(ParameterData.class).registerReadListener(new ParameterDataListener()).sheet().registerConverter(new StringStringConverter()).doRead();
}
Also used : StringStringConverter(com.alibaba.excel.converters.string.StringStringConverter)

Example 4 with StringStringConverter

use of com.alibaba.excel.converters.string.StringStringConverter in project easyexcel by alibaba.

the class ParameterDataTest method readAndWrite6.

private void readAndWrite6(File file, ExcelTypeEnum type) throws Exception {
    ExcelWriter excelWriter = EasyExcel.write(new FileOutputStream(file)).excelType(type).head(ParameterData.class).relativeHeadRowIndex(0).build();
    WriteSheet writeSheet = EasyExcel.writerSheet(0).relativeHeadRowIndex(0).needHead(Boolean.FALSE).build();
    WriteTable writeTable = EasyExcel.writerTable(0).registerConverter(new StringStringConverter()).relativeHeadRowIndex(0).needHead(Boolean.TRUE).build();
    excelWriter.write(data(), writeSheet, writeTable);
    excelWriter.finish();
    ExcelReader excelReader = EasyExcel.read(file.getPath(), new ParameterDataListener()).head(ParameterData.class).mandatoryUseInputStream(Boolean.FALSE).autoCloseStream(Boolean.TRUE).readCache(new MapCache()).build();
    ReadSheet readSheet = EasyExcel.readSheet("0").head(ParameterData.class).use1904windowing(Boolean.FALSE).headRowNumber(1).sheetNo(0).build();
    excelReader.read(readSheet);
    excelReader.finish();
    excelReader = EasyExcel.read(file.getPath(), new ParameterDataListener()).head(ParameterData.class).mandatoryUseInputStream(Boolean.FALSE).autoCloseStream(Boolean.TRUE).readCache(new MapCache()).build();
    excelReader.read();
    excelReader.finish();
}
Also used : ExcelReader(com.alibaba.excel.ExcelReader) MapCache(com.alibaba.excel.cache.MapCache) ExcelWriter(com.alibaba.excel.ExcelWriter) FileOutputStream(java.io.FileOutputStream) WriteSheet(com.alibaba.excel.write.metadata.WriteSheet) WriteTable(com.alibaba.excel.write.metadata.WriteTable) ReadSheet(com.alibaba.excel.read.metadata.ReadSheet) StringStringConverter(com.alibaba.excel.converters.string.StringStringConverter)

Aggregations

StringStringConverter (com.alibaba.excel.converters.string.StringStringConverter)4 BigDecimalNumberConverter (com.alibaba.excel.converters.bigdecimal.BigDecimalNumberConverter)2 BigDecimalStringConverter (com.alibaba.excel.converters.bigdecimal.BigDecimalStringConverter)2 BigIntegerNumberConverter (com.alibaba.excel.converters.biginteger.BigIntegerNumberConverter)2 BigIntegerStringConverter (com.alibaba.excel.converters.biginteger.BigIntegerStringConverter)2 BooleanBooleanConverter (com.alibaba.excel.converters.booleanconverter.BooleanBooleanConverter)2 BooleanStringConverter (com.alibaba.excel.converters.booleanconverter.BooleanStringConverter)2 ByteNumberConverter (com.alibaba.excel.converters.byteconverter.ByteNumberConverter)2 ByteStringConverter (com.alibaba.excel.converters.byteconverter.ByteStringConverter)2 DateStringConverter (com.alibaba.excel.converters.date.DateStringConverter)2 DoubleNumberConverter (com.alibaba.excel.converters.doubleconverter.DoubleNumberConverter)2 DoubleStringConverter (com.alibaba.excel.converters.doubleconverter.DoubleStringConverter)2 FloatNumberConverter (com.alibaba.excel.converters.floatconverter.FloatNumberConverter)2 FloatStringConverter (com.alibaba.excel.converters.floatconverter.FloatStringConverter)2 IntegerNumberConverter (com.alibaba.excel.converters.integer.IntegerNumberConverter)2 IntegerStringConverter (com.alibaba.excel.converters.integer.IntegerStringConverter)2 LocalDateTimeStringConverter (com.alibaba.excel.converters.localdatetime.LocalDateTimeStringConverter)2 LongNumberConverter (com.alibaba.excel.converters.longconverter.LongNumberConverter)2 LongStringConverter (com.alibaba.excel.converters.longconverter.LongStringConverter)2 ShortNumberConverter (com.alibaba.excel.converters.shortconverter.ShortNumberConverter)2