以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 帮忙看一下哪错了 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=149073) |
-- 作者:deliangzhaoe -- 发布时间:2020/4/22 19:20:00 -- 帮忙看一下哪错了 打印按钮报错: String was not recognized as a valid DateTime. 打印按钮代码如下: \'页面设置 Dim doc As New PrintDoc \'定义一个报表 Doc.PageSetting.LeftMargin = 15 Doc.PageSetting.BottomMargin = 15 Doc.PageSetting.TopMargin = 15 Doc.PageSetting.rightMargin = 15 Dim rm As prt.RenderEmpty \'定一个空对象 doc.Pagesetting.LandScape = True \'设置页脚 Dim yj As New prt.RenderText \'定义一个文本对象 yj = New prt.RenderText \'设置文本对象的内容 yj.Text = "第[PageNo]页 共[PageCount]页" \'设置文本内容 yj.Style.TextAlignHorz = prt.AlignHorzEnum.center \'页脚中间对齐 yj.Style.FontSize = 9 \'字体大小为10磅 yj.Style.Padding.Bottom = -10 \'底端内容缩进10毫米 Doc.PageFooter = yj \'作为页脚使用 Dim tbl8 As Table = Tables("隐患排查治理台账") \'排查表 Dim rt8 As Prt.RenderTable Dim rx8 As prt.RenderText Dim Rows8 As List(Of DataRow) \'设置二级标题 rx8 = New prt.RenderText rx8.Style.FontSize = 16 rx8.Style.Spacing.Bottom = 5 Dim dr As String = Forms("mainform").controls("安全检查台账企业名称").value rx8.text = dr & vbcrlf & "隐患排查台账" \'表标题显示企业名称 rx8.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题水平居中 doc.Body.Children.Add(rx8) \'设置表格样式 rt8 = New prt.RenderTable rt8.Style.TextAlignVert = prt.AlignVertEnum.Center rt8.Style.GridLines.All = New prt.LineDef(0.3,Color.blue) rt8.Style.Spacing.Bottom = 5 rt8.CellStyle.Spacing.All = 1 rt8.Style.Font = tbl8.Font \'设置表格细节 Rows8 = tbl8.DataTable.Select("企业名称 Like \'*" & Forms("mainform").controls("安全检查台账企业名称").value & "*\' and 年度 Like \'*" & Forms("mainform").controls("安全检查台账年度").value & "*\' and 检查时间 >= #" & Forms("mainform").controls("DateTimePicker8").Value & "# and 检查时间 <= #" & Forms("mainform").controls("DateTimePicker9").Value & "#","检查时间") \'指定符合条件的行和排序方式 Dim nms8() As String = {"年度","检查类型","检查时间","所在部门","隐患内容","整改措施","隐患照片","责任人","完成时间","备注"} Dim caps() As String = {"序号","检查类型","检查时间","所在部门","隐患内容","整改措施","隐患照片","责任人","完成时间","备注"} \'自定义列名 For c As Integer = 0 To nms8.length - 1 Dim ary() As String = caps(c).split("|") For i As Integer = 0 To ary.length-1 rt8.cells(i, c).text = ary(i) Next \'打印的列标题自定义 rt8.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 rt8.Cols(0).Width = 15 \'设置各列宽度 rt8.Cols(1).Width = 30 rt8.Cols(2).Width = 30 rt8.Cols(3).Width = 35 rt8.Cols(4).Width = 60 rt8.Cols(5).Width = 50 rt8.Cols(6).Width = 50 rt8.Cols(7).Width = 25 rt8.Cols(8).Width = 30 rt8.Cols(9).Width = 25 For r As Integer = 0 To Rows8.Count -1 If c=0 Then rt8.Cells(r + 1, c).Text = r+1 \'增加了序号列,并自动填充 Else rt8.Cells(r + 1, c).Text = rows8(r)(tbl8.Cols(nms8(c)).Name) End If Next Next rt8.RowGroups(0,1).Header = prt.TableHeaderEnum.All doc.Body.Children.Add(rt8) Doc.Preview() \'预览报表 请老师看一下哪错了,怎么改?谢谢 |
-- 作者:有点蓝 -- 发布时间:2020/4/23 9:03:00 -- 调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看是那一句代码有问题 |
-- 作者:deliangzhaoe -- 发布时间:2020/4/24 7:56:00 -- 这两段有问题: Dim nms8() As String = {"年度","检查类型","检查时间","所在部门","隐患内容","整改措施","隐患照片","责任人","完成时间","备注"} Dim caps() As String = {"序号","检查类型","检查时间","所在部门","隐患内容","整改措施","隐患照片","责任人","完成时间","备注"} \'自定义列名 之前都是这么做的,没问题,只有这一段出了问题 |
-- 作者:pyh6918 -- 发布时间:2020/4/24 8:16:00 -- 是不是这两句的上一句出了问题,SQL数据源时间用 ‘ 号括起来。 |
-- 作者:有点蓝 -- 发布时间:2020/4/24 9:13:00 -- DateTimePicker8、DateTimePicker9这些是日期控件吗?有没有选日期?如果多个条件可能有一些没有输入的,参考这种用法拼接表达式条件:http://www.foxtable.com/webhelp/topics/1058.htm |
-- 作者:deliangzhaoe -- 发布时间:2020/4/24 20:03:00 -- DateTimePicker8、DateTimePicker9是空值的原因 改了,加了个判断 谢谢大家
|