Foxtable(狐表)用户栏目专家坐堂 → [求助]为什么同样都是一样的代码,不同电脑上打印出来的方向是相反的?但其他软件都是一样的


  共有2274人关注过本帖树形打印复制链接

主题:[求助]为什么同样都是一样的代码,不同电脑上打印出来的方向是相反的?但其他软件都是一样的

帅哥哟,离线,有人找我吗?
zto001
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
[求助]为什么同样都是一样的代码,不同电脑上打印出来的方向是相反的?但其他软件都是一样的  发帖心情 Post By:2019/12/16 21:58:00 [只看该作者]

[求助]为什么同样都是一样的代码,不同电脑上打印出来的方向是相反的?但其他软件都是一样的


Dim 锁定寄件人 As WinForm.CheckBox = e.Form.Controls("锁定寄件人")
Dim 打印模板 As WinForm.ComboBox = e.Form.Controls("打印模板")
Dim 默认打印机 As WinForm.ComboBox = e.Form.Controls("默认打印机")
Dim 默认当前店铺及打印设置 As WinForm.CheckBox = e.Form.Controls("默认当前店铺及打印设置")
Dim 店铺 As WinForm.DropDownBox = e.Form.Controls("店铺")
Dim 快递公司 As WinForm.DropDownBox = e.Form.Controls("快递公司")
Dim 寄件人 As WinForm.DropDownBox = e.Form.Controls("寄件人")
Dim 寄件省 As WinForm.DropDownBox = e.Form.Controls("寄件省")
Dim 寄件市 As WinForm.TextBox = e.Form.Controls("寄件市")
Dim 寄件区 As WinForm.TextBox = e.Form.Controls("寄件区")
Dim 寄件电话 As WinForm.TextBox = e.Form.Controls("寄件电话")
Dim 寄件地址 As WinForm.TextBox = e.Form.Controls("寄件地址")
Dim 解析内容 As WinForm.TextBox = e.Form.Controls("解析内容")
Dim 解析内容1 As WinForm.TextBox = e.Form.Controls("解析内容1")
Dim 收件人 As WinForm.DropDownBox = e.Form.Controls("sjr")
Dim 收件地址 As WinForm.TextBox = e.Form.Controls("sjdz")
Dim 收件区 As WinForm.TextBox = e.Form.Controls("sjq")
Dim 收件市 As WinForm.TextBox = e.Form.Controls("sjsi")
Dim 收件省 As WinForm.DropDownBox = e.Form.Controls("sjs")
Dim 收件电话 As WinForm.TextBox = e.Form.Controls("sjdh")
Dim 备注 As WinForm.TextBox = e.Form.Controls("备注")
Dim 运单编号 As WinForm.TextBox = e.Form.Controls("运单编号")
Dim 同时打印 As WinForm.CheckBox = e.Form.Controls("同时打印")
Dim 同时发货 As WinForm.CheckBox = e.Form.Controls("同时发货0")
Dim 下单 As WinForm.Button = e.Form.Controls("下单")
Dim 批量下单 As WinForm.CheckBox = e.Form.Controls("批量下单")
Dim 打印信息 As WinForm.TextBox = e.Form.Controls("打印信息")
If 店铺.value="" OrElse 快递公司.value="" OrElse 寄件人.value="" OrElse 寄件省.value="" OrElse 收件人.value="" OrElse 收件省.value="" OrElse 收件电话.value="" OrElse 寄件电话.value="" OrElse 寄件地址.value="" OrElse 收件地址.value="" OrElse 默认打印机.value="" OrElse 打印模板.value="" Then
    MessageBox.Show("请将红框区域填写完整!")
    Return
