class="div-content">
class="list">
excel檔案:dt>
id="txtimgurl"
runat="server"
cssclass="input normal upload-path" />
class="upload-box upload-img">
div>
dd>
dl>
div>
class="*******">
id="btnok"
style="margin-left: 20px"
runat="server"
text="匯入"
class="btn"
onclick="btnok_click" />
div>
div>
//匯入事件
protected void btnok_click(object sender, eventargs e)
hr_employee mdemployee = new hr_employee();
hr_userprofile mduserprofile;
hr_employeemanager bllemployee = new hr_employeemanager();
departmentmanager blldept = new departmentmanager();
hr_postmanager bllpost = new hr_postmanager();
hr_dutymanager bllduty = new hr_dutymanager();
hr_userprofilemanager blluserprofile = new hr_userprofilemanager();
hr_enterprisemanager bllenterprise = new hr_enterprisemanager();
int succount = 0, errorcount = 0
; try
mdemployee = new hr_employee();
mdemployee.uid = blluserprofile.getuidbyupshenfenid(dr["身份證號"].tostring());
mdemployee.dept_id = dr["部門"].tostring() == "" ? 0 : blldept.getdeptidbydeptname(dr["部門"].tostring());
mdemployee.pid = dr["崗位"].tostring() == "" ? 0 : bllpost.getpidbypostname(dr["崗位"].tostring());
mdemployee.e_id = dr["保險所在公司"].tostring() == "" ? 0 : bllenterprise.eidbyename(dr["保險所在公司"].tostring());
mdemployee.duty = dr["職位"].tostring() == "" ? 0 : bllduty.getidbydutyname(dr["職位"].tostring());
mdemployee.emp_name = dr["姓名"].tostring();
mdemployee.emp_*** = dr["性別"].tostring();
mdemployee.emp_cardid = dr["身份證號"].tostring();
mdemployee.culture_degree = dr["文化程度"].tostring();
mdemployee.political_status = dr["政治面貌"].tostring();
mdemployee.emp_mobile = dr["****"].tostring();
mdemployee.related_man = dr["緊急人"].tostring();
mdemployee.urgent_telephone = dr["緊急****"].tostring();
mdemployee.contract_beg_date = datatimeoperate(dr["合同起始日期"].tostring()); //dr["合同起始日期"].tostring() == "" ? convert.todatetime("1900-1-1") : convert.todatetime(dr["合同起始日期"].tostring().replace("/", "-"));
mdemployee.contract_end_date = datatimeoperate(dr["合同終止日期"].tostring()); //dr["合同終止日期"].tostring() == "" ? convert.todatetime("1900-1-1") : convert.todatetime(dr["合同終止日期"].tostring().replace("/", "-"));
mdemployee.contract_count = dr["合同期限"].tostring() == "" ? 0 : convert.toint32(dr["合同期限"]);
mdemployee.contract_period = dr["合同續訂次數"].tostring() == "" ? 0 : convert.toint32(dr["合同續訂次數"]);
mdemployee.note_info = dr["備註"].tostring();
mdemployee.earea = ""
; mdemployee.emp_email = ""
; mdemployee.emp_qq = ""
; mdemployee.emp_weixin = ""
; mdemployee.technical = ""
; mdemployee.emp_state = int.parse(this.rblstate
.selectedvalue);
mdemployee.myorder = 999
; int emp_id = bllemployee.add(mdemployee);//新增到職工表
if (emp_id > 0)
else}}
catch (exception ex)
response.write("");
jscriptmsg("匯入成功" + succount + "條,失敗" + errorcount + "條", "employeelist.aspx");
}else
file.delete(filepath);
}else
}//日期格式處理
protected datetime datatimeoperate(string str_date)
else
}
class="div-content">
class="list">
"cblist" runat="server" repeatcolumns="7" repeatdirection="horizontal">
div>
class="*******">
"btnok" style="margin-left: 20px" runat="server" text="匯出"
class="btn" onclick="btnok_click" />
div>
div>
protected void page_load(object sender, eventargs e)
}//繫結字段
protected void bindfield()
}//獲取**
protected datatable bindtable(string chkselect)
//開始匯出
protected void btnok_click(object sender, eventargs e)
}if (chkselect != "")
datatable dt = new datatable();
if (this.cblist
.items[34].selected && this.cblist
.items[34].text == "工作經歷")}}
}else
dt = bindtable(chkselect);
dt.columns
.remove("new_index");
dt.columns
.remove("dutyorder");
dt.columns
.remove("myorder");
dt.columns
.remove("upentry");
dt.columns
.remove("emp_id");
dotnet.framework
.common
.office
.npoiexcelreader
.rendertoexcel(dt, context, datetime.now
.tostring("yyyymmddhhmmssffff") + ".xls");
response.write("");
}catch
}
Excel資料的匯入 匯出
excel資料的匯入 匯出 excel資料的匯入 匯出 匯入 匯入excel 的資料,不是一條一條的資料新增,而是方便快速儲存資料,判斷資料的正確性。匯入excel 是方便我們在開發資料中快速的匯入資料 一 匯入 獲取模板檔案路徑 字尾 xls 驗證 判斷模板檔案是否存在在根目錄,模板檔案存在就獲取...
C 使用NPOI實現Excel的匯入匯出
excel小幫手 public static class excelhelper if ofd.showdialog dialogresult.ok else iworkbook workbook null using var fs file.openread filename if path.ge...
JAVA實現Excel匯入匯出
建立工程匯入jar包 jxl建立excel檔案 author c public class jxlexpexcel 建立excel檔案 file file new file jxl test.xls try 追加資料 for int i 1 i 10 i 寫入資料 workbook.write wo...