셰이프 테두리

SpreadJS를 사용하면 셰이프에 테두리를 추가하고 색, 투명도, 너비 등 여러 서식을 테두리에 적용할 수 있습니다.

Shape API를 사용하여 자동 셰이프의 속성을 사용자 정의할 수 있습니다. text: 셰이프의 텍스트를 가져오거나 설정합니다. style: 셰이프의 스타일을 가져오거나 설정합니다. ConnectorShape API를 사용하여 연결선 셰이프의 속성을 사용자 정의할 수 있습니다. style: 연결선 셰이프의 스타일을 가져오거나 설정합니다.
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> </gc-spread-sheets> <shape-panel @updateShapeBorderStyle="updateShapeBorderStyle" :showBorderPanelRef="showBorderPanelRef"> </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 showBorderPanelRef = ref(false); const updateShapeBorderStyle = (action, value) => { let sheet = spreadRef.value.getActiveSheet(); let activeShape = sheet.shapes.all().filter(function (sp) { return sp.isSelected(); }); if (activeShape) { activeShape.forEach(function (shape) { let shapeStyle = shape.style(); shapeStyle.line[action] = value; shape.style(shapeStyle); }); sheet.repaint(); } } const bindSpreadEvent = () => { spreadRef.value.bind(GC.Spread.Sheets.Events.ShapeSelectionChanged, function () { let sheet = spreadRef.value.getActiveSheet(); var selectedShape = sheet.shapes.all().filter(function (sp) { return sp.isSelected(); }); var isShapeSelected = false, isConnectorSelected = false; if (selectedShape.length > 0) { selectedShape.forEach((shape) => { if (!isShapeSelected && shape instanceof GC.Spread.Sheets.Shapes.Shape) { isShapeSelected = true; } else if (!isConnectorSelected && shape instanceof GC.Spread.Sheets.Shapes.ConnectorShape) { isConnectorSelected = true; } }); setBorderPropVisibility(true); } else { setBorderPropVisibility(false); } }) } const setBorderPropVisibility = (isShow) => { showBorderPanelRef.value = isShow; } const initSpread = (spread) => { spreadRef.value = spread; let oval = spread.getActiveSheet().shapes.add("oval", GC.Spread.Sheets.Shapes.AutoShapeType.oval, 40, 20, 150, 150); let ovalStyle = oval.style(); ovalStyle.fill.color = "#FFFFFF"; oval.style(ovalStyle); var rectangle = spread.getActiveSheet().shapes.add("rectangle", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 40, 230, 150, 150); let rectangleStyle = rectangle.style(); rectangleStyle.fill.color = "#FFFFFF"; rectangle.style(rectangleStyle); spread.getActiveSheet().shapes.addConnector("line", GC.Spread.Sheets.Shapes.ConnectorType.straight, 250, 20, 400, 150); spread.getActiveSheet().shapes.addConnector("line", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 250, 250, 400, 350); bindSpreadEvent(); } </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 and change the border properties to see the effect: </div> <div id="divideLine" class="divide-line"></div> <div v-show="props.showBorderPanelRef" class="option-row"> <label>Border Color: </label> <input v-model="borderColorRef" type="color" /> <input type="button" @click="_handleShapeBorderAction('color', borderColorRef)" value="Set" /> <label>Border Transparency: </label> <input v-model="borderTransparencyRef" type="text" value="0.5" /> <input type="button" @click="_handleShapeBorderAction('transparency', borderTransparencyRef)" value="Set" /> <label>Border Width: </label> <input v-model="borderWidthRef" type="number" /> <input type="button" @click="_handleShapeBorderAction('width', borderWidthRef)" value="Set" /> <label>Border Line Style: </label> <select v-model="borderLineStyleRef"> <option v-bind:value="item.value" v-for="item in lineDashStyleListRef" :key="item.name">{{ item.name }}</option> </select> <input type="button" @click="_handleShapeBorderAction('lineStyle', borderLineStyleRef)" value="Set" /> <label>Border Cap Line Style: </label> <select v-model.number="borderCapTypeRef"> <option v-bind:value="item.value" v-for="item in lineCapStyleListRef" :key="item.name">{{ item.name }}</option> </select> <input type="button" @click="_handleShapeBorderAction('capType', borderCapTypeRef)" value="Set" /> <label>Border Join Line Style: </label> <select v-model="borderJoinTypeRef"> <option v-bind:value="item.value" v-for="item in lineJoinStyleListRef" :key="item.name">{{ item.name }}</option> </select> <input type="button" @click="_handleShapeBorderAction('joinType', borderJoinTypeRef)" value="Set" /> </div> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import "@mescius/spread-sheets-shapes"; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); import { defineEmits, ref } from 'vue'; let lineCapStyle = { flat: 2, square: 1, round: 0 }; let lineJoinStyle = { round: 0, miter: 1, bevel: 2 }; let lineDashStyle = { solid: 0, squareDot: 1, dash: 2, longDash: 3, dashDot: 4, longDashDot: 5, longDashDotDot: 6, sysDash: 7, sysDot: 8, sysDashDot: 9, dashDotDot: 10 }; const borderColorRef = ref("#00A2E8"); const borderTransparencyRef = ref(0.5); const borderWidthRef = ref(1); const borderLineStyleRef = ref(2); const borderCapTypeRef = ref(2); const borderJoinTypeRef = ref(2); const lineCapStyleListRef = ref(getEnumList(lineCapStyle)); const lineJoinStyleListRef = ref(getEnumList(lineJoinStyle)); const lineDashStyleListRef = ref(getEnumList(lineDashStyle)); const props = defineProps({ showBorderPanelRef: Boolean }); const emits = defineEmits(['updateShapeBorderStyle']); const _handleShapeBorderAction = (action, value) => { emits("updateShapeBorderStyle", action, value); } 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; } </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);