Search code examples
javascriptgoogle-apigoogle-picker

Excel file is not display in google picker using javascript


I am using a google picker API for attachment. This is the google API library.

I am using a below code for the document display in picker.

var docsView = new google.picker.DocsView()
                .setIncludeFolders(false)
                .setMimeTypes('application/vnd.google-apps.folder,image/png,image/jpeg,image/jpg,text/plain,application/pdf,\n\
        application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/x-vnd.oasis.opendocument.spreadsheet,\n\
        text/csv,image/svg+xml,application/vnd.openxmlformats-officedocument.presentationml.presentation')
                .setSelectFolderEnabled(false);
        var picker = new google.picker.PickerBuilder()
                .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
                .setAppId(appId)
                .setOAuthToken(oauthToken)
                .addView(docsView)
                .addView(new google.picker.DocsUploadView())
                //.setDeveloperKey(developerKey)
                .setCallback(pickerCallback)
                .build();
        picker.setVisible(true);

This code is not displaying the document which was created from the drive , it is only display the documents which was uploaded to drive.

Is there any way to also display those document which was created from the drive?. I check the document but I cannot find anything that is helpful to me.


Solution

  • I just replace the view with below view condition:

        // NEW VIEW
        var docsView = new google.picker.DocsView(google.picker.ViewId.DOCS);
                docsView.setIncludeFolders(true);
                docsView.setSelectFolderEnabled(true);
    
       // OLD VIEW
        var docsView = new google.picker.DocsView()
                        .setIncludeFolders(false)
                        .setMimeTypes('application/vnd.google-apps.folder,image/png,image/jpeg,image/jpg,text/plain,application/pdf,\n\
                application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/x-vnd.oasis.opendocument.spreadsheet,\n\
                text/csv,image/svg+xml,application/vnd.openxmlformats-officedocument.presentationml.presentation')
                        .setSelectFolderEnabled(false);
    
     // THIS CODE WILL BE SAME
                var picker = new google.picker.PickerBuilder()
                        .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
                        .setAppId(appId)
                        .setOAuthToken(oauthToken)
                        .addView(docsView)
                        .addView(new google.picker.DocsUploadView())
                        //.setDeveloperKey(developerKey)
                        .setCallback(pickerCallback)
                        .build();
                picker.setVisible(true);