你可以通过公式BC_DataMatrix来创建一个Data Matrix条形码:=BC_DataMatrix(value, color, backgroudColor, eccMode, ecc200SymbolSize, ecc200EndcodingMode, ecc00_140Symbole, structureAppend, structureNumber, fileIdentifier, quietZoneRight, quietZoneTop, quietZoneBottom)
公式包含以下参数:
eccMode : 表示条形码编码使用的ECC模式, 可以为以下数值:'ECC000, ECC050, ECC080, ECC100, ECC140, ECC200'
ecc200SymbolSize : 表示ECC200字符编码大小(默认值是squareAuto)
ecc200EndcodingMode : 表示ECC200编码模式(默认值是auto)
ecc00_140Symbole : 表示ECC000-140字符编码大小(默认值是 auto)
structureAppend : 表示是否是链接编码模式(默认值是false), 只在ECC200编码模式下使用
structureNumber : 表示链接编码模式中的索引(默认值是 0),只能是0~15, 且只在ECC200编码模式下使用
fileIdentifier : 表示编码的文件标识(默认值为 0),只能是1~254, 且只在ECC200编码模式下使用
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), {sheetCount: 1});
initSpread(spread);
};
var FORMULA = 'BC_DataMatrix';
function initSpread(spread) {
var sheet = spread.getSheet(0);
spread.suspendPaint();
_initCustomSheet(sheet);
spread.resumePaint();
}
function _initCustomSheet(sheet) {
sheet.name('customSheet');
_setData(sheet);
_setStyle(sheet);
for (var row = 3; row < 7; row++) {
var value = 'CONCAT(B' + (row + 1) + ', ": ",C' + (row + 1) + ')';
sheet.setFormula(row, 3, '=' + FORMULA + '(' + value + ')');
sheet.setFormula(row, 4, '=' + FORMULA + '(' + value + ', , ,"ECC000")');
sheet.setFormula(row, 5, '=' + FORMULA + '(' + value + ', , ,"ECC200")');
}
}
function _setData(sheet) {
sheet.getCell(1, 1).value('Service');
sheet.getCell(1, 2).value('Number');
sheet.getCell(1, 3).value('Data Matrix');
sheet.getCell(2, 3).value('Default');
sheet.getCell(2, 4).value('ECC100');
sheet.getCell(2, 5).value('ECC200');
var dataArray = [
['Police', 911],
['Telephone Directory Assistance', 411],
['Non-emergency Municipal Services', 311],
['Travel Info Call 511', 511]
];
sheet.setArray(3, 1, dataArray);
}
function _setStyle(sheet) {
for (var row = 3; row < 7; row++) {
sheet.setRowHeight(row, 80);
}
sheet.addSpan(1, 1, 2, 1)
sheet.addSpan(1, 2, 2, 1)
sheet.addSpan(1, 3, 1, 3)
sheet.setColumnWidth(0, 20);
sheet.setColumnWidth(1, 200);
sheet.setColumnWidth(2, 80);
sheet.setColumnWidth(3, 80);
sheet.setColumnWidth(4, 80);
sheet.setColumnWidth(5, 80);
sheet.getRange(1, 1, 2, 5)
.foreColor('#000')
.backColor('#FFF3CE')
.borderLeft(new GC.Spread.Sheets.LineBorder('orange', GC.Spread.Sheets.LineStyle.thin), {outline: true})
.borderBottom(new GC.Spread.Sheets.LineBorder('orange', GC.Spread.Sheets.LineStyle.thin), {outline: true});
sheet
.getRange(1, 1, 6, 5)
.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, 5, 1).wordWrap(true);
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="zh-cn" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css"
href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js"
type="text/javascript"></script>
<script
src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-barcode/dist/gc.spread.sheets.barcode.min.js"
type="text/javascript"></script>
<script
src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.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;
}