原創|使用教程|編輯:龔雪|2016-03-07 15:51:50.000|閱讀 897 次
概述:本次教程為大家介紹了使用Barcode Professional SDK for .NET類型庫Typed DataSets in .NET創建具有條形碼生成功能的水晶報表的方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
按照向導中的步驟。首先,請創建一個Northwind數據庫樣本的連接然后點擊下一步。隨后,選擇"Use SQL statements"后點擊下一步。最后,請輸入下面的SQL語句:
SELECT ProductID,ProductName,UnitPrice FROM Products
點擊Finish關閉Wizard對話框
點擊上圖的Add按鈕,然后在“Crystal Report Gallery”對話框中選擇“Blank Report”
點擊上圖中的OK按鈕
在Database Expert對話框中選擇Products DataTable,出現如下圖所示的"Selected Tables"列表
點擊OK按鈕,Products數據表在Field Explorer Window中將會轉變為可用,如下圖所示:
在我們的方案中最重要的域是Barcode.在報表中選擇Barcode項并點擊右側“Format Object”選擇按鈕打開“Format Editor”對話框,在打開的對話框中選擇“Can Grow”選項并點擊OK按鈕
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Filling Products DataTable from DB Dim ta As New NorthwindTableAdapters.ProductsTableAdapter() Dim dt As New Northwind.ProductsDataTable() ta.Fill(dt) 'Create an instance of Barcode Professional Dim bcp As New Neodynamic.SDK.BarcodeProfessional() 'Barcode settings bcp.Symbology = Neodynamic.SDK.Symbology.Code39 bcp.Extended = true bcp.AddChecksum = false bcp.BarHeight = 0.4f 'Append fictitious Company internal prefix Dim prodPrefix As String = "12345" Dim row As Northwind.ProductsRow For Each row In dt.Rows 'Set the value to encode bcp.Code = prodPrefix + row.ProductID.ToString() 'Generate the barcode image and store it into the Barcode Column row.Barcode = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png) Next 'Create a report object 'and set its data source with the DataSet Dim report As New CrystalReportBarcode() report.SetDataSource(CType(dt, DataTable)) Me.CrystalReportViewer1.ReportSource = report End Sub
private void Form1_Load(object sender, EventArgs e) { //Filling Products DataTable from DB NorthwindTableAdapters.ProductsTableAdapter ta = new NorthwindTableAdapters.ProductsTableAdapter(); Northwind.ProductsDataTable dt = new Northwind.ProductsDataTable(); ta.Fill(dt); //Create an instance of Barcode Professional Neodynamic.SDK.BarcodeProfessional bcp = new Neodynamic.SDK.BarcodeProfessional(); //Barcode settings bcp.Symbology = Neodynamic.SDK.Symbology.Code39; bcp.Extended = true; bcp.AddChecksum = false; bcp.BarHeight = 0.4f; //Append fictitious Company internal prefix string prodPrefix = "12345"; //Update DataTable with barcode image foreach (Northwind.ProductsRow row in dt.Rows) { //Set the value to encode bcp.Code = prodPrefix + row.ProductID.ToString(); //Generate the barcode image and store it into the Barcode Column row.Barcode = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png); } //Create a report object //and set its data source with the DataSet CrystalReportBarcode report = new CrystalReportBarcode(); report.SetDataSource((DataTable)dt); this.crystalReportViewer1.ReportSource = report; }
CrystalReportViewer控制器允許您導出Acrobat PDF、Microsoft Excel XLS等其它常用的文檔格式。在所有情況下,條碼圖像都會得到保護。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn