Office.OfficeTheme interface
提供了访问 Office 主题颜色的属性。
使用 Office 主题颜色,可以将加载项的配色方案与用户通过文件> Office帐户> Office主题 UI 选择的当前 Office 主题进行协调,该主题将应用于所有 Office 应用程序。 使用 Office 主题颜色适用于邮件和任务窗格外接程序。
注解
支持的应用程序(按平台)
Office 网页版 | Windows 版 Office | Mac 版 Office | iOS 版 Office | Android 版 Office | |
---|---|---|---|---|---|
Excel | 不可用 | 支持 | 支持 | 支持 | 不可用 |
Outlook | 不可用 | 预览 | 不可用 | 不可用 | 不可用 |
PowerPoint | 不可用 | 支持 | 支持 | 支持 | 不可用 |
Word | 支持 | 支持 | 支持 | 支持 | 不可用 |
示例
function applyOfficeTheme(){
// Get office theme colors.
const bodyBackgroundColor = Office.context.officeTheme.bodyBackgroundColor;
const bodyForegroundColor = Office.context.officeTheme.bodyForegroundColor;
const controlBackgroundColor = Office.context.officeTheme.controlBackgroundColor;
const controlForegroundColor = Office.context.officeTheme.controlForegroundColor;
// Apply body background color to a CSS class.
$('.body').css('background-color', bodyBackgroundColor);
}
属性
body |
获取 Office 主题正文背景色作为十六进制颜色三元 (例如“#FFA500”) 。 |
body |
获取 Office 主题正文前景色作为十六进制颜色三元 (,例如“#FFA500”) 。 |
control |
获取 Office 主题控件背景色作为十六进制颜色三元 (例如“#FFA500”) 。 |
control |
获取 Office 主题控件的前景色作为十六进制颜色三元 (,例如“#FFA500”) 。 |
属性详细信息
bodyBackgroundColor
获取 Office 主题正文背景色作为十六进制颜色三元 (例如“#FFA500”) 。
bodyBackgroundColor: string;
属性值
string
bodyForegroundColor
获取 Office 主题正文前景色作为十六进制颜色三元 (,例如“#FFA500”) 。
bodyForegroundColor: string;
属性值
string
controlBackgroundColor
获取 Office 主题控件背景色作为十六进制颜色三元 (例如“#FFA500”) 。
controlBackgroundColor: string;
属性值
string
controlForegroundColor
获取 Office 主题控件的前景色作为十六进制颜色三元 (,例如“#FFA500”) 。
controlForegroundColor: string;
属性值
string
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