形状的填充色,边框(颜色及线宽),文字(颜色,字形,字号以及文字排列位置)都是可以配置的。
你可以通过Shape的API来添加一个形状并修改其样式。
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 7});
initSpread(spread);
};
function initSpread(spread) {
var shapeCategory = [
{
type: ['rectangle',
'roundedRectangle',
'snip1Rectangle',
'snip2SameRectangle',
'snip2DiagRectangle',
'snipRoundRectangle',
'round1Rectangle',
'round2SameRectangle',
],
desc: "Rectangles",
},
{
type: ['oval', 'hexagon', 'cube', 'smileyFace', 'heart', 'gear9', 'actionButtonMovie', 'funnel'],
desc: "Basic Shapes",
},
{
type: [
'rightArrow',
'leftArrow',
'upArrow',
'downArrow',
'leftRightArrow',
'upDownArrow',
'quadArrow',
'leftRightUpArrow',
],
desc: "Block Arrows",
}, {
type: [
'mathPlus',
'mathMinus',
'mathMultiply',
'mathDivide',
'mathEqual',
'mathNotEqual'],
desc: "Equation Shapes",
}, {
type: [
'flowchartProcess',
'flowchartAlternateProcess',
'flowchartDecision',
'flowchartData',
'flowchartPredefinedProcess',
'flowchartInternalStorage',
'flowchartDocument',
'flowchartMultidocument',
],
desc: "Flowchart",
}, {
type: [
'shape8pointStar',
'explosion2',
'shape4pointStar',
'shape5pointStar',
'star6Point',
'star7Point',
'shape8pointStar',
'star10Point',
],
desc: "Stars and Banners",
}, {
type: [
'rectangularCallout',
'roundedRectangularCallout',
'ovalCallout',
'cloudCallout',
'lineCallout2',
'lineCallout3',
'lineCallout4',
'lineCallout2AccentBar',
],
desc: "Callouts",
}];
spread.suspendPaint();
var sheets = spread.sheets;
for (var i = 0; i < shapeCategory.length; i++) {
var sheet = sheets[i];
initSheet(sheet, shapeCategory[i].desc);
initShape(sheet, shapeCategory[i].type);//add shape
}
spread.options.tabStripRatio = 0.8;
spread.resumePaint();
}
function initSheet(sheet, sheetName) {
sheet.name(sheetName);
}
function initShape(sheet, shapeType) {
let left = 50, top = 50, tempX = 0, tempY = 0, tempShape = null, shapeName, row = 1, column = 1;
for(let i = 0, len = shapeType.length ; i < len; i++) {
shapeName = shapeType[i];
if(GC.Spread.Sheets.Shapes.AutoShapeType[shapeName]){
tempShape = sheet.shapes.add(shapeName, GC.Spread.Sheets.Shapes.AutoShapeType[shapeName], left + tempX * 180, top + tempY, 150, 150);
tempX ++;
sheet.setText(row,column,shapeName);
column = column+3;
if(tempX === 4) {
tempX = 0;
tempY += 200;
column = 1;
row = 11;
}
}
}
}
<!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-shapes/dist/gc.spread.sheets.shapes.min.js"
type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.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="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-spreadsheets"></div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: 100%;
height: 100%;
overflow: hidden;
float: left;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}