时间选择器

时间选择器是SpreadJS中的一种下拉菜单,时间选择器下拉菜单定义在样式中,通过时间选择器用户可以方便地选择时间。

下拉菜单使开发人员能够向工作簿中的单元格添加具有特定属性的下拉菜单。 这些下拉菜单不需要任何额外的代码,只需指定要使用哪一种下拉菜单即可。 SpreadJS目前拥有8种下拉列表,当前介绍的是时间选择器下拉列表。 你可以使用时间选择器下拉列表,如以下代码所示: 还有一些用于自定义时间选择器的选项: max: ITimePickerValue : 时间选择器可显示的最大值,这个值需要时、分、秒等属性。 min: ITimePickerValue : 时间选择器可以显示的最小值,这个值需要时、分、秒等属性。 setp: ITimePickerValue : 时间选择器的步长。 formatString: string : 指定时间选择器显示的时间格式。 height: number : 指定时间选择器容器的高度,默认是300。
<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-resources-zh'; GC.Spread.Common.CultureManager.culture("zh-cn"); import "@grapecity-software/spread-sheets-vue"; import GC from "@grapecity-software/spread-sheets"; let App = Vue.extend({ name: "app", data: function() { return { spread: null }; }, methods: { createPickerStyle(option) { let timePickerStyle = new GC.Spread.Sheets.Style(); timePickerStyle.cellButtons = [{ imageType: GC.Spread.Sheets.ButtonImageType.dropdown, command: "openTimePicker", useButtonStyle: true, }]; timePickerStyle.dropDowns = [{ type: GC.Spread.Sheets.DropDownType.timePicker, option: option }]; return timePickerStyle; }, initSpread(spread) { let sheet = spread.getSheet(0); sheet.suspendPaint(); sheet.setText(1, 3, "Time Picker"); sheet.setStyle(2, 3, this.createPickerStyle({ min: { hour: 8 }, max: { hour: 19 }, step: { minute: 30 }, formatString: "h:mm AM/PM", })); sheet.setText(1, 7, "Time Picker"); sheet.setStyle(2, 7, this.createPickerStyle({ min: { hour: 5 }, max: { hour: 20 }, step: { minute: 30 }, formatString: "h:mm:ss", height: 350 })); sheet.resumePaint(); spread.commandManager().execute({ cmd: "openTimePicker", row: 2, col: 3, sheetName: "Sheet1" }); } } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <style> .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; } </style>
<!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="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>
(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-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);