Created
November 7, 2018 04:24
-
-
Save kreja/d4385aa666758fa80565f156256f8cd1 to your computer and use it in GitHub Desktop.
lock a range - 与Script Lab共享
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 锁定 | |
description: lock a range | |
author: kreja | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#setup").click(setup); | |
async function setup() { | |
await Excel.run(async (context) => { | |
const sheet = context.workbook.worksheets.getActiveWorksheet(); | |
var wholerange = sheet.getRange(); | |
wholerange.format.fill.color = "#00FF00"; | |
wholerange.format.protection.locked = false; | |
var range = sheet.getRange("A2:D5"); | |
range.format.fill.color = '#FF0000'; | |
range.format.protection.locked = true; | |
sheet.protection.protect({ allowInsertRows: true }); | |
await context.sync(); | |
}); | |
} | |
language: typescript | |
template: | |
content: | | |
<section class="ms-font-m"> | |
<p>This sample shows how to format a range using the Excel API.</p> | |
</section> | |
<section class="setup ms-font-m"> | |
<h3>Set up</h3> | |
<button id="setup" class="ms-Button"> | |
<span class="ms-Button-label">Add sample data</span> | |
</button> | |
</section> | |
<section class="samples ms-font-m"> | |
<h3>Try it out</h3> | |
<button id="set-font-and-fill-color" class="ms-Button"> | |
<span class="ms-Button-label">Set font and fill color</span> | |
</button> | |
<button id="set-number-format" class="ms-Button"> | |
<span class="ms-Button-label">Set number format</span> | |
</button> | |
</section> | |
language: html | |
style: | |
content: | | |
section.samples { | |
margin-top: 20px; | |
} | |
section.samples .ms-Button, section.setup .ms-Button { | |
display: block; | |
margin-bottom: 5px; | |
margin-left: 20px; | |
min-width: 80px; | |
} | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css | |
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css | |
core-js@2.4.1/client/core.min.js | |
@types/core-js | |
@microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js | |
@microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts | |
jquery@3.1.1 | |
@types/jquery@3.3.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment