以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]执行wrt.BuildOne(dr)后陷入死循环  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=161030)

--  作者:jerzhh
--  发布时间:2021/3/3 12:11:00
--  [求助]执行wrt.BuildOne(dr)后陷入死循环
最近刚换了电脑,在老电脑上可以正常执行的Word报表无法正常运行,经设置断点分析后发现执行wrt.BuildOne(dr)后陷入死循环,请问是什么原因?
--  作者:有点蓝
--  发布时间:2021/3/3 12:17:00
--  
贴出具体代码,或者上传实例说明
--  作者:jerzhh
--  发布时间:2021/3/3 12:36:00
--  
执行后对话框“OK1”出现,“OK2”和“OK3”始终不出现
代码如下:

\'--"M00_主界面" "2_BTN2_15生成概览"-------------
Dim YearStart, YearEnd As Integer
Dim dt As DataTable = DataTables("学习班历史数据")
YearStart = Math.Max(e.Form.Controls("2_NCB2_13起始年度").Value,dt.Compute("Min(年度)"))
e.Form.Controls("2_NCB2_13起始年度").Value = YearStart
YearEnd = Math.Min(e.Form.Controls("2_NCB2_14终止年度").Value,dt.Compute("Max(年度)"))
e.Form.Controls("2_NCB2_14终止年度").Value = YearEnd
If YearStart > YearEnd Then
    MessageBox.Show("起始年度不能超过终止年度!")
    Return
End If
Dim Fstr As String = "年度 >= " & YearStart & " And 年度 <= " & YearEnd
\'-----分项统计:年度、期数-----------------
Dim drs As List(Of DataRow) = dt.Select(Fstr)
Dim ReportName As String = ProjectPath & "项目信息\\学习班简报\\概览_" & IIF(YearStart = YearEnd, YearEnd, YearStart & " - " & YearEnd) & "年度" & ".doc"
Dim TemplateName As String =  ProjectPath & "报表模板\\T33_ISCD学习班概览_模板.doc"
\'-----生成"学习班简报"-----------------
Dim wrt As New WordReport(Tables("学习班历史数据"), TemplateName, ReportName)
\'-----筛选范围-----------------
wrt.Replace("[A00]",IIF(YearStart = YearEnd, YearEnd, YearStart & " - " & YearEnd) & "年度")
\'-----分项统计:年度、期数-----------------
wrt.Replace("[A01]",IIF(YearStart = YearEnd,YearStart & "年", "从" & YearStart & "年 至 " & YearEnd & "年") & " 历时 " & Cstr(YearEnd - YearStart + 1) & " 年")
wrt.Replace("[A02]","共举办了" & drs.Count & "期")
\'-----分项统计:办班地域-----------------
Dim Provs As List(Of String) = dt.GetValues("省" ,Fstr)
Dim StrProvs As String =  dt.GetComboListString("省",Fstr,"省").Replace("|","、")
Dim Citys As List(Of String) = dt.GetValues("城市",Fstr)
Dim StrCitys As String =  dt.GetComboListString("城市",Fstr,"省,城市").Replace("|","、")
wrt.Replace("[A03]","全国" & Provs.Count & "个省市区" & "(" & StrProvs & ")" & "的" & Citys.Count & "座城市" & "(" & StrCitys &  ")")
MessageBox.Show("OK1")
\'---生成概览文件------------------------------
wrt.BuildOne(drs(0))
MessageBox.Show("OK2")
wrt.Quit()
MessageBox.Show("OK3")
MessageBox.Show("学习班概览文件生成!")

--  作者:有点蓝
--  发布时间:2021/3/3 12:51:00
--  
电脑是不是安装了wps?另外看看是不是弹出了什么出错窗口被其它程序界面挡住了
--  作者:jerzhh
--  发布时间:2021/3/3 13:10:00
--  
两台电脑都是安装了WPS和Office2003,没有任何出错信息。在老电脑上运行无碍,新电脑就卡机
--  作者:jerzhh
--  发布时间:2021/3/3 13:37:00
--  
跟我的电脑系统有关系吗?


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


--  作者:有点蓝
--  发布时间:2021/3/3 13:38:00
--  
word报表不支持wps,卸载wps,或者把word文档不要关联到wps
--  作者:jerzhh
--  发布时间:2021/3/3 13:53:00
--  
谢谢!卸载WPS后确实可以正常运行了。
但我的老电脑也装了WPS,而且是关联到WPS,为什么又能正常运行呢?

--  作者:有点蓝
--  发布时间:2021/3/3 14:03:00
--  
这就不清楚了