基本应用

Spread.Sheets支持触摸。这样就可以在移动设备和支持触摸的设备上使用您的应用程序,从而提供用户访问您的内容的多种方式。

<p>Spread Sheets 支持以下平台的触摸操作。</p> <ul> <li><strong>Desktop: Windows--IE 9+, Chrome, Firefox, Opera</strong></li> <li><strong>Tablet PC: iPad--Chrome, Safari; Android Pad--Chrome; Surface--IE 10+</strong></li> <li><strong>Mobile: Android--Chrome; Windows Phone: IE 10+</strong></li> </ul> <p>你可以调用 <strong>useTouchLayout</strong> 属性来获取或者设置是否使用触摸布局来呈现 Spread 部件。在触摸布局下,控件更容易进行触摸操作。</p> <pre><code class="hljs js language-js">spread.options.useTouchLayout = <span class="hljs-literal">true</span>; </code></pre> <p>Spread Sheets 在触摸模式下提供了很多功能,包括滚动,缩放,选择,调整大小,拖拽填充,组,单元格类型,自动调整,编辑,工作表选项卡和工具栏。</p>
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss")); spread.options.useTouchLayout = true; var sd = dataSource; var sheet = spread.getActiveSheet(); if (sd.length > 0) { sheet.setDataSource(sd); } sheet.setColumnWidth(0, 160); sheet.setColumnWidth(1, 70); sheet.setColumnWidth(2, 90); sheet.setColumnWidth(3, 110); sheet.setColumnWidth(4, 80); sheet.setColumnWidth(6, 110); document.getElementById('useTouchLayout').onclick = function (e) { spread.options.useTouchLayout = e.target.checked; }; };
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="zh-cn" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/data.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.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 class="options-container"> <input type="checkbox" id="useTouchLayout" checked="checked"> <label for="useTouchLayout">Enable Touch</label> </div> </div> </body> </html>
.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: 5px; margin-top: 10px; } label { margin-bottom: 6px; } input { padding: 4px 6px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }