Google Drive Picker ViewId.SPREADSHEET显示电子表格和表单

问题描述 投票:1回答:2

有没有办法将Google云端硬盘选择器限制为仅限电子表格。我正在添加电子表格视图ID(根据Google文档中的以下脚本),但它会同时显示表单和表单。

function createPicker(token) {
  if (pickerApiLoaded && token) {
    var picker = new google.picker.PickerBuilder()
        // Instruct Picker to display only spreadsheets in Drive. For other
        // views, see https://developers.google.com/picker/docs/#otherviews
        .addView(google.picker.ViewId.SPREADSHEETS)
        // Hide the navigation panel so that Picker fills more of the dialog.
        .enableFeature(google.picker.Feature.NAV_HIDDEN)
        // Hide the title bar since an Apps Script dialog already has a title.
        .hideTitleBar()
        .setOAuthToken(token)
        .setDeveloperKey(DEVELOPER_KEY)
        .setCallback(pickerCallback)
        .setOrigin(google.script.host.origin)
        // Instruct Picker to fill the dialog, minus 2 pixels for the border.
        .setSize(DIALOG_DIMENSIONS.width - 2,
            DIALOG_DIMENSIONS.height - 2)
        .build();
    picker.setVisible(true);
  } else {
    showError('Unable to load the file picker.');
  }
}
google-apps-script google-drive-sdk
2个回答
1
投票

首先,创建一个视图(注意view.setMimeTypes):

// Instruct Picker to display only spreadsheets in Drive. For other
// views, see https://developers.google.com/picker/docs/#otherviews
var view = new google.picker.DocsView(google.picker.ViewId.SPREADSHEETS);
view.setMimeTypes('application/vnd.google-apps.spreadsheet');
view.setIncludeFolders(true);

然后将视图添加到选择器:

var picker = new google.picker.PickerBuilder().addView(view)

2
投票

我认为你可以通过setting the MIME类型来做到这一点。可以找到MIME类型here.

PickerBuilder.setSelectableMimeTypes(string)
© www.soinside.com 2019 - 2024. All rights reserved.