简体   繁体   English

如何向 Office 加载项添加打印功能?

[英]How to add a print functionality to Office Add-in?

I am building an Excel Add-in with the Office JS API.我正在使用 Office JS API 构建 Excel 加载项。 Is there a way to handle printing with the Add-in or open a printing window?有没有办法使用插件处理打印或打开打印窗口?

I have been going through the documentation but can't find any methods for this.我一直在浏览文档,但找不到任何方法。 Am I missing something?我错过了什么吗?

Edit: To be more specific, I want to open the Excel print dialog with the Add-in.编辑:更具体地说,我想用加载项打开 Excel 打印对话框。

There is no API in Office.js to invoke the Excel print dialog. Office.js 中没有用于调用 Excel 打印对话框的 API。 If you know that all the users of your add-in will be working on Windows machines, using desktop Excel, you might look into whether a VSTO/VBA add-in has this feature.如果您知道加载项的所有用户都将在 Windows 计算机上使用桌面 Excel,您可能会查看 VSTO/VBA 加载项是否具有此功能。 But if some users will be using Excel on the web or Excel on Mac, you'll have to stick to an Office.js add-in.但是,如果某些用户将在 Web 上使用 Excel 或在 Mac 上使用 Excel,则您必须坚持使用 Office.js 加载项。 In the later case, the best you can do is have your add-in prompt and/or instruct users to print from the Excel UI.在后一种情况下,您能做的最好的事情就是让您的加载项提示和/或指示用户从 Excel UI 打印。 You can have some control over the layout of the worksheet when it prints.您可以在打印时对工作表的布局进行一些控制。 See Work with worksheets - Page layout and print settings for more information.有关详细信息,请参阅使用工作表 - 页面布局和打印设置

You can suggest that Office add-ins be given access to the print UI at Microsoft 365 Developer Platform Ideas , but I suspect that security concerns would make it unlikely that Office.js-based add-ins, which are web applications, would be given that feature.您可以在Microsoft 365 Developer Platform Ideas建议授予 Office 加载项访问打印 UI 的权限,但我怀疑安全问题会导致不太可能授予基于 Office.js 的加载项(即 Web 应用程序)该功能。 The JavaScript/HTML that is hosted by a web application can be changed by its creator after the add-in has been installed by a user and/or approved by an administrator.在用户安装加载项和/或管理员批准后,Web 应用程序托管的 JavaScript/HTML 可以由其创建者更改。 This makes it possible for a rogue add-in creator to change the behavior of the add-in post-installation.这使得流氓加载项创建者可以更改加载项安装后的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM