Foxtable(狐表)用户栏目专家坐堂 → [求助]条码打印


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

主题:[求助]条码打印

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


加好友 发短信
等级:七尾狐 帖子:1710 积分:11410 威望:0 精华:0 注册:2015/6/22 8:11:00
[求助]条码打印  发帖心情 Post By:2022/7/25 7:28:00 [只看该作者]

老师好,下面是Excel报表事件,我想直接打印“条码管理表”不打印父,另一组是按钮事件。两组代码不知怎样修改。谢谢老师。

If e.Book.TempLate = "模板" Then
    If e.region = "条码管理" Then     老师,能换成打印窗口表吗?
        If e.DataRow Is Nothing OrElse e.DataRow.IsNull("条码一") Then '如果是空行或者Lot列为空
            Dim img As New System.Drawing.Bitmap(1,1) '生成一个空白图片
            img.Save(ProjectPath & "Images\BarCode.gif")
        Else '否则生成条形码图片
            Dim Bar As New BarCodeBuilder
            Bar.Symbology = Barpro.Symbology.Ean13
            Bar.Code = e.DataRow("条码一")
            Bar.BarRatio = 0.3
            Bar.BarHeight = 8
            bar.SaveImage(ProjectPath & "Images\BarCode.gif",300)
        End If

        If e.DataRow Is Nothing OrElse e.DataRow.IsNull("条码二") Then '如果是空行或者Lot列为空
            Dim img As New System.Drawing.Bitmap(1,1) '生成一个空白图片
            img.Save(ProjectPath & "Images\BarCode1.gif")
        Else '否则生成条形码图片
            Dim Bar As New BarCodeBuilder
            Bar.Symbology = Barpro.Symbology.Ean13
            Bar.Code = e.DataRow("条码二")
            Bar.BarRatio = 0.3
            Bar.BarHeight = 8
            bar.SaveImage(ProjectPath & "Images\BarCode1.gif",300)
        End If

If e.DataRow Is Nothing OrElse e.DataRow.IsNull("条码三") Then '如果是空行或者Lot列为空
            Dim img As New System.Drawing.Bitmap(1,1) '生成一个空白图片
            img.Save(ProjectPath & "Images\BarCode2.gif")
        Else '否则生成条形码图片
            Dim Bar As New BarCodeBuilder
            Bar.Symbology = Barpro.Symbology.Ean13
            Bar.Code = e.DataRow("条码三")
            Bar.BarRatio = 0.3
            Bar.BarHeight = 8
            bar.SaveImage(ProjectPath & "Images\BarCode2.gif",300)
        End If
    End If
End If

下面是按钮代码
Dim Book As New XLS.Book(ProjectPath & "Attachments\模板.xls")
Dim fl As String = ProjectPath & "Reports\模板.xls"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()








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


加好友 发短信
等级:超级版主 帖子:107381 积分:546178 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/7/25 8:43:00 [只看该作者]


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


加好友 发短信
等级:七尾狐 帖子:1710 积分:11410 威望:0 精华:0 注册:2015/6/22 8:11:00
  发帖心情 Post By:2022/7/27 6:07:00 [只看该作者]

老师好,打印条形码报错,去掉标出的代码就好了。
If e.Book.TempLate = "模板" Then
    If e.region = "条码管理" Then
        If e.DataRow Is Nothing OrElse e.DataRow.IsNull("条码一") Then '如果是空行或者Lot列为空
            Dim img As New System.Drawing.Bitmap(1,1) '生成一个空白图片
            img.Save(ProjectPath & "Images\BarCode.gif")
        Else '否则生成条形码图片
            Dim Bar As New BarCodeBuilder
            Bar.Symbology = Barpro.Symbology.Ean13
            Bar.Code = e.DataRow("条码一")
            Bar.BarRatio = 0.3
            Bar.BarHeight = 8
            bar.SaveImage(ProjectPath & "Images\BarCode.gif",300)
        End If
       

If e.DataRow Is Nothing OrElse e.DataRow.IsNull("条码二") Then '如果是空行或者Lot列为空
            Dim img As New System.Drawing.Bitmap(1,1) '生成一个空白图片
            img.Save(ProjectPath & "Images\BarCode1.gif")
        Else '否则生成条形码图片
            Dim Bar As New BarCodeBuilder
            Bar.Symbology = Barpro.Symbology.Ean13
            Bar.Code = e.DataRow("条码二")
            Bar.BarRatio = 0.3
            Bar.BarHeight = 8
            bar.SaveImage(ProjectPath & "Images\BarCode1.gif",300)
       End If

        If e.DataRow Is Nothing OrElse e.DataRow.IsNull("条码三") Then '如果是空行或者Lot列为空
            Dim img As New System.Drawing.Bitmap(1,1) '生成一个空白图片
            img.Save(ProjectPath & "Images\BarCode2.gif")
        Else '否则生成条形码图片
            Dim Bar As New BarCodeBuilder
            Bar.Symbology = Barpro.Symbology.Ean13
            Bar.Code = e.DataRow("条码三")
            Bar.BarRatio = 0.3
            Bar.BarHeight = 8
            bar.SaveImage(ProjectPath & "Images\BarCode2.gif",300)
        End If       
    End If
End If

第二行重复了第一行的条形码图


图片点击可在新窗口打开查看此主题相关图片如下:条码二.jpg
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:条码1.jpg
图片点击可在新窗口打开查看



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


加好友 发短信
等级:超级版主 帖子:107381 积分:546178 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/7/27 8:45:00 [只看该作者]

应该是第二行条码二没有值,或者是一个空字符串,或者是一个不符合ean13规则的条码数据

 回到顶部