Document Solutions for Excel, .NET Edition | Document Solutions
Features / Barcodes / Data Matrix
In This Topic
    Data Matrix
    In This Topic

    DataMatrix barcode is a high density, two-dimensional barcode with square modules typically arranged in a square or a rectangular matrix pattern. The most popular application for Data Matrix is marking small items, due to the code's ability to encode fifty characters in a symbol that is readable at 2 or 3 mm2 and the fact that the code can be read with only a 20% contrast ratio.

    The below image displays DataMatrix barcode in a PDF document.

    Datamatrix barcode

    Formula definition

    You can set Datamatrix in a worksheet using the following formula:

    =BC_DataMatrix(value, color, backgroudColor, eccMode, ecc200SymbolSize, ecc200EndcodingMode, ecc00_140Symbole, structureAppend, structureNumber, fileIdentifier, quietZoneRight, quietZoneTop, quietZoneBottom)

    Parameter

    Name Description
    value A string that represents encode on the symbol of Datamatrix.
    color A color that represents the barcode color. The default value is 'rgb(0,0,0)'.
    backgroundColor A color that represents the barcode backgroundcolor. The default value is 'rgb(255, 255, 255)'
    eccMode A value that represents which ecc mode to use. It has the following values : 'ECC000, ECC050, ECC080, ECC100, ECC140, ECC200'.
    ecc200SymbolSize A value that specifies the size of the ECC200 symbol only. The default value is 'squareAuto'.
    ecc200EndcodingMode A value that specifies which encoding mode to use for the symbol. The default value is 'auto'.
    ecc00_140Symbole A value that specifies the size of the ECC000-140 symbol only. The default value is 'auto'.
    structureAppend Specifies whether the symbol is part of a structured append message ECC200 only.The default value is 'false'.
    structureNumber A value that represents which block the symbol is in the structured append message. It has the value '0-15', only for ECC200. The default value is '0'.
    fileIdentifier A value that specifies the file identification. It has values '1-254', only for ECC200. The default value is '0'.
    quietZoneRight A value that represents the size of right quiet zone.
    quietZoneTop A value that represents the size of top quiet zone.
    quietZoneBottom A value that represents the size of bottom quiet zone.

    Using Code

    This example creates a DataMatrix barcode.

    C#
    Copy Code
    // Create a new workbook
    var workbook = new GrapeCity.Documents.Excel.Workbook();
    
    // Set worksheet layout and data
    IWorksheet worksheet = workbook.Worksheets[0];
    worksheet.Range["B:F"].ColumnWidth = 15;
    worksheet.Range["4:7"].RowHeight = 60;
    worksheet.Range["A:A"].ColumnWidth = 5;
    worksheet.Range["B2"].Value = "Data Matrix";
    worksheet.Range["B2:F2"].Merge(true);
    worksheet.Range["B3:F3"].Value = new object[,]{
        {"Server", "Data", "Defult", "ECC100", "ECC200"}
    };
    worksheet.Range["B4:C7"].HorizontalAlignment = HorizontalAlignment.Center;
    worksheet.Range["B4:C7"].VerticalAlignment = VerticalAlignment.Center;
    worksheet.Range["B2:F3"].HorizontalAlignment = HorizontalAlignment.Center;
    worksheet.Range["B2:F3"].VerticalAlignment = VerticalAlignment.Center;
    worksheet.Range["B4:C7"].Value = new object[,]
      {
        {"Police", "911"},
        {"Telephone Directory Assistance", "411"},
        { "Non-emergency Municipal Services", "311"},
        {"Travel Info Call 511", "511"}
      };
    worksheet.Range["B4:B7"].WrapText = true;
    worksheet.PageSetup.PrintGridlines = true;
    // Set formula
    for (var i = 4; i < 8; i++)
    {
       var value = "CONCAT(B" + i + ",\":\",C" + i + ")";
       worksheet.Range["D" + i].Formula = "=BC_DataMatrix" + "(" + value + ")";
       worksheet.Range["E" + i].Formula = "=BC_DataMatrix" + "(" + value + ", , ,\"ECC000\")";
       worksheet.Range["F" + i].Formula = "=BC_DataMatrix" + "(" + value + ", , ,\"ECC200\")";
    }
    
    // Save to a pdf file
    workbook.Save("datamatrix.pdf");

    Limitation