导入Excel根据表头与注解名匹配

pull/67/MERGE
RuoYi 6 years ago
parent 999cd996fd
commit b1f4952cde

@ -8,7 +8,7 @@
<version>3.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<packaging>jar</packaging>
<artifactId>ruoyi-admin</artifactId>
<description>

@ -136,17 +136,20 @@ public class ExcelUtil<T>
if (rows > 0)
{
// 定义一个map用于存放excel列的序号和field.
Map<String, Integer> cellMap = new HashMap<String, Integer>();
// 获取表头
Row heard = sheet.getRow(0);
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) {
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
{
Cell cell = heard.getCell(i);
if (StringUtils.isNotNull(cell != null)) {
if (StringUtils.isNotNull(cell != null))
{
String value = this.getCellValue(heard, i).toString();
cellMap.put(value, i);
} else {
}
else
{
cellMap.put(null, i);
}
}

Loading…
Cancel
Save