package com.alibaba.excel; import java.io.InputStream; import java.io.OutputStream; import java.util.List; import com.alibaba.excel.converters.BooleanConverter; import com.alibaba.excel.converters.Converter; import com.alibaba.excel.converters.ConverterRegistryCenter; import com.alibaba.excel.converters.DateConverter; import com.alibaba.excel.converters.DoubleConverter; import com.alibaba.excel.converters.FloatConverter; import com.alibaba.excel.converters.IntegerConverter; import com.alibaba.excel.converters.LongConverter; import com.alibaba.excel.converters.StringConverter; import com.alibaba.excel.event.WriteHandler; import com.alibaba.excel.metadata.BaseRowModel; 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.merge.MergeStrategy; /** * Excel Writer This tool is used to write value out to Excel via POI. This object can perform the * following two functions. * *
* 1. Create a new empty Excel workbook, write the value to the stream after the value is filled. * 2. Edit existing Excel, write the original Excel file, or write it to other places.} ** * @author jipengfei */ public class ExcelWriter { private ExcelBuilder excelBuilder; /** * Create new writer * * @param outputStream the java OutputStream you wish to write the value to * @param typeEnum 03 or 07 */ public ExcelWriter(OutputStream outputStream, ExcelTypeEnum typeEnum) { this(outputStream, typeEnum, true); } @Deprecated private Class extends BaseRowModel> objectClass; /** * @param generateParam */ @Deprecated public ExcelWriter(GenerateParam generateParam) { this(generateParam.getOutputStream(), generateParam.getType(), generateParam.isNeedHead()); this.objectClass = generateParam.getClazz(); } /** * * 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? */ public ExcelWriter(OutputStream outputStream, ExcelTypeEnum typeEnum, boolean needHead) { this(null, outputStream, typeEnum, needHead, null, null); } /** * Create new writer * * @param templateInputStream Append value after a POI file ,Can be null(the 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 */ public ExcelWriter(InputStream templateInputStream, OutputStream outputStream, ExcelTypeEnum typeEnum, Boolean needHead) { this(templateInputStream, outputStream, typeEnum, needHead, null, null); } /** * Create new writer * * @param templateInputStream Append value after a POI file ,Can be null(the 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 */ public ExcelWriter(InputStream templateInputStream, OutputStream outputStream, ExcelTypeEnum typeEnum, Boolean needHead, WriteHandler writeHandler) { this(templateInputStream, outputStream, typeEnum, needHead, writeHandler, null); } public ExcelWriter(InputStream templateInputStream, OutputStream outputStream, ExcelTypeEnum typeEnum, Boolean needHead, WriteHandler writeHandler, List