- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <script src="http://code.jquery.com/jquery-3.1.0.js"></script>
- <link href="http://cdn.grapecity.com/spreadjs/hosted/css/gcspread.sheets.excel2016colorful.9.40.20161.0.css" rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="http://cdn.grapecity.com/spreadjs/hosted/scripts/gcspread.sheets.all.9.40.20161.0.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- init();
- });
- function init() {
- var spread = new GcSpread.Sheets.Spread($("#ss")[0]);
- spread.setSheetCount(3);
- var sheet = spread.getActiveSheet();
-
- sheet.setIsProtected(true);
- sheet.getCell(0, 0).locked(false);
- sheet.getCell(1, 1).locked(false);
- sheet.getCell(2, 2).locked(false);
- sheet.getCell(2, 3).locked(false);
- var oldPaste = GcSpread.Sheets.SpreadActions.paste,
- oldSetValue = GcSpread.Sheets.Sheet.prototype.setValue;
- sheet.addKeyMap(GcSpread.Sheets.Key.v, true, false, false, false, function () {
- sheet.setIsProtected(false);
- GcSpread.Sheets.Sheet.prototype.setValue = function (row, col, value, sheetArea, ignoreRecalc) {
- if (sheet.getCell(row, col).locked()) {
- return;
- }
- oldSetValue.call(this, row, col, value, sheetArea, ignoreRecalc);
- };
- oldPaste.call(this);
- window.setTimeout(function () {
- GcSpread.Sheets.Sheet.prototype.setValue = oldSetValue;
- sheet.setIsProtected(true);
- }, 200)
- })
- }
- </script>
- </head>
- <body>
- <div id="ss" class="spread" style="width:1200px;height:300px"></div>
- </body>
- </html>
复制代码
|