基本シェイプ

Spread.Sheetsには182種類のシェイプがあります。各シェイプは単独で使用できます。組み込みの種類のまま使用することも、カスタムモデルオブジェクトによって定義することもできます。

<p>シェイプには、塗りつぶしの色、枠線(色、線種、線幅)、テキスト(色、フォント、サイズ、水平/垂直配置)を設定できます。</p> <p>シェイプのスタイルを変更するには、追加した自動シェイプに対し、Shape APIを使用してカスタマイズします。</p> <pre><code class="hljs js language-js"> <span class="hljs-keyword">var</span> heart = sheet.shapes.add(<span class="hljs-string">'autoShape'</span>, GC.Spread.Sheets.Shapes.AutoShapeType.heart, <span class="hljs-number">100</span>, <span class="hljs-number">50</span>, <span class="hljs-number">100</span>, <span class="hljs-number">150</span>); heart.text(<span class="hljs-string">'My Shape'</span>); <span class="hljs-keyword">var</span> heartStyle = heart.style(); heartStyle.fill.color = <span class="hljs-string">'pink'</span>; heartStyle.fill.transparency = <span class="hljs-number">0.5</span>; heartStyle.line.color = <span class="hljs-string">'green'</span>; heartStyle.line.lineStyle = GC.Spread.Sheets.Shapes.PresetLineDashStyle.dashDot; heartStyle.line.width = <span class="hljs-number">5</span>; heartStyle.line.capType = GC.Spread.Sheets.Shapes.LineCapStyle.square; heartStyle.line.joinType = GC.Spread.Sheets.Shapes.LineJoinStyle.miter; heartStyle.line.transparency = <span class="hljs-number">0.5</span>; heartStyle.textEffect.font = <span class="hljs-string">'bold 15px Georgia'</span>; heartStyle.textEffect.color = <span class="hljs-string">'yellow'</span>; heartStyle.textEffect.transparency = <span class="hljs-number">0.5</span>; heartStyle.textFrame.vAlign = GC.Spread.Sheets.VerticalAlign.center; heartStyle.textFrame.hAlign = GC.Spread.Sheets.HorizontalAlign.center; heart.style(heartStyle); </code></pre>
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 7}); initSpread(spread); }; function initSpread(spread) { var shapeCategoary = [ { 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 < shapeCategoary.length; i++) { var sheet = sheets[i]; initSheet(sheet, shapeCategoary[i].desc); initShape(sheet, shapeCategoary[i].type);//add shape } spread.options.tabStripRatio = 0.8; spread.resumePaint(); } function initSheet(sheet, sheetName) { sheet.name(sheetName); } function initShape(sheet, shapeType) { var left = 10, top = 10, tempX = 0, tempY = 0, tempShape = null, shapeName, shapeStyle; for(var 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); tempShape.text(shapeName); shapeStyle = tempShape.style(); shapeStyle.textEffect.color = "red"; shapeStyle.textFrame.hAlign = GC.Spread.Sheets.HorizontalAlign.center; shapeStyle.textFrame.vAlign = GC.Spread.Sheets.VerticalAlign.center; tempShape.style(shapeStyle); tempX ++; if(tempX === 4) { tempX = 0; tempY += 180; } } } sheet.resumePaint(); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="ja-jp" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets-shapes/dist/gc.spread.sheets.shapes.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets-resources-ja/dist/gc.spread.sheets.resources.ja.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-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; }