<div class="form-group col-md-6">
<!--<label for="exampleInputFile">-->
上传文件:<input type="file" name="excel" id="exampleInputFile">
</label>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-default btn-primary exportexcel">提交改密</button>
</div>
</form>
$(".exportexcel").click(function(){
var excel=$("#exampleInputFile").val();
alert(excel)
if(excel==""){
alert("上传文件必需选择!!");
return;
}else{
$("#ModifyFile").submit();
}
});
private File excel;
public void modifyPwdCard() throws Exception{
String cardNumber=null;
String password=null;
List errorList=new ArrayList();
String exception=null;
List<HashMap<String,Object>> ErrorInfolist=new ArrayList<HashMap<String,Object>>();
System.out.println("======excel====="+excel.getName());
InputStream fi=new FileInputStream(excel);
HSSFWorkbook wb=new HSSFWorkbook(fi);
HSSFSheet sheet=wb.getSheetAt(0);
int rows=sheet.getLastRowNum() + 1;
int columns=sheet.getRow(0).getLastCellNum();
HSSFRow row;
HSSFCell cell;
StringBuilder stb=new StringBuilder();
for(int i=1;i < rows;i++){
row=sheet.getRow(i);
stb.setLength(0);
for(int j=0;j < columns;j++){
cell=row.getCell((short)j);
if(j == 0){
cardNumber=HSSFCellUtil.getCellValue(cell).trim();
}
if(j == 1){
password=HSSFCellUtil.getCellValue(cell).trim();
}
}