OneNote Extension-Main API
API main Extension OneNote
2023-06-13 09:13:00 时间
Environment Setup
Main API Usage
There are 2 types of main API:
- host-specific API: able to access oneNote related contents, such as section, page details
- Common API: able to access Office related contents, such as selected content , font and other software common details.
Host-Specfic API Usage
- Access application instance
- Create proxy
- Implement this proxy to do load action, this action will be push push into queue, but will NOT execute immediately
- Invoke
context.sync
to execute the events in the queue.
function getPagesInSection() {
OneNote.run((context) => {
// 1. Access API via context.application, access pages details from getActiveSection()
var pages = context.application.getActiveSection().pages;
// 2. load the page id & title, but will NOT execute immediately
pages.load('id,title');
// 3. Async function, execute the events in the queue
return context.sync()
.then(() => {
// 4 Access the id & title
for (let page of pages.items) {
var pageId = page.id;
var pageTitle = page.title;
console.log(pageTitle + ': ' + pageId);
}
})
.catch((error) => {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
});
}
Common API Usage
function getSelectedText() {
// Access the mouse selected text
Office.context.document.getSelectedDataAsync(
Office.CoercionType.Text, {
valueFormat: "unformatted"
},
function(asyncResult) {
var error = asyncResult.error;
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.log(error.message);
} else console.log(asyncResult.value);
});
}
相关文章
- 天气预报api免费接口_天气API
- SDK 与 API 之间的区别
- 博客通过 API 实现'随机美文'
- 常见QQ签到Api分享
- 使用百度地图api通过redis实现地标存储及范围坐标点查询功能
- ZooKeeper学习之路 (十一)ZooKeeper API的应用详解大数据
- Java根据百度API获得经纬度,然后根据经纬度在获得城市信息详解编程语言
- api接口数据加密和身份验证详解编程语言
- 探索Linux系统 API 的乐趣(linux系统api)
- MySQL的API接口:快速、便捷的数据库访问方式(mysql的api接口)
- MongoDB C 语言 API 查询技巧(mongodbc查询)
- 操作Redis的API操作:最佳实践(redis的api)
- Linux 基金会联合谷歌微软推出“开放 API 战略”
- 简易指南:轻松使用Redis 常用API(redis常用api)
- 使用C语言访问Redis的API(redisapic)
- 使用MSSQL的API实现更佳的数据库管理(mssql的api)
- 使用Oracle内置API让程序开发更轻松(oracle内置api)
- Oracle数据库入门指南API快速入门(oracle入门api)
- API连接MySQL数据库实现快速灵活的数据存取(api连mysql数据库)
- API实现MySQL数据库备份(api备份mysql)
- API实现Mysql数据写入的完美解决方案(api 写入mysql)
- 简易Redis操作开启通用API之旅(redis 通用api)