Else
    
    Select Case 下单.text
        Case "下单"
            SaveConfigValue("店铺", 店铺.Value)
            SaveConfigValue("快递公司", 快递公司.Value)
            SaveConfigValue("打印机", 默认打印机.Value)
            SaveConfigValue("打印模板", 打印模板.Value)
            SaveConfigValue("打印信息", 打印信息.Value)
            SaveConfigValue("寄件人", 寄件人.Value)
            SaveConfigValue("寄件电话", 寄件电话.Value)
            SaveConfigValue("寄件省", 寄件省.Value)
            SaveConfigValue("寄件市", 寄件市.Value)
            SaveConfigValue("寄件区", 寄件区.Value)
            SaveConfigValue("寄件地址", 寄件地址.Value)
            SaveConfigValue("批量下单", 批量下单.Checked)
            SaveConfigValue("同时发货", 同时发货.Checked)
            SaveConfigValue("同时打印", 同时打印.Checked)
            
            
            Tables("订单详情").Current.Save()
            If 批量下单.Checked=True Then

                If 同时发货.Checked=True Then
                    Tables("订单详情").Current("当前状态")= "已发货"
                    Tables("订单详情").Current("操作记录")= Date.Now & "[" & _姓名 & "]发货成功" & vbcrlf & Tables("订单详情").Current("操作记录")
                    Tables("订单详情").Current.Save
                End If
                
                Dim 新增行 As Row= Tables("订单详情").AddNew()
                新增行 ("所属店铺")=GetConfigValue("店铺", "")
                新增行 ("快递公司")=GetConfigValue("快递公司", "")
                新增行 ("打印信息")=GetConfigValue("打印信息", "")
                e.Form.Controls("打印模板").value=GetConfigValue("打印模板", "一联单")
                e.Form.Controls("默认打印机").value = GetConfigValue("打印机", DefaultPrinter)
                批量下单.Checked =GetConfigValue("批量下单", False)
                同时发货.Checked=GetConfigValue("同时发货", False)
                同时打印.Checked=GetConfigValue("同时打印", False)
                新增行 ("寄件人")=GetConfigValue("寄件人", "")
                新增行 ("寄件电话")=GetConfigValue("寄件电话", "")
                新增行 ("寄件省")=GetConfigValue("寄件省", "")
                新增行 ("寄件市")=GetConfigValue("寄件市", "")
                新增行 ("寄件区")=GetConfigValue("寄件区", "")
                新增行 ("寄件地址")=GetConfigValue("寄件地址", "")
                
                Return
            Else
                e.Form.Close
            End If
        Case "修改"
            DataTables("订单详情").AllowEdit = True
            e.Form.Controls("sjr") .Enabled=True
            e.Form.Controls("sjdh").Enabled=True
            e.Form.Controls("sjdz").Enabled=True
            e.Form.Controls("sjs").Enabled=True
            e.Form.Controls("店铺") .Enabled=True
            e.Form.Controls("寄件地址") .Enabled=True
            e.Form.Controls("寄件电话") .Enabled=True
            e.Form.Controls("寄件人") .Enabled=True
            e.Form.Controls("寄件省") .Enabled=True
            e.Form.Controls("快递公司").Enabled=True
            e.Form.Controls("解析内容") .Visible=True
            e.Form.Controls("存至联系簿") .Visible=True
            e.Form.Controls("存至联系簿1") .Visible=True
            e.Form.Controls("备注").Enabled=True
            e.Form.Controls("取消").text="关闭"
            e.Form.Controls("下单") .Text="保存"
            e.Form.Controls("修改") .Visible=True
            
            
        Case "保存"
            Tables("订单详情").Current.Save()
            DataTables("订单详情").AllowEdit = False
            e.Form.Close
        Case "下单并打印"
            SaveConfigValue("店铺", 店铺.Value)
            SaveConfigValue("快递公司", 快递公司.Value)
            SaveConfigValue("打印机", 默认打印机.Value)
            SaveConfigValue("打印模板", 打印模板.Value)
            SaveConfigValue("打印信息", 打印信息.Value)
            SaveConfigValue("寄件人", 寄件人.Value)
            SaveConfigValue("寄件电话", 寄件电话.Value)
            SaveConfigValue("寄件省", 寄件省.Value)
            SaveConfigValue("寄件市", 寄件市.Value)
            SaveConfigValue("寄件区", 寄件区.Value)
            SaveConfigValue("寄件地址", 寄件地址.Value)
            SaveConfigValue("同时打印", 同时打印.Checked )
            SaveConfigValue("同时发货", 同时发货.Checked)
            SaveConfigValue("批量下单", 批量下单.Checked)
            Tables("订单详情").Current.Save()
            Dim hang As Row
            hang= Functions.Execute("取单",Tables("订单详情").Current)
            If hang Is Nothing Then
                Forms("主页").Controls("操作信息").value="单号获取失败!"
                Return
            End If
            Functions.Execute("打印",Tables("订单详情").Current ,默认打印机.value ,打印模板.value )
            Tables("订单详情").Current("操作记录")= Date.Now & "[" & _姓名 & "]进行打印" & vbcrlf & Tables("订单详情").Current("操作记录")
            Tables("订单详情").Current.Save
            
            If 同时发货.Checked=True Then
                Tables("订单详情").Current("当前状态")= "已发货"
                Tables("订单详情").Current("操作记录")= Date.Now & "[" & _姓名 & "]发货成功" & vbcrlf & Tables("订单详情").Current("操作记录")
                Tables("订单详情").Current.Save
            End If
            If 批量下单.Checked=True Then
                Dim 新增行 As Row= Tables("订单详情").AddNew()
                新增行 ("所属店铺")=GetConfigValue("店铺", "")
                新增行 ("快递公司")=GetConfigValue("快递公司", "")
                新增行 ("打印信息")=GetConfigValue("打印信息", "")
                e.Form.Controls("打印模板").value=GetConfigValue("打印模板", "一联单")
                e.Form.Controls("默认打印机").value = GetConfigValue("打印机", DefaultPrinter)
                e.Form.Controls("同时打印").Checked= GetConfigValue("同时打印", False)
                e.Form.Controls("同时发货0").Checked= GetConfigValue("同时发货", False)
                e.Form.Controls("批量下单").Checked= GetConfigValue("批量下单", False)
                
                新增行 ("寄件人")=GetConfigValue("寄件人", "")
                新增行 ("寄件电话")=GetConfigValue("寄件电话", "")
                新增行 ("寄件省")=GetConfigValue("寄件省", "")
                新增行 ("寄件市")=GetConfigValue("寄件市", "")
                新增行 ("寄件区")=GetConfigValue("寄件区", "")
                新增行 ("寄件地址")=GetConfigValue("寄件地址", "")
                
                Return
            End If
            e.Form.Close
    End Select
