public class EasyExcelTestObj {
public static void main(String[] args) throws FileNotFoundException {
testStudentRead("C:\\Users\\Administrator\\Desktop\\图纸解析\\H7D09353.xls");
}
public static void testStudentRead(String targetFilePath) throws FileNotFoundException {
List<Map<String, String>> dataList = new ArrayList<>();
// 读取excel
EasyExcelStudentListener listener = new EasyExcelStudentListener(dataList);
EasyExcel.read(targetFilePath, listener).sheet(0).headRowNumber(4).doRead();
// 输出读到的内容
for (Map dto : dataList) {
System.out.println(JSON.toJSONString(dto));
}
}
异常提示
Exception in thread "main" java.lang.NullPointerException at com.alibaba.excel.analysis.v03.handlers.DummyRecordHandler.processRecord(DummyRecordHandler.java:29) at com.alibaba.excel.analysis.v03.XlsSaxAnalyser.processRecord(XlsSaxAnalyser.java:157) at org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener.processRecord(MissingRecordAwareHSSFListener.java:156) at org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener.processRecord(FormatTrackingHSSFListener.java:92) at org.apache.poi.hssf.eventusermodel.HSSFRequest.processRecord(HSSFRequest.java:106)
问题描述这是我的excel文件 123.xls