本篇文章主要讲解实现用户在前台选择读取excel文件,获取excel中数据进行插入MySQL数据库中对应的属性列。
html页面代码
//定义批量添加按钮
<a href="#button" class="button icon log" onclick="BatchAdditionWindow()">批量添加教师</a>
//提升培训批量上传教师对话框
<div id="uploadBatchAddEnchangeTeacher" class="easyui-window" style="width:380px;padding:10px 40px" closed="true">
<form id="upload" method="post" enctype="multipart/form-data">
<table border="0" style="margin-top:4px;" width="100%" align="center">
<tr>
<td>
<input class="easyui-filebox" id="uploadFile" name="uploadFile" data-options="prompt:'文件上传', buttonText:'选择文件'" style="width:100%"></input>
</td>
</tr>
</table>
</form>
<div data-options="region:'south',border:false" style="text-align:center;padding:5px 0 0;">
<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="BatchAdditionTeacher();" style="width:80px">上传</a>
</div>
</div>
js代码控制
//打开文件上传对话框
function BatchAdditionWindow() {
var row = $('#ddg1').datagrid('getSelected');
if(row) {
$('#uploadBatchAddEnchangeTeacher').window('open').dialog('setTitle', '文件上传');
$('#uploadFileName').value = "";
}else{
alert("请先选择批量添加培训教师信息的项目!");
}
}
//<![CDATA[
//批量添加教师到项目中
function BatchAdditionTeacher