概览

概述 GanttSheet 是一个具有甘特行为和电子表格用户界面的快速、数据绑定的DataTable视图。

初始化 SpreadJS的GanttSheet支持使用DataManager视图作为数据源。 要使用GanttSheet,请将js文件链接添加到文档的head部分: 然后,您可以使用带有层次结构模式的DataManager: 然后,您可以根据您的源数据结构定义正确的层次结构模式。 然后初始化一个GanttSheet。 批处理模式 GanttSheet中的项目数据记录是结构化数据,因此应使用批处理模式。 甘特列 GanttSheet有一个名为enableGanttColumn的属性,用于控制是否显示甘特列。 默认情况下,此选项为true。如果您不想显示它,则可以在创建GanttSheet时将此属性设置为false,或者调用ganttSheet.bindGanttView(view, { enableGanttColumn: false })。
/*REPLACE_MARKER*/ /*DO NOT DELETE THESE COMMENTS*/ <template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> </gc-spread-sheets> </div> </template> <script> import Vue from "vue"; import "@grapecity-software/spread-sheets-vue"; import GC from '@grapecity-software/spread-sheets'; import "@grapecity-software/spread-sheets-tablesheet"; import "@grapecity-software/spread-sheets-ganttsheet"; import "./styles.css"; import '@grapecity-software/spread-sheets-resources-zh'; GC.Spread.Common.CultureManager.culture("zh-cn"); let App = Vue.extend({ name: "app", data: function() { return { spread: null }; }, methods: { initSpread: function(spread) { this.spread = spread; spread.suspendPaint(); spread.clearSheets(); this.initGanttSheetWithIdParentIdData(spread); this.initGanttSheetWithLevelData(spread); this.initGanttSheetWithChildrenData(spread); spread.resumePaint(); }, initGanttSheetWithIdParentIdData(spread) { var tableName = "Gantt_Id"; var baseApiUrl = getBaseApiUrl(); var apiUrl = baseApiUrl + "/" + tableName; var dataManager = spread.dataManager(); var myTable1 = dataManager.addTable("myTable1", { batch: true, remote: { read: { url: apiUrl } }, schema: { hierarchy: { type: "Parent", column: "parentId" }, columns: { id: { isPrimaryKey: true }, taskNumber: { dataType: "rowOrder" } } } }); var ganttSheet = spread.addSheetTab(0, "GanttSheet1", GC.Spread.Sheets.SheetType.ganttSheet); var view = myTable1.addView("myView1", [ { value: "taskNumber", caption: "NO", width: 60 }, { value: '=CONCAT("(L",LEVEL(),"-",LEVELROWNUMBER(),")")', caption: "L" }, { value: "name", caption: "Task Name", width: 200 }, { value: "duration", caption: "Duration", width: 90 }, { value: "predecessors", caption: "Predecessors", width: 60 }, { value: "cost", caption: "Cost", style: { formatter: "$0" } } ]); view.fetch().then(function() { ganttSheet.bindGanttView(view); }); }, initGanttSheetWithLevelData(spread) { var tableName = "Gantt_Level"; var baseApiUrl = getBaseApiUrl(); var apiUrl = baseApiUrl + "/" + tableName; var dataManager = spread.dataManager(); var myTable1 = dataManager.addTable("myTable1", { batch: true, remote: { read: { url: apiUrl } }, schema: { hierarchy: { type: "Level", column: "level" } } }); var ganttSheet = spread.addSheetTab(1, "GanttSheet2", GC.Spread.Sheets.SheetType.ganttSheet); var view = myTable1.addView("myView1", [ { value: "taskNumber", caption: "NO.", width: 60 }, { value: "name", caption: "Task Name", width: 200 }, { value: "duration", caption: "Duration", width: 90 }, { value: "predecessors", caption: "Predecessors", width: 120 } ]); view.fetch().then(function() { ganttSheet.bindGanttView(view); }); }, initGanttSheetWithChildrenData(spread) { var tableName = "Gantt_Children"; var baseApiUrl = getBaseApiUrl(); var apiUrl = baseApiUrl + "/" + tableName; var dataManager = spread.dataManager(); var myTable1 = dataManager.addTable("myTable1", { batch: true, remote: { read: { url: apiUrl } }, schema: { hierarchy: { type: "ChildrenPath", column: "children" } } }); var ganttSheet = spread.addSheetTab(2, "GanttSheet3", GC.Spread.Sheets.SheetType.ganttSheet); var view = myTable1.addView("myView1", [ { value: "taskNumber", caption: "NO.", width: 60 }, { value: "name", caption: "Task Name", width: 200 }, { value: "duration", caption: "Duration", width: 90 }, { value: "predecessors", caption: "Predecessors", width: 120 } ]); view.fetch().then(function() { ganttSheet.bindGanttView(view); }); } } }); function getBaseApiUrl() { return window.location.href.match(/http.+spreadjs\/SpreadJSTutorial\//)[0] + 'server/api'; } new Vue({ render: (h) => h(App), }).$mount("#app"); </script>
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/vue/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- SystemJS --> <script src="$DEMOROOT$/zh/vue/node_modules/systemjs/dist/system.src.js"></script> <script src="$DEMOROOT$/spread/source/data/employees.js" type="text/javascript"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); System.import('$DEMOROOT$/zh/lib/vue/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
.sample-tutorial { width: 100%; height: 100%; } body, html { padding: 0; margin: 0; width: 100%; height: 100%; position: relative; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; }
(function(global) { System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, meta: { '*.css': { loader: 'css' }, '*.vue': { loader: 'vue-loader' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { '@grapecity-software/spread-sheets': 'npm:@grapecity-software/spread-sheets/index.js', '@grapecity-software/spread-sheets-resources-zh': 'npm:@grapecity-software/spread-sheets-resources-zh/index.js', '@grapecity-software/spread-sheets-tablesheet': 'npm:@grapecity-software/spread-sheets-tablesheet/index.js', '@grapecity-software/spread-sheets-ganttsheet': 'npm:@grapecity-software/spread-sheets-ganttsheet/index.js', '@grapecity-software/spread-sheets-vue': 'npm:@grapecity-software/spread-sheets-vue/index.js', '@grapecity-software/jsob-test-dependency-package/react-components': 'npm:@grapecity-software/jsob-test-dependency-package/react-components/index.js', 'jszip': 'npm:jszip/dist/jszip.js', 'css': 'npm:systemjs-plugin-css/css.js', 'vue': 'npm:vue/dist/vue.min.js', 'vue-loader': 'npm:systemjs-vue-browser/index.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' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'js' }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' } } }); })(this);