Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importExcelBySax NullPointerException #91

Open
ma19881117 opened this issue Aug 5, 2023 · 0 comments
Open

importExcelBySax NullPointerException #91

ma19881117 opened this issue Aug 5, 2023 · 0 comments

Comments

@ma19881117
Copy link

jeecgboot版本: 3.5.3

描述:importExcelBySax方法中ImportParams 为null,readExcel方法不支持ImportParams 为null

报错位置行:params.getSheetNum()

public static List importExcelBySax(InputStream inputstream, ISaxRowRead rowRead) {
return new SaxReadExcel().readExcel(inputstream, null, null, rowRead, null);
}

private <T> List<T> readExcel(OPCPackage opcPackage, Class<?> pojoClass, ImportParams params, ISaxRowRead rowRead, IExcelReadRowHanlder hanlder) {
	try {
		XSSFReader xssfReader = new XSSFReader(opcPackage);
		SharedStringsTable sst = xssfReader.getSharedStringsTable();
		if (rowRead == null) {
			rowRead = new SaxRowRead(pojoClass, params, hanlder);
		}
		XMLReader parser = fetchSheetParser(sst, rowRead);
		Iterator<InputStream> sheets = xssfReader.getSheetsData();
		int sheetIndex = 0;
		while (sheets.hasNext() && sheetIndex < params.getSheetNum()) {
			sheetIndex++;
			InputStream sheet = sheets.next();
			InputSource sheetSource = new InputSource(sheet);
			parser.parse(sheetSource);
			sheet.close();
		}
		return rowRead.getList();
	} catch (Exception e) {
		LOGGER.error(e.getMessage(), e);
		throw new ExcelImportException("SAX导入数据失败");
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant