通过


Office.FileType enum

指定返回文档的格式。

注解

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/get-file-as-pdf.yaml

Office.context.document.getFileAsync(Office.FileType.Pdf, (result) => {
  if (result.status === Office.AsyncResultStatus.Failed) {
    console.error("getFileAsync failed:", result.error);
  } else {
    const myFile = result.value;
    const sliceCount = myFile.sliceCount;
    console.log("File size:" + myFile.size + " #Slices: " + sliceCount);

    // Get the file slices.
    const docDataSlices = [];
    let slicesReceived = 0,
      gotAllSlices = true;
    getSliceAsync(myFile, 0, sliceCount, gotAllSlices, docDataSlices, slicesReceived);

    myFile.closeAsync();
  }
});

字段

Compressed

返回 Office Open XML 中整个文档 (.pptx、.docx、.xlsx 或 .xlsm) , (OOXML) 格式为字节数组。

注意:Windows 和 Mac 上的 Excel 支持 .xslm 文件类型。 Excel web 版不支持它。 在 Excel on Windows 中,方法中的文件切片 getFileAsync 包括 .xslm 文件类型的 VBA 签名文件。 VBA 签名文件vbaProjectSignature.bin、vbaProbjectSignatureAgile.bin和vbaProjectSignatureV3.bin。 在 Excel on Mac 中,方法中的文件切片 getFileAsync 不包括 VBA 签名文件,因为此平台不支持 VBA 签名功能。

Pdf

将 PDF 格式的整个文档作为字节数组返回。

Text

仅以字符串形式返回文档的文本。