Foxtable(狐表)用户栏目专家坐堂 → 提取excel文件的问题


  共有2039人关注过本帖树形打印复制链接

主题:提取excel文件的问题

帅哥哟,离线,有人找我吗?
vincent92
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:46 积分:398 威望:0 精华:0 注册:2018/4/27 13:27:00
提取excel文件的问题  发帖心情 Post By:2018/5/22 11:49:00 [只看该作者]

我写了一段代码,想实现从excel中提取两部分格式不一样的数据,但是保存的时候报错,不知道是什么问题?

With DataTables("库存明细表")
   .DataRows.Clear() 
End With
Dim Book As New XLS.Book("E:\Vincent\库存报表\1804\430-财务库存.xlsx")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim nms() As String = {"日期","区域","店铺","店铺名","货号","店铺级别","大类","季节","品牌","月份"}
Dim opq() As Double = {"销售数量","销售金额","吊牌金额","库存数量","库存金额"}
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
    For s As Integer = 0 To opq.length - 1
         r(opq(s + 10)) = Sheet(n,s+10).Value
    Next
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/22 11:51:00 [只看该作者]

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
    For s As Integer = 0 To opq.length - 1
         r(opq(s)) = Sheet(n,s+10).Value
    Next
Next

 回到顶部