[]
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.
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)
!type=note
Note: The 'value' parameter is mandatory and the remaining ones are optional. This holds true for all the barcodes that support 'value' parameter in DsExcel.
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 |
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 |
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. |
This example code sets a QRCode in the worksheet.
// Create a new workbook
Workbook workbook = new Workbook();
// Set worksheet layout and data
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("B:K").setColumnWidth(15);
worksheet.getRange("4:6").setRowHeight(60);
worksheet.getRange("A:A").setColumnWidth(2);
worksheet.getRange("B2").setValue("QR Code");
worksheet.getRange("B2:K2").setMergeCells(true);
worksheet.getRange("I3:J3").setMergeCells(true);
worksheet.getRange("B3:H3").setValue(new Object[][] { { "Server", "Data", "Default",
"Change errorCorrectionLevel", "Change model", "Change version", "Change mask" } });
worksheet.getRange("I3").setValue("Change connection and connectionNo");
worksheet.getRange("K3:K5")
.setValue(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.getPageSetup().setPrintTitleColumns("$A:$C");
worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
worksheet.getPageSetup().setPrintGridlines(true);
worksheet.getRange("K4:K5").getFont().setColor(Color.GetRed());
worksheet.getRange("K4:K5").setWrapText(true);
worksheet.getRange("B4:C6").setHorizontalAlignment(HorizontalAlignment.Center);
worksheet.getRange("B4:C6").setVerticalAlignment(VerticalAlignment.Center);
worksheet.getRange("B2:K3").setHorizontalAlignment(HorizontalAlignment.Center);
worksheet.getRange("B2:K3").setVerticalAlignment(VerticalAlignment.Center);
worksheet.getRange("B4:C6").setValue(
new Object[][] { { "Police", "911" }, { "Travel Info Call 511", "511" }, { "", "developer.mescius.com" } });
// Set formula
for (int i = 4; i < 7; i++) {
worksheet.getRange("D" + i).setFormula("=BC_QRCODE" + "(C" + i + ")");
worksheet.getRange("E" + i).setFormula("=BC_QRCODE" + "(C" + i + ",,,\"H\")");
worksheet.getRange("F" + i).setFormula("=BC_QRCODE" + "(C" + i + ",,,,1)");
worksheet.getRange("G" + i).setFormula("=BC_QRCODE" + "(C" + i + ",,,,,8)");
worksheet.getRange("H" + i).setFormula("=BC_QRCODE" + "(C" + i + ",,,,,,3)");
worksheet.getRange("I" + i).setFormula("=BC_QRCODE" + "(C" + i + ",,,,,,,\"true\",0)");
worksheet.getRange("J" + i).setFormula("=BC_QRCODE" + "(C" + i + ",,,,,,,\"true\",1)");
}
// Save to an pdf file
workbook.save("QRCode.pdf");