Dim Book As New XLS.Book("D:\360安全浏览器下载\管理系统下载的数据\管理系统数据下载为导出\中交中石油电子加油卡.xlsx")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For i As Integer = 0 To Sheet.Rows.Count - 1
If sheet(0, i).Text = "中石油电子卡加油列表" Then
messagebox.show("文件修复未完成,不能继续!请再次点击 修复待导入数据 按钮!", "提示")
Return
End If
Next
Tables("中交中石油电子加油卡").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"电子加油卡", "面值", "单价优惠", "实付金额", "实付返利金", "分配状态", "首次分配用户手机号", "首次分配用户车牌号", "首次分配用户姓名", "当前持有用户手机号", "当前持有用户车牌号", "当前持有用户姓名", "首次分配时间", "卡券状态", "加油站点", "加油时间", "支付方式", "采购时间", "订单号", "备注"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count - 1
Dim r As Row = Tables("中交中石油电子加油卡").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n, m).Value
Next
Next
Tables("中交中石油电子加油卡").ResumeRedraw()