以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]能不能把下面一段代码导出的很多EXCEL报表放在一个PDF文件上?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=79008)

--  作者:zgjmost
--  发布时间:2015/12/22 18:57:00
--  [求助]能不能把下面一段代码导出的很多EXCEL报表放在一个PDF文件上?
DataTables("考试数据表").LoadFilter = ""
DataTables("考试数据表").Load

Dim nms As String() = {"短日期","起始时间","教室"} \'指定生成目录树的各列
Dim qts As String() = {"\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim trv As WinForm.TreeView = e.Form.Controls("签到单时间")
Dim filter As String
For Each nd As object In trv.AllNodes
    If nd.Level > 2 Then
        If nd.Checked  Then
            Dim rts() As String = nd.FullPath.Split("\\")
            Dim val As String = ""
            For i As Integer = 1 To rts.length - 1
                If val > "" Then
                    val = val & " And "
                End If
                val = val & nms(i-1) & " = " & qts(i-1) & rts(i) & qts(i-1)
            Next
            If filter > "" Then
                filter = filter & " Or (" & val & ")"
            Else
                filter = val
            End If
        End If
    End If
Next

filter = filter.Replace("(","").Replace(")","")

DataTables("考试数据表").ResumeRedraw
DataTables("考试数据表").StopRedraw
For Each ary() As String In DataTables("考试数据表").GetValues("短日期|起始时间|教室", filter)
    
    Vars("qdd1") = ary(0)
    Vars("qdd2") = ary(1)
    Vars("qdd3") = ary(2)
    
    With Tables("考试数据表")
     .Sort = "保密号,座位号"
        .Filter = "机考安排 is null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'"
        If .Rows.count > 0 Then
            .Select(0,0,.Rows.count - 1,.Cols.count - 1 )


            Dim Book As New XLS.Book(ProjectPath & "Attachments\\纸考签到单.xls")
            Dim fl As String = ProjectPath & "Reports\\纸考签到表\\" & ary(0) & " "  & ary(1).Replace(":", "点") &  " "  &  ary(2) & "签到单.xls"
            Book.Build() \'生成细节区
            Book.Save(fl) \'保存工作簿
        End If
    End With

    With Tables("考试数据表")

  .Sort = "保密号,座位号"

        .Filter = "机考安排 is null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'"
        If .Rows.count > 0 Then
            .Select(0,0,.Rows.count - 1,.Cols.count - 1 )
            Dim Book As New XLS.Book(ProjectPath & "Attachments\\纸考座位单.xls")
            Dim fl As String = ProjectPath & "Reports\\纸考座位单\\" & ary(0) & " "  & ary(1).Replace(":", "点") &  " "  &  ary(2) & "座位单.xls"
            Book.Build() \'生成细节区
            Book.Save(fl) \'保存工作簿
        End If
    End With
    
    
    With Tables("考试数据表")
        .Sort = "试卷号,座位号"
        .Filter = "机考安排 is not null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'"
        If .Rows.count > 0 Then
            .Select(0,0,.Rows.count - 1,.Cols.count - 1 )

            Dim  book = New XLS.Book(ProjectPath & "Attachments\\机考签到单.xls")
            Dim fl = ProjectPath & "Reports\\机考签到表\\" & ary(0) & " "  & ary(1).Replace(":", "点") &  " "  &  ary(2) & "签到单.xls"
            
            Book.Build() \'生成细节区
            Book.Save(fl) \'保存工作簿
        End If
    End With
    
Next                                      \'结束遍历value2s的数组
DataTables("考试数据表").ResumeRedraw



--  作者:大红袍
--  发布时间:2015/12/22 19:10:00
--  

你可以只做一个excel模板,然后把所有的都生成在这个excel模板里面,最后save成pdf即可。

 

再者,你要用专业报表生成也可以


--  作者:zgjmost
--  发布时间:2015/12/22 23:12:00
--  
你可以只做一个excel模板,然后把所有的都生成在这个excel模板里面

怎么做?
怎么实现?

--  作者:Hyphen
--  发布时间:2015/12/23 9:03:00
--  

参考http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=74188


 


--  作者:大红袍
--  发布时间:2015/12/23 9:56:00
--  
以下是引用zgjmost在2015/12/22 23:12:00的发言:
你可以只做一个excel模板,然后把所有的都生成在这个excel模板里面

怎么做?
怎么实现?

 

为什么不行啊?http://www.foxtable.com/help/topics/1542.htm