以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 打印报错 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151467) |
-- 作者:deliangzhaoe -- 发布时间:2020/6/23 21:23: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 = 10 \'字体大小为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("更多查询条件").controls("startdate0").Value & "# and 考核日期 <= #" & Forms("更多查询条件").controls("enddate0").Value & "#","考核日期 DESC") \'指定符合条件的行和排序方式 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).Text = tbl8.Cols(nms8(c)).Name \'使用原列名 rt8.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 \'rt8.Cols(c).Width = tbl8.Cols(c).PrintWidth \'根据原表格确定列宽 rt8.Cols(0).Width = 12 \'设置各列宽度 rt8.Cols(1).Width = 12 rt8.Cols(2).Width = 25 rt8.Cols(3).Width = 25 rt8.Cols(4).Width = 50 rt8.Cols(5).Width = 40 rt8.Cols(6).Width = 15 rt8.Cols(7).Width = 25 rt8.Cols(8).Width = 25 rt8.Cols(9).Width = 25 rt8.Cols(10).Width = 20 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/6/23 21:53:00 -- http://www.foxtable.com/webhelp/topics/1485.htm,看是哪一句代码出错 startdate0是日期控件还是文本框? msgbox("企业名称 Like \'*" & Forms("mainform").controls("目标考核企业名称").value & "*\' And 年度 Like \'*" & Forms("mainform").controls("目标考核年度").value & "*\'and 考核日期 >= #" & Forms("更多查询条件").controls("startdate0").Value & "# and 考核日期 <= #" & Forms("更多查询条件").controls("enddate0").Value & "#")
|