简介

SpreadJS为了支持ADA以及屏幕阅读器(例如Windows讲述人模式、NVDA(非可视桌面访问)以及Mac操作系统的VoiceOver)提供了基础的辅助功能。

当SpreadJS开启辅助功能同时元素获取到了焦点,在以下情况下,屏幕阅读器就可以访问SpreadJS的文本内容:

1.通过按Tab键来更改选中的单元格。

2.通过移动鼠标在单元格上悬停。

当enableAccessibility为true时SpreadJS将启用辅助功能。 于此同时,SpreadJS能通过以下方式获得焦点。 1.当按下注册有moveToNextCellThenControl 或 selectNextControl, moveToPreviousCellThenControl 或 selectPreviousControl事件的Tab键或者Tab+Shift键时。 2.点击工作簿内元素。 3.调用工作簿的焦点方法。 此外,这些是常见操作系统的屏幕阅读器。 Windows操作系统的NVDA Mac操作系统的VoiceOver
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(_getElementById('ss'), { sheetCount: 1 }); initSpread(spread); }; function initSpread(spread) { spread.suspendPaint(); //enable accessibility spread.options.enableAccessibility = true; //set focus spread.focus(); //change the commands related to Tab key, Shift key with Tab key var commands = spread.commandManager(); //TAB commands.register("moveToNextCellThenControl", GC.Spread.Sheets.Commands.moveToNextCellThenControl, GC.Spread.Commands.Key.tab, false, false, false, false); //SHIFT+TAB commands.register("moveToPreviousCellThenControl", GC.Spread.Sheets.Commands.moveToPreviousCellThenControl, GC.Spread.Commands.Key.tab, false, true, false, false); var sheet = spread.getActiveSheet(); //set default row height and column width sheet.defaults.rowHeight = 50; sheet.defaults.colWidth = 150; //set default horizontal alignment and vertical alignment var defaultStyle = sheet.getDefaultStyle(); defaultStyle.hAlign = GC.Spread.Sheets.HorizontalAlign.center; defaultStyle.vAlign = GC.Spread.Sheets.VerticalAlign.center; sheet.setDefaultStyle(defaultStyle); //bind data source sheet.setDataSource(dataSource); spread.resumePaint(); } function _getElementById(id) { return document.getElementById(id); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="spreadjs culture" content="zh-cn" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/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$/spread/source/js/license.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.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"> <div class="option-row"> </div> </div> </div> </body> </html>
.sample-tutorial { height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; 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; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }