<worksheet name="Sheet1">
<loop startRow="1" endRow="30" items="data" var="item"
varType="com.base.tool.xls.UserXLS">
<section startRow="1" endRow="1">
<mapping cell="A2">item.account</mapping>
<mapping cell="B2">item.name</mapping>
<mapping cell="C2">item.mobile</mapping>
<mapping cell="D2">item.email</mapping>
</section>
<loopbreakcondition>
<rowcheck offset="0">
<cellcheck offset="0" />
</rowcheck>
</loopbreakcondition>
</loop>
</worksheet>
转换代码
if (file == null) {
return null;
}
FileObject foConfig = null;
foConfig = fs.toFileObject(new File(xml));
XLSReader reader = null;
reader = ReaderBuilder.buildFromXML(foConfig.getContent().getInputStream());
ReaderConfig.getInstance().setSkipErrors(true);
List excels = new ArrayList();
Map beans = new HashMap();
beans.put("data", excels);
try {
InputStream stream=new FileInputStream(file);
reader.read(stream, beans);
最后的数据
[名字-账号, 123-123, 111-111, null-null, null-null, null-null, null-null, null-null, null-null, null-null, null-null, null-null, null-null, null-null, null-null, null-null]
excel数据
账号 名字 电话 email
123 123 123 123
111 111 11 11
四季花海
相关分类