You can create a QR Code using the BC_QRCODE function in a formula: =BC_QRCODE(value, color, backgroundColor, errorCorrectionLevel, model, version, mask, connection, connectionNo, charCode, charset, quietZoneLeft, quietZoneRight, quietZoneTop, quietZoneBottom)
The function has the following parameters:
errorCorrectionLevel : (default value is 'L') this string represents the error correction level of QRCode, which can be 'L', 'M', 'Q', or 'H'.
model : (default value is 2) this value represents the model of QRCode, which can be 1 or 2.
version : (default value is 'auto') this value can be 'auto', 1-14, or 1-40'. For model1, the version range is 1-14, and for model 2, the version range is 1-40,
mask : (default value is 'auto') this value represents the mask pattern for QRCode, which can be 'auto' or 0-7.
connection : (default value is false) this value indicates whether the symbol is part of a structured append message.
connectionNo : (default value is '0') this value indicates which block the symbol is in the structured append message, which can between 0 and 15.
charCode : this represents the collection of characters that comprise the value of the QRCode.
charset : (default value is 'UTF-8') this value represents which charset to use, which can be 'UTF-8' or 'Shift-JIS'.
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
initSpread(spread);
};
var FORMULA = 'BC_QRCODE';
function initSpread(spread) {
var sheet = spread.getSheet(0);
spread.suspendPaint();
_initBasicSheet(sheet);
spread.resumePaint();
}
function _initBasicSheet(sheet) {
sheet.name('customSheet');
_setData(sheet);
_setStyle(sheet);
for (var row = 3; row < 6; row++) {
sheet.setFormula(row, 3, '=' + FORMULA + '(C' + (row + 1) + ')');
sheet.setFormula(row, 4, '=' + FORMULA + '(C' + (row + 1) + ',,,"H")');
sheet.setFormula(row, 5, '=' + FORMULA + '(C' + (row + 1) + ',,,,1)');
sheet.setFormula(row, 6, '=' + FORMULA + '(C' + (row + 1) + ',,,,,8)');
sheet.setFormula(row, 7, '=' + FORMULA + '(C' + (row + 1) + ',,,,,,3)');
sheet.setFormula(row, 8, '=' + FORMULA + '(C' + (row + 1) + ',,,,,,,"true",0)');
sheet.setFormula(row, 9, '=' + FORMULA + '(C' + (row + 1) + ',,,,,,,"true",1)');
}
}
function _setStyle(sheet) {
for (var row = 3; row < 6; row++) {
sheet.setRowHeight(row, 80);
}
sheet.setColumnWidth(0, 20);
for (var col = 1; col < 3; col++) {
sheet.setColumnWidth(col, 160);
}
for (var col = 3; col < 10; col++) {
sheet.setColumnWidth(col, 120);
}
sheet.setColumnWidth(10, 200);
sheet.setColumnWidth(4, 200);
sheet
.getRange(1, 1, 2, 10)
.foreColor('#000')
.backColor('#FFF3CE')
.setBorder(new GC.Spread.Sheets.LineBorder('orange', GC.Spread.Sheets.LineStyle.thin), { all: true });
sheet
.getRange(1, 1, 5, 10)
.vAlign(GC.Spread.Sheets.VerticalAlign.center)
.hAlign(GC.Spread.Sheets.HorizontalAlign.center)
.setBorder(new GC.Spread.Sheets.LineBorder('orange', GC.Spread.Sheets.LineStyle.medium), { outline: true });
sheet.getRange(1, 1, 1, 9).foreColor('#000').backColor('#FFF3CE').wordWrap(true);
sheet.getRange(1, 2, 5, 1).wordWrap(true);
sheet.getCell(3, 10).value('No QR Code generated, barcode data is too short to create connection symbol.').wordWrap(true).foreColor("red");
sheet.getCell(4, 10).value('No QR Code generated, barcode data is too short to create connection symbol.').wordWrap(true).foreColor("red");
sheet.addSpan(2, 8, 1, 2);
}
function _setData(sheet) {
var headers = [[
'Default',
'Change errorCorrectionLevel',
'Change model',
'Change version',
'Change mask',
'Change connection and connectionNo ',
'',
'Explain'
]];
sheet.setArray(2, 3, headers)
var dataArray = [
['Police', 911],
['Travel Info Call 511', 511],
['', 'abcdefghijklmnopqrstuvwxyz1234567890']
];
sheet.setArray(3, 1, dataArray);
sheet.addSpan(1, 1, 2, 1);
sheet.addSpan(1, 2, 2, 1);
sheet.addSpan(1, 3, 1, 7);
sheet.setValue(1, 1, 'Service');
sheet.setValue(1, 2, 'Number');
sheet.setValue(1, 3, 'QR Code');
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-barcode/dist/gc.spread.sheets.barcode.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-tutorial"></div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}