蓝老师,我按照狐表使用指南中“从Excel报表提取数据”的提示操作,未能实现,请指导修改一下,在按钮代码如下:
'从Excel报表提取数据
For Each file As String In filesys.GetFiles("D:\Data\员工资料卡.xlsx")
If file.EndsWith(".xls")
OrElse file.EndsWith(".xlsx") Then
Dim Book As
New
XLS.Book(file)
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
End If
Next
提示如下错误
.NET Framework 版本:4.0.30319.36543
Foxtable 版本:2024.10.30.1
错误所在事件:窗口,窗口1,Button1,Click
详细错误信息:
The process cannot access the file 'D:\Data\~$员工资料卡.xlsx' because it is being used by another process.
上面的错误提示是目录中不带文件名,如带文件名,即For Each file As String In filesys.GetFiles("D:\Data\员工资料卡.xlsx")时,提示如下.NET Framework 版本:4.0.30319.36543
Foxtable 版本:2024.10.30.1
错误所在事件:窗口,窗口1,Button1,Click
详细错误信息:
目录名称无效。
For Each file As String In filesys.GetFiles("D:\Data\员工资料卡.xlsx")
改为
For Each file As String In filesys.GetFiles("D:\Data\")
For Each file As String In filesys.GetFiles("D:\Data\")
If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
Dim Book As New XLS.Book(file)
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
End If
Next
修改后,仍提示
.NET Framework 版本:4.0.30319.36543
Foxtable 版本:2024.10.30.1
错误所在事件:窗口,窗口1,Button1,Click
详细错误信息:
Central dir not found.
在D:\data目录下有“员工资料卡.xlsx”和“员工.xlsx”文件,不是这个原因吧?
Central dir not found指不存在这个目录"D:\Data\"