Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xls;*.xlsx" '设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮 Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim dr As DataRow = DataTables("员工").AddNew dr("姓名") = sheet(4,1).Text dr("部门") = sheet(5,1).text dr("出生日期") = sheet(4,3).text dr("雇佣日期") = sheet(5,3).text dr("性别") = sheet(6,1).text dr("职务") = sheet(6,3).text dr("地址") = sheet(7,1).text dr("家庭电话") = sheet(8,1).text dr("办公电话") = sheet(8,3).text dr("备注") = sheet(9,0).text Dim fl As String = ProjectPath & "Attachments\" & dr("姓名") & ".jpg" If Sheet(4,4).SaveImage(fl) Then '如果照片保存成功 dr("照片") = fileSys.GetName(fl) End If Else e.Form.Close() End If
|