以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]excel报表求助  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=106440)

--  作者:ajie5211
--  发布时间:2017/9/8 16:44:00
--  [求助]excel报表求助

Dim Book As New XLS.Book(ProjectPath & "Attachments\\冲压制令单.xls")
Dim fl As String = ProjectPath & "Reports\\冲压制令单.xls"
With Tables("冲压生产计划追踪表")
    If .TopPosition > -1 Then \'如果选定区域包括数据行
        For i As Integer = .TopPosition To .BottomPosition
            book.AddDataTable("冲压生产计划追踪表","wjexcel","Select * f ro m {冲压生产计划追踪表} where 制令单号 = \'" & .Rows(i)("制令单号") & "\'") \'添加父表
            book.AddDataTable("Ft生产制令单","wjexcel","Select * f ro m {Ft生产制令单} where 销售单号 = \'" & .Rows(i)("制令单号") & "\'") \'添加子表
            book.AddRelation("冲压生产计划追踪表","制令单号","Ft生产制令单","销售单号") \'建立关联
            Book.Build() \'生成细节区
            fl = ProjectPath & "Reports\\" & .Rows(i)("制令单号") & ".pdf"
            \'Book.Save(fl) \'保存工作簿
            Book.SaveToPDF(fl) \'保存为PDF文件
            \'Dim Proc As New Process \'打开工作簿
            \'Proc.File = fl
            \'Proc.Start()
        Next
    End If
End With

以上代码,选择多行,提示如下错误

 


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20170908163959.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2017/9/8 17:21:00
--  

把下面这句代码,写到循环里

 

Dim Book As New XLS.Book(ProjectPath & "Attachments\\冲压制令单.xls")