Search in sources :

Example 1 with MapCache

use of com.alibaba.excel.cache.MapCache in project easyexcel by alibaba.

the class ParameterDataTest method readAndWrite5.

private void readAndWrite5(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).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().head(ParameterData.class).use1904windowing(Boolean.FALSE).headRowNumber(1).sheetNo(0).sheetName("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)

Example 2 with MapCache

use of com.alibaba.excel.cache.MapCache 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

ExcelReader (com.alibaba.excel.ExcelReader)2 ExcelWriter (com.alibaba.excel.ExcelWriter)2 MapCache (com.alibaba.excel.cache.MapCache)2 ReadSheet (com.alibaba.excel.read.metadata.ReadSheet)2 WriteSheet (com.alibaba.excel.write.metadata.WriteSheet)2 WriteTable (com.alibaba.excel.write.metadata.WriteTable)2 FileOutputStream (java.io.FileOutputStream)2 StringStringConverter (com.alibaba.excel.converters.string.StringStringConverter)1