End If



以上执行的函数是以下

Dim 当前行 As Row = Args(0)
Dim 打印() As String = 当前行("打印信息").split("\")

Dim doc As New PrintDoc '定义一个报表

doc.PageSetting.Width =76 '纸张宽度为100毫米
doc.PageSetting.Height =130 '纸张高度为120毫米

Dim rt As New prt.RenderTable() '定义一个表格对象
Doc.PageSetting.LeftMargin = 0 '设置左边距
Doc.PageSetting.RightMargin = 0 '设置右边距
Doc.PageSetting.TopMargin = 0 '设置上边距
Doc.PageSetting.BottomMargin = 0 '设置下边距
rt.Width = "Parent.Width" '对象宽度等于页面宽度
rt.Height = "Parent.Height" '对象高度等于页面高度
'指定行数?列数?列宽?行高
rt.Rows.Count = 10 '设置总行数
rt.Cols.Count = 4 '设置总列数
rt.Rows(0).Height = 9 '
rt.Rows(1).Height = 0 '
rt.Rows(2).Height = 17 '
rt.Rows(3).Height = 11 '
rt.Rows(4).Height = 10 '
rt.Rows(5).Height = 7 '
rt.Rows(6).Height = 13 '
rt.Rows(7).Height = 6 '
rt.Rows(8).Height = 6 '
rt.Rows(9).Height = 37 '
rt.Rows(10).Height = 14 '
'设置列宽度
rt.Cols(0).Width = 8.5 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
rt.Cols(1).Width = 29.5
rt.Cols(2).Width = 23
rt.Cols(3).Width = 15
'设置合并单元格
'rt.Cells(0,0).SpanCols =2 '
rt.Cells(1,0).SpanCols = 2 '
rt.Cells(1,2).SpanCols = 2 '
rt.Cells(2,0).SpanCols = 4 '
rt.Cells(3,0).SpanCols = 4 '
rt.Cells(4,0).SpanCols = 2 '
rt.Cells(5,1).SpanCols = 2 '
rt.Cells(5,0).SpanRows = 2 '
rt.Cells(6,1).SpanCols = 2 '
rt.Cells(7,0).SpanRows = 2 '
rt.Cells(7,1).SpanCols = 2 '
rt.Cells(8,1).SpanCols = 2 '
rt.Cells(9,0).SpanCols = 4 '
rt.Cells(10,0).SpanCols = 2 '
rt.Cells(10,2).SpanCols = 2 '
rt.Cells(5,3).SpanRows = 4 '

'设置表格样式
rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
rt.Style.GridLines.All = New prt.Linedef '设置网格线
rt.Style.GridLines.All = new Prt.LineDef(Color.DarkGray) '设置网格颜色
rt.Style.TextAlignVert =  prt.AlignVertEnum.Top '内容靠上对齐
'''下面很简单,指定每一个单元格的内容
rt.Cells(0,1).Style.BackColor = Color.Black
Dim rx As New prt.RenderText '定义一个文本对象
rx.Text = 打印(2) ' 打印(20)  '退件标识
rx.Style.Font = New Font("微软雅黑", 14, FontStyle.Bold)
rx.Style.TextColor = Color.white
rt.Cells(0,1).RenderObject = rx '将文本对象放置在单元格中
rt.Cells(0,3).Text= ""  '"第1/1页"
rt.Cells(0,3).Style.Font = New Font("微软雅黑", 7, FontStyle.Bold) '设置字体
rt.Cells(0,2).Text= "普通订单"
rt.Cells(0,2).Style.Font = New Font("微软雅黑", 14, FontStyle.Bold) '设置字体
rt.Cells(3,0).Text= 当前行("大头笔")  '大头笔
rt.Cells(3,0).Style.Font = New Font("微软雅黑",20, FontStyle.Bold) '设置字体
rt.Cells(4,0).Text= 当前行("集包地") '集包地
rt.Cells(4,0).Style.Font = New Font("微软雅黑", 16, FontStyle.Bold) '设置字体
rt.Cells(4,2).Text= Date.Now
rt.Cells(4,2).Style.FontSize = 8  '字体大小为16磅
rt.Cells(5,1).Text= 当前行("收件人") & " " & 当前行("收件电话")  '收件人 电话
rt.Cells(5,1).Style.Font = New Font("微软雅黑", 9, FontStyle.Bold) '设置字体
rt.Cells(6,1).Text= 当前行("收件省") & " " &当前行("收件市")& " " &当前行("收件区")& " " &当前行("收件地址") '收件地址
rt.Cells(6,1).Style.Font = New Font("微软雅黑",9, FontStyle.Regular) '设置字体
rt.Cells(5,0).Text= "收"
rt.Cells(5,0).Style.Font = New Font("微软雅黑", 14, FontStyle.Bold) '设置字体
rt.Cells(7,0).Text= "寄"
rt.Cells(7,0).Style.Font = New Font("微软雅黑", 14, FontStyle.Bold) '设置字体
rt.Cells(7,1).Text= 当前行("寄件人") & " "& 当前行("寄件电话")  '寄件人电话
rt.Cells(8,1).Text= 当前行("寄件省")& " "&当前行("寄件市")& " "&当前行("寄件区")& " "&当前行("寄件地址") '寄件地址
rt.Cells(8,1).Style.Font = New Font("微软雅黑",8, FontStyle.Regular) '设置字体
rt.Cells(9,0).Text=当前行("内件详情") ' "物品:" & 当前行(9)  '内件
rt.Cells(9,0).Style.Font = New Font("微软雅黑",8, FontStyle.Bold) '设置字体
rt.Cells(10,0).Text= "本次服务适用于中通官网(www.zto.com)公示的快递服务协议条款.您对此单的签收代表您已收到快件且包装完好无损."
rt.Cells(10,0).Style.Font = New Font("微软雅黑",6, FontStyle.Regular) '设置字体
rt.Cells(10,2).Text=  打印(2) '当前行(20)  '退件标识
rt.Cells(10,2).Style.Font = New Font("微软雅黑",14, FontStyle.Bold) '设置字体
rt.Cells(4,3).Text= " 已验视 " & Chr(13) & Chr(10) & " 已实名"
rt.Cells(4,3).Style.Font = New Font("微软雅黑",9, FontStyle.Bold) '设置字体
rt.Cells(4,3).Style.GridLines.All = new Prt.LineDef(0.5,Color.Black) '设置网格颜色
Dim rg As New prt.RenderGraphics
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.Code128
bar.Code = 当前行("运单编号")    '条形码
rg = new prt.RenderGraphics
bar.DrawOnCanvas(rg.Graphics,3,0,1)
rt.Cells(2,0).RenderObject = rg  '将单元格内容设置为图片对象rm
Dim rbc As New prt.RenderBarCode()
rbc.Height = 1
rbc.BarCodeType = BarCodeEnum.Code128
rbc.BarDirection = BarDirectionEnum.Up
rbc.Text = 当前行("运单编号")
rbc.ShowText = False
rt.Cells(5,3).RenderObject = rbc  '将单元格内容设置为图片对象rm
doc.Body.Children.Add(rt) '将表格对象加入到报表中
Doc.PrinterName = Args(1)
Doc.Preview() '预览报表

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106097 积分:539590 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/16 22:13:00 [只看该作者]

添加多一个打印按钮,直接打印,Doc.Print(),不要在预览后的窗口里点击打印。

另外其他电脑有没有添加对应的打印纸张?并设置为默认纸张

 回到顶部
帅哥哟,离线,有人找我吗?
zto001
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
  发帖心情 Post By:2019/12/20 17:13:00 [只看该作者]

能不能用代码让打印出来的东西转180度,由反变正?老是换纸方向太麻烦了

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106097 积分:539590 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/20 17:27:00 [只看该作者]

这个好像没有

 回到顶部