以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]打印 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=187461) |
||||
-- 作者:江南小镇 -- 发布时间:2023/7/20 5:40:00 -- [求助]打印 老师好,打开打印窗口在ComboBox2控件中选择用电记录然后点击打印按钮报错,选择不同的表点击打印按钮报错不同的内容。
|
||||
-- 作者:有点蓝 -- 发布时间:2023/7/20 9:06:00 -- 打印按钮遍历所有列的时候,排除掉隐藏的列 ComboBox2控件选择不同的表时候注意,有些是内部表,fill的时候不要设置数据源
|
||||
-- 作者:江南小镇 -- 发布时间:2023/7/22 7:40:00 -- 老师好 打印按钮遍历所有列的时候,排除掉隐藏的列搞不好。 Dim dst As Table = Tables("打印_Table1") Dim clb As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox2") Dim nbox1 As WinForm.NumericComboBox = e.Form.Controls("NumericComboBox1") Dim rbt As WinForm.RadioButton = e.Form.Controls("RadioButton1") Dim dt As DataTable = dst.DataTable If nbox1.value > dst.DataTable.DataCols.Count Then msgbox("合并列数不能大于表列数!",64,"提示") Else Dim bstr,kkk,kk As String Dim r,c,i1,i2,i3,m,n,n2,i,rm,rm2,ci As Integer Dim v As Integer = e.Form.Controls("NumericComboBox2").value \'表头高 Dim vv As Integer = e.Form.Controls("NumericComboBox3").value \'行高 Dim s,ss,z As String Dim s2 As String = "" Dim ss2 As String = "__________" Dim doc As New PrintDoc \'定义一个报表 For i=0 To e.Form.Controls("NumericComboBox4").value-1 Doc.Columns.Add() Next Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 5 \'设置上边距 Doc.PageSetting.BottomMargin = 5 \'设置下边距 Dim rt As New prt.RenderTable() \'定义一个表格对象 rt.Style.Gridlines.All = New prt.Linedef(e.Form.Controls("ColorLabel2").Color) \'灰色网格线 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中 rt.Style.Spacing.top = 5 \'表格上边距为5 If not e.Form.Controls("CheckBox3").Checked Then rt.Width = "Auto" \'表宽等于各列设置值之和 rt.CanSplitHorz = True \'允许表格在水平方向换页 End If \'设置标题 If e.Form.Controls("NumericComboBox4").value <= 1 Then Dim rs As New prt.RenderText() \'定义一个文本对象 rs.Text = e.Form.Controls("TextBox13").value \'设置标题 rs.Style.Font = New Font("宋体", 15 , FontStyle.Bold) \'设置标题字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 doc.Body.Children.Add(rs) \'将标题对象加入到表格中 End If doc.Body.Children.Add(rt) \'将表格对象加入到报表中 \'----------------------------------------------------------------- If e.Form.Controls("ComboBox6").value ="纵向" OrElse e.Form.Controls("ComboBox6").value = "" doc.PageSetting.Landscape = False \'打印方向 Else doc.PageSetting.Landscape = True \'横向打印方向 End If |
||||
-- 作者:有点蓝 -- 发布时间:2023/7/22 9:17:00 -- For Each tc As Col In dst.Cols if tc.visible = true Dim dc As DataCol = tc.DataCol If clb.GetItemChecked(c) Then \'判断选择列,真,导出,假,隐藏列 …… end if next
|
||||
-- 作者:江南小镇 -- 发布时间:2023/7/22 20:50:00 -- 老师,还是没有搞定。 For Each tc As Col In dst.Cols Dim dc As DataCol = tc.DataCol If clb.GetItemChecked(c) Then \'判断选择列,真,导出,假,隐藏列 ss = dc.name & "__________" \'求得列表头最大宽度 For i = 1 To Len(ss.split("_")(0)) m = Asc(Mid(ss, i, 1)) If m >= 0 And m <128 Then \' 英文 n = n + 1 Else \' 中文 n = n + 2 End If Next i3 = Math.Max(i3,n) For i=0 To i1 If v>0 Then rt.Rows(r).Height = v \'表头高度 End If rt.Cells(i,c).Text = ss.split("_")(i) \'设置表头内容 If ss2.split("_")(i)=ss.split("_")(i) And ss2.split("_")(i)<>"" And c<dt.datacols.count Then kk = kkk.Replace(ss.split("_")(i) & "_","@") rt.Cells(i,c-1).SpanCols = len(kk)-len(kk.Replace("@","")) \'合并多表头 End If Next r = i1 For Each cr As Row In dst.GetCheckedRows Dim dr As DataRow = cr.DataRow s = dr(dc) \'求得当前列各行中最大宽度 For i = 1 To Len(s) m = Asc(Mid(s, i, 1)) If m >= 0 And m <128 Then \' 英文 n2 = n2 + 1 Else \' 中文 n2 = n2 + 2 End If Next i3 = Math.Max(i3,n2) r +=1 \'行开始 \'设置单元格值 rt.Cells(r,c).Text = s z = "" If c>1 And rbt.Checked Then For i=1 To c z = z & rt.cells(r,i).text Next s = z End If \'合并指定前N列 If c <= nbox1.value Then If s <> s2 Or r-i1=dt.DataRows.Count Then If s=s2 Then rm2 = rm2+1 End If If rm2 <> 0 And s2<>"" And s2<>"0" Then rt.Cells(rm,c).SpanRows = rm2 End If s2 = s rm = r rm2 = 1 Else rm2 +=1 End If End If If vv>0 Then rt.Rows(r).Height = vv \'设置行高 End If n2 = 0 \'完成一行后初始化条件 Next If rt.Cells(i1,c).Text="" Then rt.Cells(0,c).SpanRows = i1+1 \'合并单表头 End If rt.Cols(c).Width = (i3+2.5)*1.8 \'设置列宽 Else rt.Cols(c).Width = 0 \'隐藏列 End If \'完成一列后初始化条件 ss2 = ss & ss2 i3 = 0 n = 0 c +=1 r = i1 Next |
||||
-- 作者:有点蓝 -- 发布时间:2023/7/24 9:04:00 -- For Each tc As Col In dst.Cols if tc.visible = true Dim dc As DataCol = tc.DataCol If clb.GetItemChecked(c) Then \'判断选择列,真,导出,假,隐藏列 ss = dc.name & "__________" \'求得列表头最大宽度 For i = 1 To Len(ss.split("_")(0)) m = Asc(Mid(ss, i, 1)) If m >= 0 And m <128 Then \' 英文 n = n + 1 Else \' 中文
|