Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Create a DataSet from the XML file
            string filePath = "..\\..\\Employees.xml";
            DataSet ds = new DataSet();
            ds.ReadXml(filePath);

            //Create and add barcode column
            DataColumn dc = new DataColumn("BarcodeImage", typeof(byte[]));
            ds.Tables[0].Columns.Add(dc);

            //We'll use Code 128 Barcode Symbology
            BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.Code128);

            b.Height = 50;
            b.FontHeight = 0.3F;
            //Now, generate and fill barcode images
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                //We'll encode the ID column
                b.Number = (string)dr["ID"];

                //Create bitmap and save it to BarcodeImage column
                MemoryStream ms = new MemoryStream();
                b.Save(ms, ImageType.Png);
                dr["BarcodeImage"] = ms.GetBuffer();
            }

            CrystalReport1 report = new CrystalReport1();
            report.SetDataSource(ds);
            crystalReportViewer1.ReportSource = report;
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Create a DataSet from the XML file
            string  filePath = "..\\..\\Employees.xml";
            DataSet ds       = new DataSet();

            ds.ReadXml(filePath);

            //Create and add barcode column
            DataColumn dc = new DataColumn("BarcodeImage", typeof(byte[]));

            ds.Tables[0].Columns.Add(dc);

            //We'll use Code 128 Barcode Symbology
            BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.Code128);

            b.NarrowBarWidth = 3;
            b.Height         = 300;
            b.FontHeight     = 0.3F;
            //Now, generate and fill barcode images
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                //We'll encode the ID column
                b.Number = (string)dr["ID"];

                //Create bitmap and save it to BarcodeImage column
                MemoryStream ms = new MemoryStream();
                b.Save(ms, ImageType.Png, 300, 300);
                dr["BarcodeImage"] = ms.GetBuffer();
            }

            CrystalReport1 report = new CrystalReport1();

            report.SetDataSource(ds);
            crystalReportViewer1.ReportSource = report;
        }
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
 {
     CrystalReport1 rpt = new CrystalReport1();
     rpt.Site = this.Site;
     return rpt;
 }