[]
        
(Showing Draft Content)

QRCode

QRCode is a two-dimensional barcode representing symbology that enables effective handling of numeric, alphanumeric and byte data. This barcode can encode up to 7,366 characters.

The below image displays QRCode barcode in a PDF document.

QRCode barcode

Formula definition

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

=BC_QRCODE(value, color, backgroundColor, errorCorrectionLevel, model, version, mask, connection, connectionNo, charCode, charset, quietZoneLeft, quietZoneRight, quietZoneTop, quietZoneBottom)

Note: The 'value' parameter is mandatory and the remaining ones are optional. This holds true for all the barcodes that support 'value' parameter in GcExcel.

Parameter

Name

Description

value

A string that represents encode on the symbol of QRCode.

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)'

errorCorrectionLevel

A string that represents the error correction level of QRCode. It has 'L|M|Q|H' four error correction levels. The default value is 'L'.

model

A value that represents the model of QRCode. It has 1 and 2 models. The default value is 2.

version

Vesion range is 1-14 for model1 and model 2. It has 'auto|1-14|1-40' values. The default value is  'auto'.

mask

A value that represents mask pattern for QRCode. It has 'auto and 0-7' eight mask pattern.

connection

A value that represents whether the symbol is part of a structured append message. The default value is false.

connectionNo

Specifies which block the symbol is in the structured append message. It has '0-15' values. The default value is '0'.

charCode

A value that represents the collection of characters of QRCode.

charset

A value that represents which charset to use. It has 'UTF-8 and Shift-JIS'.

quietZoneLeft

A value that represents the size of left quiet zone.

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 code sets a QRCode in the worksheet.

// Create a new workbook
var workbook = new GrapeCity.Documents.Excel.Workbook();

// Set worksheet layout and data
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Range["B:K"].ColumnWidth = 15;
worksheet.Range["4:6"].RowHeight = 60;
worksheet.Range["A:A"].ColumnWidth = 2;
worksheet.Range["B2"].Value = "QR Code";
worksheet.Range["B2:K2"].Merge(true);
worksheet.Range["I3:J3"].Merge(true);
worksheet.Range["B3:H3"].Value = new object[,]{
    {"Server", "Data", "Defult", "Change errorCorrectionLevel", "Change model", "Change version", "Change mask"}
};
worksheet.Range["I3"].Value = "Change connection and connectionNo";
worksheet.Range["K3:K5"].Value = new object[,]
  {
    {"Explain" },
    {"No QR Code generated, barcode data is too short to create connection symbol."},
    {"No QR Code generated, barcode data is too short to create connection symbol."}
  };
worksheet.PageSetup.PrintTitleColumns = "$A:$C";
worksheet.PageSetup.Orientation = PageOrientation.Landscape;
worksheet.PageSetup.PrintGridlines = true;
worksheet.Range["K4:K5"].Font.Color = Color.Red;
worksheet.Range["K4:K5"].WrapText = true;
worksheet.Range["B4:C6"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["B4:C6"].VerticalAlignment = VerticalAlignment.Center;
worksheet.Range["B2:K3"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["B2:K3"].VerticalAlignment = VerticalAlignment.Center;
worksheet.Range["B4:C6"].Value = new object[,]
  {
    {"Police", "911"},
    {"Travel Info Call 511", "511"},
    { "", "www.grapecity.com"},
  };

// Set formula
for (var i = 4; i < 7; i++)
{
   worksheet.Range["D" + i].Formula = "=BC_QRCODE" + "(C" + i + ")";
   worksheet.Range["E" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,\"H\")";
   worksheet.Range["F" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,1)";
   worksheet.Range["G" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,8)";
   worksheet.Range["H" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,,3)";
   worksheet.Range["I" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,,,\"true\",0)";
   worksheet.Range["J" + i].Formula = "=BC_QRCODE" + "(C" + i + ",,,,,,,\"true\",1)";
}

// Save to a pdf file
workbook.Save("qrcode.pdf");