原創|使用教程|編輯:龔雪|2016-03-11 12:06:04.000|閱讀 1770 次
概述:本教程將帶您一步一步了解如何使用Barcode Professional SDK for .NET創建具有條碼生成功能的本地RDLC報表。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Barcode Professional SDK for .NET最新版下載
按照向導中的步驟。首先,請創建一個到AdventureWorks SQL Server數據庫樣本的連接然后選擇下一步。之后,選擇"Use SQL statements"并點擊下一步。輸入以下SQL語句:
SELECT ProductID, Name, ProductModel FROM Production.vProductAndDescription WHERE (CultureID = N'en')
VB
private void Form1_Load(object sender, EventArgs e) { //Fill the datasource from DB this.vProductAndDescriptionTableAdapter.Fill(this.AdventureWorks.vProductAndDescription); //Create an instance of Barcode Professional Neodynamic.SDK.BarcodeProfessional bcp = new Neodynamic.SDK.BarcodeProfessional(); //Barcode settings bcp.Symbology = Neodynamic.SDK.Symbology.Code128; bcp.BarHeight = 0.25f; //Update DataTable with barcode image foreach(AdventureWorks.vProductAndDescriptionRow row in this.AdventureWorks.vProductAndDescription.Rows) { //Set the value to encode bcp.Code = row.ProductID.ToString(); //Generate the barcode image and store it into the Barcode Column row.Barcode = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png); } this.reportViewer1.RefreshReport(); }
C#
private void button1_Click(object sender, EventArgs e) { //Create an instance of ReportViewer Microsoft.Reporting.WinForms.ReportViewer viewer = new Microsoft.Reporting.WinForms.ReportViewer(); //Set local report //NOTE: LocalReportWithBarcode refers to the namespace for the app. viewer.LocalReport.ReportEmbeddedResource = "LocalReportWithBarcode.Report1.rdlc"; //Generate Data Source... //Fill the datasource from DB AdventureWorksTableAdapters.vProductAndDescriptionTableAdapter ta = new AdventureWorksTableAdapters.vProductAndDescriptionTableAdapter(); AdventureWorks.vProductAndDescriptionDataTable dt = new AdventureWorks.vProductAndDescriptionDataTable(); ta.Fill(dt); //Create an instance of Barcode Professional Neodynamic.SDK.BarcodeProfessional bcp = new Neodynamic.SDK.BarcodeProfessional(); //Barcode settings bcp.Symbology = Neodynamic.SDK.Symbology.Code128; bcp.BarHeight = 0.25f; //Update DataTable with barcode image foreach(AdventureWorks.vProductAndDescriptionRow row in dt.Rows) { //Set the value to encode bcp.Code = row.ProductID.ToString(); //Generate the barcode image and store it into the Barcode Column row.Barcode = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png); } //Create Report Data Source Microsoft.Reporting.WinForms.ReportDataSource rptDataSource = new Microsoft.Reporting.WinForms.ReportDataSource("AdventureWorks_vProductAndDescription", dt); viewer.LocalReport.DataSources.Add(rptDataSource); //Export to PDF. Get binary content. string mimeType; string encoding; string fileNameExtension; string[] streams; Microsoft.Reporting.WinForms.Warning[] warnings; byte[] pdfContent = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); //Creatr PDF file on disk string pdfPath = @"C:\temp\reportBarcode.pdf"; System.IO.FileStream pdfFile = new System.IO.FileStream(pdfPath, System.IO.FileMode.Create); pdfFile.Write(pdfContent, 0, pdfContent.Length); pdfFile.Close(); //Open PDF file System.Diagnostics.Process.Start(pdfPath); }
本文翻譯自
更多條形碼相關產品請點擊>>
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn