Foxtable(狐表)用户栏目专家坐堂 → [求助]导出非关联表数据并字段分工作表


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

主题:[求助]导出非关联表数据并字段分工作表

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/10 9:23:00 [显示全部帖子]

Dim cr As Row = Tables("订单").Current

Dim nams As List(Of String) = DataTables("备料明细").GetValues("供货方","订单号 = '" & cr("订单号") & "'")
Dim App As New MSExcel.Application
Dim bname As String = "d:\物料采购\物料采购清单.xlsx"
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Add
Dim ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
For Each nam As String In nams
    Dim Book As New XLS.Book ( ProjectPath & "Attachments\物料采购清单.xls" ) '调用模板
    Dim sheet As XLS.Sheet = Book.Sheets(0)
    Tables("备料明细").filter = "供货方 = '" & nam & "' and 订单号 = '" & cr("订单号") & "'"
    Book.Build()
    Dim fl As String = "d:\物料采购\" & nam & ".xls"
    Book.Save(fl) '保存工作簿
    Dim Wb_temp As MSExcel.WorkBook = App.WorkBooks.Open(fl)
    Dim Ws_temp As MSExcel.WorkSheet = wb_temp.WorkSheets(1)
    Ws_temp.name = nam
    Ws_temp.Copy(System.Reflection.Missing.Value, ws)
    wb_temp.close(False, System.Reflection.Missing.Value, System.Reflection.Missing.Value)
Next
ws.delete
Wb.saveas(bname)
App.Quit
Dim Proc As New Process '打开工作簿
Proc.File = bname
Proc.Start()

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/5/10 10:01:00 [显示全部帖子]

Dim t As Table = Tables("订单")
Dim filter As String = "1=2"
For i As Integer = t.TopPosition To t.BottomPosition
    filter &= " or 订单号 = '" & t.rows(i)("订单号") & "'"
Next
Dim nams As List(Of String) = DataTables("备料明细").GetValues("供货方",filter)
Dim App As New MSExcel.Application
Dim bname As String = "d:\物料采购\物料采购清单.xlsx"
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Add
Dim ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
For Each nam As String In nams
    Dim Book As New XLS.Book ( ProjectPath & "Attachments\物料采购清单.xls" ) '调用模板
    Dim sheet As XLS.Sheet = Book.Sheets(0)
    Tables("备料明细").filter = "供货方 = '" & nam & "' and (" & filter & ")"
    Book.Build()
    Dim fl As String = "d:\物料采购\" & nam & ".xls"
    Book.Save(fl) '保存工作簿
    Dim Wb_temp As MSExcel.WorkBook = App.WorkBooks.Open(fl)
    Dim Ws_temp As MSExcel.WorkSheet = wb_temp.WorkSheets(1)
    Ws_temp.name = nam
    Ws_temp.Copy(System.Reflection.Missing.Value, ws)
    wb_temp.close(False, System.Reflection.Missing.Value, System.Reflection.Missing.Value)
Next
ws.delete
Wb.saveas(bname)
App.Quit
Dim Proc As New Process '打开工作簿
Proc.File = bname
Proc.Start()


 回到顶部