forked from fanruan/easyexcel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1011 B
44 lines
1011 B
package com.alibaba.excel.support; |
|
|
|
import org.apache.poi.poifs.filesystem.FileMagic; |
|
|
|
import java.io.IOException; |
|
import java.io.InputStream; |
|
|
|
/** |
|
* |
|
* @author jipengfei |
|
*/ |
|
public enum ExcelTypeEnum { |
|
XLS(".xls"), |
|
XLSX(".xlsx"); |
|
// CSV(".csv"); |
|
private String value; |
|
|
|
private ExcelTypeEnum(String value) { |
|
this.setValue(value); |
|
} |
|
|
|
public String getValue() { |
|
return value; |
|
} |
|
|
|
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); |
|
} |
|
} |
|
}
|
|
|