需要导入excel的样子
代码:说明 最多支持5级目录导入
package net.parim.spark.unicom.provider.careercenter.service;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import net.parim.spark.core.system.entity.UserGroup;
import net.parim.spark.core.system.security.UserToken;
import net.parim.spark.core.system.service.UserGroupService;
import net.parim.spark.unicom.provider.careercenter.entity.CareerTeachMaterial;
public class TeachingMaterialImport {
public static final String UPLOADTEACHEXCEL ="TEACHEXCEL";
public Workbook readFile(InputStream inputStream,String fileName){
Workbook wb = null;
Map map = new HashMap<>();
boolean isE2007 = false; //判断是否是excel2007格式
if(fileName.endsWith("xlsx")){
isE2007 = true;
}
try {
InputStream input = inputStream; //建立输入流
//根据文件格式(2003或者2007)来初始化
if(isE2007){
wb = new XSSFWorkbook(input);
}else{
wb = new HSSFWorkbook(input);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return wb;
}
/**
* 校检表头
*/
public Map inspectHead(Sheet sheet){
//所有的单元格信息
List cras = getCombineCell(sheet);
//存储行信息
List
效果图
有喜欢的朋友可以关注下头条号《老徐聊技术》