我们在用阿里巴巴的Excel组件解析excel的时候, 会出现表头和内容列数不一致的情况, 采用以下方式就可以了 public class EasyExcelDemo {
private static String getCellValue(final Object value){
if(value==null){
return "";
}
return value.toString();
};
public static void main(String[] args) {
ExcelListener excelListener = new ExcelListener();
InputStream inputStream = null;
try {
inputStream = new FileInputStream(new File("D:\\更新mingjian.xlsx"));
EasyExcelFactory.readBySax(inputStream, new Sheet(1, 0), excelListener);
inputStream.close();
List> list = excelListener.list;
//获取表头的size
int size = list.get(0).size();
//移除表头
list.remove(0);
//声明一个数组, 是excel列, 要保持列数
Object[] cells = new Object[size];
Object cell = cells[5];