URL url = new URL(fileUrl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
//设置超时间为3秒
conn.setConnectTimeout(3*1000);
//防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//得到输入流
InputStream inputStream = conn.getInputStream();
public static AjaxModel parseExcelForInfo(InputStream inputStream, String fileName, int taskId) {
try {
//创建workbook对象
Workbook workbook = null;
if (fileName.contains(".xlsx")) {
workbook = new XSSFWorkbook(inputStream);
} else if (fileName.contains(".xls")) {
workbook = new HSSFWorkbook(inputStream);
} else {
return AjaxModel.failed(-1, "文件类型不正确");
}
//获取第一个sheet表
Sheet sheetAt = workbook.getSheetAt(0);
if