一个label就是一条detail,分布成4列16行,用A4纸打印。

这与通常的报表有点不一样,通常报表的明细都是一条一行;而现在要每4条放在一行,这需要用到“多列格式化”属性。

先说打印条码的吧,条码图片怎么来?

下载生成条码的exe文件Barcode.exe以及dll文件Zen.Barcode.Core.dll,通过shell函数调用执行Barcode.exe文件生成条码图片

在给报表传数的table里面插入条码图片:

Private Sub AddBarcodeImages(ByVal DTab As DataTable)
        If Not DTab Is Nothing Then

            DTab.Columns.Add("BCIMAGE", Type.GetType("System.Byte[]"))

            Dim r As DataRow
            For Each r In DTab.Rows

                Try
                    Dim BatchNo As String = r.Item("Line_No") & "-" & CStr(r.Item("Operator")).Trim
                    Dim sFileName As String = "C:\TEMP\" & BatchNo & ".jpg"

                    Shell("Barcode.exe " & BatchNo & " 36", AppWinStyle.NormalFocus, True)

                    Dim fs As IO.FileStream = New IO.FileStream(sFileName, IO.FileMode.Open)
                    Dim fi As IO.FileInfo = New IO.FileInfo(sFileName)
                    Dim fl As Long = fi.Length
                    Dim lung As Integer = Convert.ToInt32(fl)
                    Dim imgBytes As Byte() = New Byte(lung - 1) {}
                    fs.Read(imgBytes, 0, lung)
                    fs.Close()
                    r.Item("BCIMAGE") = imgBytes

                    Dim f As IO.File
                    Try
                        f.Delete(sFileName)
                    Catch ex As Exception
                        Console.WriteLine(ex.ToString)
                    End Try

                Catch ex As Exception
                    'MessageBox.Show(ex.ToString)
                End Try
            Next
        End If
    End Sub


获取条码图片后传递数据给报表,报表的设计:

posted on 2013-05-14 12:24  vinsonLu  阅读(1609)  评论(0编辑  收藏  举报