按老师教的这种写法,数值都正常导入进来了,可是字符却导不进来,真正的字符变成了0
Dim dlg As new OpenFileDialog
dlg.Filter = "excel文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
Dim App As New MSExcel.Application
try
Dim Wb As MSExcel.Workbook = App.WorkBooks.Open(dlg.FileName)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Tables("版块业绩").StopRedraw()
'Dim nms() As String = {"支付金额","外呼时间","录入时间"}
Dim nms() As String = {"支付金额"}
Dim dict As new Dictionary(of String,Integer)
Dim dict2 As new Dictionary(of String,Integer)
Dim Rg As MSExcel.Range = Ws.UsedRange
Dim ary = rg.value
For c As Integer = 1 To rg.Columns.Count
If array.Indexof(nms, ary(1, c)) >= 0 Then
dict.add(ary(1, c), c)
End If
If Tables("版块业绩").Cols.Contains(ary(1,c)) Then
dict2.add(ary(1, c), c)
End If
Next
Dim newcount As Integer = 0
Dim Modifycount As Integer = 0
For n As Integer = 2 To rg.Rows.count
Dim rq As Date = e.Form.Controls("日期").value 'ary(n, 4)
Dim dr As DataRow = DataTables("版块业绩").sqlFind("日期 = '" & rq & "'")
If dr Is Nothing Then '如果不存在同编号的订单
dr = DataTables("版块业绩").AddNew()
dr("日期")=rq
For Each key As String In dict2.Keys
Dim s As String = ary(n,dict2(key))
If s.contains("%") Then
dr(key) = val(s.replace("%","")) * 100
Else
dr(key) = val(s)
End If
'dr(key) = ary(n,dict2(key))
Next
newcount += 1
Else
For Each key As String In dict.Keys
Dim s As String = ary(n,dict(key))
If s.contains("%") Then
dr(key) = val(s.replace("%","")) * 100
Else
dr(key) = val(s)
End If
'dr(key) = ary(n,dict(key))
Next
Modifycount += 1
End If
Next
Tables("店铺流量来源_table1").save()
Tables("版块业绩").ResumeRedraw()
msgbox(newcount & " " & Modifycount)
catch ex As exception
msgbox(ex.message)
app.quit
End try
End If