以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何将临时表直接作为报表输出数据源?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=148093)

--  作者:lanbor
--  发布时间:2020/3/31 9:30:00
--  如何将临时表直接作为报表输出数据源?
If Tables(e.Form.name & "_table1").Rows.Count>0 Then
Dim t1 As Table
t1.DataSource = DataT ables(e.Form.name & "_table1")     我这样做了
Dim i1 As Integer
    Dim Book As New XLS.Book(ProjectPath & "Attachments\\proc99_all.xls") \'9_report.xls")
    Dim sheet As XLS.Sheet = Book.Sheets(0)
    Dim Style As Xls.Style=book.NewStyle
    Style.BackColor=Color.Red
    ExcelPath="D:\\step00\\"
    Dim fl As String = ExcelPath & "ExcelReport\\proc99_all.xls" 
     book.Add DataTable("proc99_pub","","sel ect * fro m {t1} order by p9.proc01,p9.proc02,p9.proc03,p8.proc805" )    ‘这里报错了。
    book.Build()
    book.save( fl ) \'fl
    Dim proc As New Process
    Proc.file=fl
    proc.Start()
End If
请教:如何正确将当前:Tables(e.Form.name & "_table1") 的记录直接作为  book.AddDataTable 的数据源 ?
谢谢专家!


--  作者:有点蓝
--  发布时间:2020/3/31 9:51:00
--  
book.AddDataTable 只能添加后台数据库,这个是为了直接从数据库生成报表使用的,如果是已经加载数据的,没有必要使用AddDataTable 了。

直接把模板的表名改为窗口表名称即可http://www.foxtable.com/webhelp/topics/2627.htm

--  作者:lanbor
--  发布时间:2020/3/31 11:20:00
--  临时表直接打印再请教

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


If Tables(e.Form.name & "_table1").Rows.Count>0 Then
    Dim t1 As Table
    t1.DataSource = DataT ables(e.Form.name & "_table1")
    Dim i1 As Integer
    Dim Book As New XLS.Book(Projec tPath & "Attachments\\proc99_all.xls") \'9_report.xls")
    Dim sheet As XLS.Sheet = Book.Sheets(0)
    Dim Style As Xls.Style=book.NewStyle
    Style.BackColor=Color.Red
    ExcelPath="D:\\step00\\"
    Dim fl As String = ExcelPath & "ExcelReport\\proc99_all.xls"
    Sheet(7,0).Value = "<proc99_from_view_all_Table1>"  \'写入表名
    book.Build()
    book.save( fl ) \'fl
    Dim proc As New Process
    Proc.file=fl
    proc.Start()
End If

我用以上方法测试,系统报错为:未将实列引用到对象
请再我看看,语句上什么地主有错?
谢谢!


--  作者:有点蓝
--  发布时间:2020/3/31 11:48:00
--  
去掉下面代码

    Dim t1 As Table
    t1.DataSource = DataT ables(e.Form.name & "_table1")

--  作者:lanbor
--  发布时间:2020/3/31 11:59:00
--  再请教:我的报表只打出来1行记录,
修改后:
再请教:我的报表只打出来1行记录,
我应该再修改什么地方?
If Tables(e.Form.name & "_table1").Rows.Count>0 Then
    Dim i1 As Integer
    Dim Book As New XLS.Book(ProjectPath & "Attachments\\proc99_all.xls") \'9_report.xls")
    Dim sheet As XLS.Sheet = Book.Sheets(0)
    Dim Style As Xls.Style=book.NewStyle
    Style.BackColor=Color.Red
    ExcelPath="D:\\step00\\"
    Dim fl As String = ExcelPath & "ExcelReport\\proc99_all.xls"
    Sheet(7,0).Value = "<proc99_from_view_all_Table1>"  \'写入表名
    book.Build()
    book.save( fl ) \'fl
    Dim proc As New Process
    Proc.file=fl
    proc.Start()
End If


--  作者:有点蓝
--  发布时间:2020/3/31 12:10:00
--  
http://www.foxtable.com/webhelp/topics/0201.htm