C# Barcode Generator Library
How to generate barcode to Microsoft Excel (.xlsx) file?


How to create, add barcode to Microsoft Excel (.xlsx) document in C# ASP.NET Core, MVC, WinForms, WPF apps?









How to create barcode Excel document using C#?


The C# sample code below explains how to create, add QR Code barcode image to an existing Microsoft Excel (.xlsx) worksheets using C#.NET.

  1. Create a new QR Code barcode object, and set the QR Code data text.
  2. Customize QR Code barcode dpi, width, height options
  3. Create a new XLSXDocument object from an existing Excel (.xlsx) file
  4. Get a XLSXPage object from the first sheet of the Excel worksheets
  5. Generate and insert QR Code on the XLSXPage object on the specified region
  6. Save the Excel (.xlsx) file



            QRCode barcode = new QRCode();
            barcode.Data = "https://www.rasteredge.com";

            barcode.AutoResize = true;
            barcode.Resolution = 96;
            barcode.UOM = UnitOfMeasure.INCH;
            barcode.BarcodeWidth = 1.5f;
            barcode.BarcodeHeight = 1.5f;

            String inputFilePath = @"C:\Input\RasterEdge.com\test-document.xlsx";
            String outputFilePath = @"C:\Output\RasterEdge.com\barcode-qrcode-excel.xlsx";

            XLSXDocument doc = new XLSXDocument(inputFilePath);
            //  Draw the barcode at position (100, 200) in pixels on the 1st page.
            XLSXPage page = (XLSXPage)doc.GetPage(0);
            barcode.DrawBarcode(page, 120, 200);

            doc.Save(outputFilePath);