在水晶报表中使用一维和二维条码
本文思路来自于:http://topic.csdn.net/u/20080306/13/b471356c-d5d8-4914-bfc0-bb5a742b9c1f.html
什么是一维条码
![](/images/cnblogs_com/babyt/11710834552362172_small.jpg)
http://baike.baidu.com/view/13740.html
什么是二维条码
![](https://www.cnblogs.com/images/cnblogs_com/babyt/11623670672112966_small.jpg)
http://baike.baidu.com/view/587003.htm
在一般的应用系统开发中,一般都是通过设置文字(数字)的字体为条码字体(code3of9 或 code 128 等 ) 来实现的
但是在水晶报表中,使用同样的方法,这些条码字体却出不来条码。
国外市场上出现了专门针对水晶报表的条码,其中code3of9是免费的,其余都要收费。
在上面的帖子中提到的思路是这样的:
首先用应用程序接口生成条码图片(需注意精度)
将条码图片保存到数据库中
然后在水晶报表中将这个对象显示出来就行了。
本文所涉及到的DotNetBarCode可参考以下网址
DotNetBarcode.dll
http://www.geocities.jp/japan_inf/DotNetBarcode/
http://hi.baidu.com/optical/blog/item/4849d4b4a0ad8d708bd4b21c.html
以下内容摘自原帖:
Sub QRCodeSaveRead()
bc1.Type = DotNetBarcode.Types.QRCode
bc1.PrintChar = True
![](/Images/OutliningIndicators/InBlock.gif)
'保存QRCode图片
strQRCode = ""
strQRCode = Trim(txtCode.Text) + " " + _
Trim(txtTLot1.Text) + " " + _
txtEPack2.Text
Panel1.Refresh()
bc1.QRSave(strQRCode, "QRCodeBmp.bmp", 2)
![](/Images/OutliningIndicators/InBlock.gif)
'读取QRCodeBmp
![](/Images/OutliningIndicators/InBlock.gif)
Dim fs As New System.IO.FileStream("QRCodeBmp.bmp", IO.FileMode.Open, IO.FileAccess.Read)
Dim imageDataTemp(fs.Length) As Byte
ImageData = imageDataTemp
fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
End Sub
![](/Images/OutliningIndicators/None.gif)
Sub InsertDB(ByVal txtInsertSql As String)
Dim InSertSql As New System.Text.StringBuilder
InSertSql.AppendLine(txtInsertSql)
InSertSql.AppendLine("',Convert(image,@imgQRCode))")
Dim wblInsertCnn As New SqlConnection(ConnectString)
Dim wblInsertCmd As New SqlCommand
Try
wblInsertCnn.Open()
wblInsertCmd.Connection = wblInsertCnn
wblInsertCmd.CommandText = InSertSql.ToString
Dim wblSP As New SqlParameter("@imgQRCode", SqlDbType.Image)
wblSP.Value = ImageData
wblInsertCmd.Parameters.Add(wblSP)
wblInsertCmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message + "插入数据库操作失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Finally
wblInsertCnn.Dispose()
wblInsertCmd.Dispose()
End Try
End Sub
在水晶报表里面把数据库的存放二维码的字段拖到水晶报表里面就可以了。
什么是一维条码
![](/images/cnblogs_com/babyt/11710834552362172_small.jpg)
http://baike.baidu.com/view/13740.html
什么是二维条码
![](https://www.cnblogs.com/images/cnblogs_com/babyt/11623670672112966_small.jpg)
http://baike.baidu.com/view/587003.htm
在一般的应用系统开发中,一般都是通过设置文字(数字)的字体为条码字体(code3of9 或 code 128 等 ) 来实现的
但是在水晶报表中,使用同样的方法,这些条码字体却出不来条码。
国外市场上出现了专门针对水晶报表的条码,其中code3of9是免费的,其余都要收费。
在上面的帖子中提到的思路是这样的:
首先用应用程序接口生成条码图片(需注意精度)
将条码图片保存到数据库中
然后在水晶报表中将这个对象显示出来就行了。
本文所涉及到的DotNetBarCode可参考以下网址
DotNetBarcode.dll
http://www.geocities.jp/japan_inf/DotNetBarcode/
http://hi.baidu.com/optical/blog/item/4849d4b4a0ad8d708bd4b21c.html
以下内容摘自原帖:
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
在水晶报表里面把数据库的存放二维码的字段拖到水晶报表里面就可以了。