从 Android 应用程序与 Office 集成Integrate with Office from Android applications

06/18/2015

本文内容

Office for Android 提供了一个可扩展的的解决方案,可与第三方应用程序集成。您可以将用户从您的应用程序传递到 Office,从 Android 应用程序与 Office 集成。Office for Android provides an extensible solution that enables integration with third-party applications. You can integrate with Office from your Android application by passing users from your application to Office.

您可以让在 Android 设备上运行 Office 的用户从任何应用程序打开和编辑存储在 SharePoint 或 OneDrive 中的文件。为此,您可以通过协议处理程序将文件传递到 Office,并确保以 Office 可以理解的方式来调用 Office。You can enable users who are running Office on an Android device to open and edit files stored in SharePoint or OneDrive from any application. To do this, you pass files to Office via protocol handlers, and you make sure that Office is invoked in a way that Office can understand.

用户完成编辑文件后,可以选择设备上的返回键,返回到原始存储应用程序。When a user is done editing a file, they can choose the back key on the device to return to the original storage application.

确定已安装 OfficeVerify that Office has been installed

引用的应用程序将首先需要验证特定 Office 应用程序是否已安装。以下 Office 应用程序可以安装在 Android 设备上用于查看和编辑文档:Your referring application will first need to verify that a particular Office application is installed. The following Office applications can be installed on Android devices for document viewing and editing:

ExcelExcel

PowerPointPowerPoint

WordWord

使用 Android PackageManager 确定设备上是否已安装特定的 Office 应用程序。下表列出了您在此过程中可使用的 Office 应用程序包的名称。Use Android PackageManager to determine whether a particular Office application is installed on the device. The following table lists the package names for the Office applications that you can use in this process.

应用程序Application

包名称Package name

ExcelExcel

com.microsoft.office.excelcom.microsoft.office.excel

PowerPointPowerPoint

com.microsoft.office.powerpointcom.microsoft.office.powerpoint

WordWord

com.microsoft.office.wordcom.microsoft.office.word

提示用户安装 OfficePrompt the user to install Office

如果未安装某个特定的 Office 应用程序,您可以提示用户安装该应用程序。下表列出了 Office 应用程序可用的安装位置。If a particular Office application is not installed, you can prompt the user to install the application. The following table lists the available install locations for Office applications.

调用 OfficeInvoke Office

当安装 Office 应用程序时,引用应用程序可以通过传递以下详细信息调用 Office:When the Office application is installed, your referring application can invoke Office by passing the following details:

Office 协议Office protocol

打开模式Open mode

URLURL

架构格式:Schema format:

|u|

以下示例显示调用 Word 文件以供编辑的请求。The following example shows a request to invoke a Word file for editing.

ms-word:ofe|u|https://contoso/Q4/budget.docx

Office 协议Office protocols

下表列出了每个 Office 应用程序的协议。The following table lists the protocols for each Office application.

应用程序Application

协议Protocol

ExcelExcel

ms-excel:ms-excel:

PowerPointPowerPoint

ms-powerpoint:ms-powerpoint:

WordWord

ms-word:ms-word:

打开模式Open mode

Office 应用程序可以直接在视图 (ofv) 或编辑 (ofe) 模式下打开文件。编辑模式为默认设置。Office applications can open files directly into view (ofv) or edit (ofe) mode. Edit mode is the default.

架构格式:Schema format:

URLURL

URL 包括三个部分:The URL includes three parts:

文件将在编辑 (ofe) 模式下打开的声明The declaration that the file will be opened for edit (ofe)

URL 描述符 (|u|)The URL descriptor (|u|)

URLThe URL

URL 必须进行编码,并且必须是指向文件(不是重定向)的直接链接。如果 URL 的格式不是 Office 能够处理的格式,或者只是下载失败,Office 就不会将用户返回到调用应用程序。The URL has to be encoded and must be a direct link to the file (not a redirect). If the URL is in a format that Office cannot handle, or the download simply fails, Office will not return the user to the invoking application.

架构格式:Schema format:

|u|

另请参阅See also