개요

SpreadJS에는 여러 Excel 셰이프를 비롯하여 180개 이상의 셰이프에 대한 지원이 포함됩니다. 또한 SpreasJS는 데이터 기반 셰이프를 사용하여 고급 기능을 제공합니다. 예를 들어 데이터베이스 또는 기타 데이터 소스의 데이터를 사용하여 셰이프 속성을 동적으로 생성할 수 있으며, 이를 통해 제조 공장용 셰이프처럼 대화형 셰이프를 만들 수 있습니다.

SpreadJS는 다음과 같은 세 가지 셰이프 유형을 제공합니다. 자동 셰이프: 자동 셰이프는 독립 실행형으로 사용할 수 있습니다. 연결선 셰이프: 연결선 셰이프는 독립 실행형 또는 다른 셰이프에 연결하여 사용할 수 있습니다. 그룹 셰이프: 그룹 셰이프는 실제 셰이프가 아니지만, 셰이프 그룹을 쉽고 빠르게 처리하기 위해 관리자로 사용할 수 있습니다. 셰이프 기능을 사용하려면 js 파일 링크를 문서의 헤더 섹션에 추가하십시오. ShapeCollection API를 사용하여 시트에서 모든 셰이프를 관리할 수 있습니다. 아래와 같이 sheet.shapes.add 메서드로 자동 셰이프를 만들 수 있습니다. 아래와 같이 sheet.shapes.addConnector 메서드로 연결선 셰이프를 만들 수 있습니다. 다음과 같은 코드를 사용하여 이름이 있는 셰이프를 가져오거나 제거할 수 있습니다.
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> </gc-spread-sheets> <shape-panel @insertShape="insertShape" @insertConnectShape="insertConnectShape"> </shape-panel> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import { ref, createApp } from "vue"; import "@mescius/spread-sheets-vue"; import '@mescius/spread-sheets-shapes'; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); const spreadRef = ref(null); const initSpread = (spread) => { spreadRef.value = spread; spread.getActiveSheet().shapes.add("rectangle", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 40, 20, 150, 150); let lineShape = spread.getActiveSheet().shapes.addConnector("line", GC.Spread.Sheets.Shapes.ConnectorType.straight, 290, 20, 420, 170); let lineShapeStyle = lineShape.style(); lineShapeStyle.line.width = 8; lineShape.style(lineShapeStyle); } const insertShape = (addShapeType) => { let spread = spreadRef.value; let sheet = spread.getActiveSheet(), shapes = sheet.shapes, total = shapes.all().length; let x = 40 + (total % 2) * 250, y = parseInt(total / 2) * 200 + 20; let shape = shapes.add('', addShapeType, x, y); shape.style().hAlign = 1; } const insertConnectShape = (addConnectoShapeType) => { let spread = spreadRef.value; let sheet = spread.getActiveSheet(), shapes = sheet.shapes, total = shapes.all().length; let x = 40 + (total % 2) * 250, y = parseInt(total / 2) * 200 + 20; shapes.addConnector('', addConnectoShapeType, x, y, x + 200, y + 200); } </script> <style scoped> .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 280px); height: 100%; overflow: hidden; float: left; } .options-container { float: right; width: 280px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row { font-size: 14px; padding-left: 5px; } .divide-line { width: 100%; height: 1px; background: #cbcbcb; margin-top: 10px; margin-bottom: 3px; } .title { text-align: center; font-weight: bold; } label { display: block; margin-top: 15px; margin-bottom: 5px; } p { padding: 2px 10px; background-color: #F4F8EB; } input { width: 160px; margin-left: 10px; display: inline; } input[type=button] { width: 50px; margin-left: 1px; } select { width: 160px; margin-left: 10px; display: inline; } textarea { width: 160px; margin-left: 10px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { height: 100%; } </style>
<template> <div class="options-container"> <div class="option-row"> Try selecting a shape from either of the drop-down menus and click the ‘Add’ button to add that shape to the Spread instance. </div> <div class="option-row"> <label for='autoShapeType'>Add Shape:</label> <select class="shapeSelect" id="'autoShapeType'" v-model.number="addShapeType"> <option :value="item.value" v-for="item in autoShapeTypeList" :key="item.name">{{ item.name }} </option> </select> <input type='button' @click="insertShape" value="Add" /> <label for='connectShapeType'>Add Connect Shape: </label> <select class="shapeSelect" id="connectShapeType" v-model.number="addConnectorShapeType"> <option :value="item.value" v-for="item in connectorTypeList" :key="item.name">{{ item.name }} </option> </select> <input type='button' @click='insertConnectShape' value="Add" /> </div> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import "@mescius/spread-sheets-shapes"; import { defineEmits, ref } from 'vue'; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); function getEnumList(enumObject) { let names = []; for (var name in enumObject) { if (name === "none" || (parseInt(name, 10)) == name) { continue; } names.push({ name: name, value: enumObject[name] }); } names.sort(function (a, b) { return a.name > b.name ? 1 : -1 }); return names; } const emits = defineEmits(['insertShape', 'insertConnectShape']); const props = [ "showBorderPanel", "showShapeFillPropPanel", "showShapeTxtPanel", "showConnectorPropPanel" ]; const addShapeType = ref(GC.Spread.Sheets.Shapes.AutoShapeType.actionButtonBackorPrevious); const addConnectorShapeType = ref(GC.Spread.Sheets.Shapes.ConnectorType.elbow); const autoShapeTypeList = ref(getEnumList(GC.Spread.Sheets.Shapes.AutoShapeType)); const connectorTypeList = ref(getEnumList(GC.Spread.Sheets.Shapes.ConnectorType)); const insertShape = () => { emits('insertShape', addShapeType.value); }; const insertConnectShape = () => { emits('insertConnectShape', addConnectorShapeType.value); }; </script> <style scoped> </style>
<!DOCTYPE html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/spread/source/data/inventory-tracker.js" type="text/javascript"></script> <script src="$DEMOROOT$/ko/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/ko/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js' }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);