以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]异步函数请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=153447)

--  作者:2900819580
--  发布时间:2020/8/11 11:17:00
--  [求助]异步函数请教

Dim cn() As String = {"OA","ksg"}
Dim st As Date = Date.Now
\'要测试耗时的代码
\'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1")
Dim id As Integer = tab.TabPages.Count
For Each c As String In cn
    Dim lst As List(Of String) = Conne ctions(c).GetTableNames
    If Forms("数据加载提醒").Opened = False Then Forms("数据加载提醒").Open
    For i As Integer = 0 To  lst.Count - 1
        If i = 2 Then Exit Sub
        tab.TabPages.Add(c & lst(i), lst(i))
        Functions.AsyncExecute("MySaveExcel",c,lst(i),id + i) ‘异步函数出问题。
       \' Functions.Execute("MySaveExcel",c,lst(i),id + i)  \'常规调用函数没有问题,

    Next
Next

If Forms("数据加载提醒").Opened = True Then Forms("数据加载提醒").Close

MessageBox.Show("数据备份完成!耗时: " & (Date.Now - st).TotalSeconds & "秒")
e.Form.Close

 

以下是内部函数!

Dim tab As WinForm.TabControl = Forms("管理调试").Controls("TabControl1")
Dim c As String = args(0)
Dim lstr As String = args(1)
Dim id As Integer = args(2)
Dim tbl As WinForm.Table
tbl = Forms("管理调试").CreateSQLTable(c & lstr,"sel ect * from {" & lstr & "} " ,c)
\'tbl.Dock = 5
tab.Tabpages(id).AddControl(tbl)
Tables(Forms("管理调试").Name & "_" & tbl.Name).SaveExcel("D:" &  Format(Functions.Execute("返回服务器日期"),"yyyy_MM_d") & "\\" & c & "\\" & lstr & ".xls" ,lstr)

[此贴子已经被作者于2020/8/11 11:17:43编辑过]

--  作者:有点蓝
--  发布时间:2020/8/11 13:47:00
--  
这种函数不能异步调用:http://www.foxtable.com/mobilehelp/topics/277.htm
--  作者:2900819580
--  发布时间:2020/8/11 14:21:00
--  

老师看了一下,Excel报表方式可能用得上,但我不是用报表 ,应该怎么改。

Dim Book As New XLS.Book(ProjectPath & "Attachments\\资料卡.xls")
Dim
fl As String = ProjectPath & "Reports\\资料卡.xls"
book
.AddDataTa ble("员工","数据源名称","Sel ect * from {员工} where 姓名 = \'王伟\'")
Book
.Build()
Book
.Save(fl)
Dim
Proc As New Process
Proc
.File = fl
Proc
.Start()


--  作者:有点蓝
--  发布时间:2020/8/11 14:25:00
--  
这种方式导出数据:http://www.foxtable.com/webhelp/topics/1148.htm

把帮助中从table取数据改为从数据库取数据:http://www.foxtable.com/webhelp/topics/0696.htm

--  作者:2900819580
--  发布时间:2020/8/11 15:04:00
--  
以下是引用有点蓝在2020/8/11 14:25:00的发言:
这种方式导出数据:http://www.foxtable.com/webhelp/topics/1148.htm

把帮助中从table取数据改为从数据库取数据:http://www.foxtable.com/webhelp/topics/0696.htm

 

这样逐行的生成,不是更慢吗?没有更好的方法了吗?

 


--  作者:有点蓝
--  发布时间:2020/8/11 15:09:00
--  
1楼的方式不要使用异步。或者设计模板导出