提交 c598a704 编写于 作者: J jipengfei.jpf

阿里內部最新版本开源,为了稳定性07版本解析修改为底层使用POI解析。

上级 bde93f94
......@@ -31,11 +31,23 @@ public class ExcelReader {
* }AnalysisContext
* @param eventListener
*/
@Deprecated
public ExcelReader(InputStream in, ExcelTypeEnum excelTypeEnum, Object customContent,
AnalysisEventListener eventListener) {
this(in, excelTypeEnum, customContent, eventListener, true);
}
/**
* @param in
* @param customContent {@link AnalysisEventListener#invoke(Object, AnalysisContext)
* }AnalysisContext
* @param eventListener
*/
public ExcelReader(InputStream in, Object customContent,
AnalysisEventListener eventListener) {
this(in, customContent, eventListener, true);
}
/**
* old 1.1.0
* @param param
......@@ -54,12 +66,27 @@ public class ExcelReader {
* @param eventListener
* @param trim
*/
@Deprecated
public ExcelReader(InputStream in, ExcelTypeEnum excelTypeEnum, Object customContent,
AnalysisEventListener eventListener, boolean trim) {
validateParam(in, excelTypeEnum, eventListener);
analyser.init(in, excelTypeEnum, customContent, eventListener, trim);
}
/**
* @param in
* @param customContent {@link AnalysisEventListener#invoke(Object, AnalysisContext)
* }AnalysisContext
* @param eventListener
* @param trim
*/
public ExcelReader(InputStream in, Object customContent,
AnalysisEventListener eventListener, boolean trim) {
ExcelTypeEnum excelTypeEnum = ExcelTypeEnum.valueOf(in);
validateParam(in, excelTypeEnum, eventListener);
analyser.init(in, excelTypeEnum, customContent, eventListener, trim);
}
/**
*/
public void read() {
......
......@@ -18,7 +18,6 @@ import static com.alibaba.excel.constant.ExcelXmlConstants.*;
/**
* @author jipengfei
* @date 2017/08/23
*/
public class XlsxRowHandler extends DefaultHandler {
......
......@@ -25,7 +25,6 @@ import java.util.List;
/**
* @author jipengfei
* @date 2017/08/27
*/
public class XlsxSaxAnalyser extends BaseSaxAnalyser {
......
......@@ -7,7 +7,6 @@ import java.lang.annotation.*;
* Field column num at excel head
*
* @author jipengfei
* @date 2017/03/19
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
......
......@@ -3,6 +3,7 @@ package com.alibaba.excel.context;
import com.alibaba.excel.metadata.*;
import com.alibaba.excel.metadata.CellRange;
import com.alibaba.excel.metadata.Table;
import com.alibaba.excel.metadata.TableStyle;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
......
......@@ -8,14 +8,14 @@ package com.alibaba.excel.event;
public interface AnalysisEventRegisterCenter {
/**
* @param name
* @param listener
* @param name 监听名定义
* @param listener 具体实现
*/
void appendLister(String name, AnalysisEventListener listener);
/**
* @param event
* @param event 事件
*/
void notifyListeners(OneRowAnalysisFinishEvent event);
......
......@@ -2,7 +2,6 @@ package com.alibaba.excel.event;
/**
* @author jipengfei
* @date 2017/07/21
*/
public class OneRowAnalysisFinishEvent {
......
......@@ -2,7 +2,6 @@ package com.alibaba.excel.metadata;
/**
* @author jipengfei
* @date 2017/06/02
*/
public class CellRange {
......
......@@ -6,7 +6,6 @@ import java.util.List;
/**
* @author jipengfei
* @date 2017/05/31
*/
public class ExcelColumnProperty implements Comparable<ExcelColumnProperty> {
......
......@@ -9,7 +9,6 @@ import java.util.*;
/**
*
* @author jipengfei
* @date 2017/05/31
*/
public class ExcelHeadProperty {
......
......@@ -3,7 +3,6 @@ package com.alibaba.excel.metadata;
/**
*
* @author jipengfei
* @date 2017/05/24
*/
public class Font {
......
......@@ -4,7 +4,6 @@ import java.util.List;
/**
* @author jipengfei
* @date 2017/05/16
*/
public class Table {
/**
......
......@@ -4,7 +4,6 @@ import org.apache.poi.ss.usermodel.IndexedColors;
/**
* @author jipengfei
* @date 2017/05/24
*/
public class TableStyle {
......
......@@ -8,7 +8,6 @@ import java.io.OutputStream;
* {@link com.alibaba.excel.ExcelWriter}
*
* @author jipengfei
* @date 2017/05/15
*/
@Deprecated
public class ExcelWriteParam {
......
package com.alibaba.excel.support;
import org.apache.poi.poifs.filesystem.FileMagic;
import java.io.IOException;
import java.io.InputStream;
/**
*
* @author jipengfei
......@@ -21,4 +26,19 @@ public enum ExcelTypeEnum {
public void setValue(String value) {
this.value = value;
}
public static ExcelTypeEnum valueOf(InputStream inputStream){
try {
FileMagic fileMagic = FileMagic.valueOf(inputStream);
if(FileMagic.OLE2.equals(fileMagic)){
return XLS;
}
if(FileMagic.OOXML.equals(fileMagic)){
return XLSX;
}
throw new IllegalArgumentException("excelTypeEnum can not null");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
......@@ -9,7 +9,6 @@ import java.util.Stack;
/**
* 去除空Cell
* @author jipengfei
* @date 2017/04/13
*/
public class IndexValueConverter {
public static List<String> converter(List<IndexValue> i_list) {
......
......@@ -5,7 +5,6 @@ import java.io.File;
/**
*
* @author jipengfei
* @date 2017/06/22
*/
public class POITempFile {
......
......@@ -2,7 +2,6 @@ package com.alibaba.excel.util;
/**
* @author jipengfei
* @date 2017/08/27
*/
public class PositionUtils {
......
......@@ -14,7 +14,6 @@ import java.util.regex.Pattern;
/**
* @author jipengfei
* @date 2017/03/15
*/
public class TypeUtil {
......
......@@ -21,7 +21,6 @@ import java.util.List;
/**
* @author jipengfei
* @date 2017/05/27
*/
public class ExcelBuilderImpl implements ExcelBuilder {
......
package com.alibaba.excel.annotation;
/**
*
* @author jipengfei
*/
public enum FieldType {
STRING, INT, LONG, DATE, BOOLEAN, DOUBLE,EMPTY;
}
package com.alibaba.excel.constant;
/**
* @author jipengfei
*/
public class ExcelXmlConstants {
public static final String DIMENSION = "dimension";
public static final String DIMENSION_REF = "ref";
public static final String POSITION = "r";
public static final String ROW_TAG = "row";
public static final String CELL_TAG = "c";
public static final String CELL_VALUE_TAG = "v";
public static final String CELL_VALUE_TAG_1 = "t";
}
......@@ -5,7 +5,6 @@ import com.alibaba.excel.metadata.BaseRowModel;
/**
* @author jipengfei
* @date 2017/05/31
*/
public class ExcelPropertyIndexModel extends BaseRowModel {
......
......@@ -19,12 +19,12 @@ public class XLS2003FunctionTest extends TestCase {
@Test
public void testExcel2003NoModel() {
InputStream inputStream = getInputStream("loan1.xls");
InputStream inputStream = getInputStream("2003.xls");
try {
// 解析每行结果在listener中处理
ExcelListener listener = new ExcelListener();
ExcelReader excelReader = new ExcelReader(inputStream, ExcelTypeEnum.XLS, null, listener);
ExcelReader excelReader = new ExcelReader(inputStream, null, listener);
excelReader.read();
} catch (Exception e) {
e.printStackTrace();
......
......@@ -23,11 +23,11 @@ public class Read2007Xlsx {
//创建没有自定义模型,没有sheet的解析器,默认解析所有sheet解析结果以List<String>的方式通知监听者
@Test
public void noModel() {
InputStream inputStream = getInputStream("需要分批关闭客户名单 2018.8.24.xlsx");
InputStream inputStream = getInputStream("2007.xlsx");
final List<List<String>> ll = new ArrayList<List<String>>();
try {
ExcelReader reader = new ExcelReader(inputStream, ExcelTypeEnum.XLSX, null,
ExcelReader reader = new ExcelReader(inputStream, null,
new AnalysisEventListener<List<String>>() {
@Override
public void invoke(List<String> object, AnalysisContext context) {
......
......@@ -12,7 +12,6 @@ import java.util.List;
/**
* @author jipengfei
* @date 2017/08/27
*/
public class Excel2007WithJavaModelAnalysisListener extends AnalysisEventListener {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册