Explorar o código

feat: Add Google Sheets support to file picker with .xlsx export

Taylor Wilsdon (aider) hai 4 meses
pai
achega
eae86f04c5
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/lib/utils/google-drive-picker.ts

+ 3 - 1
src/lib/utils/google-drive-picker.ts

@@ -104,7 +104,7 @@ export const createPicker = () => {
                 .addView(new google.picker.DocsView()
                     .setIncludeFolders(false)
                     .setSelectFolderEnabled(false)
-                    .setMimeTypes('application/pdf,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.google-apps.document'))
+                    .setMimeTypes('application/pdf,text/plain,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.google-apps.document,application/vnd.google-apps.spreadsheet'))
                 .setOAuthToken(token)
                 .setDeveloperKey(API_KEY)
                 // Remove app ID setting as it's not needed and can cause 404 errors
@@ -132,6 +132,8 @@ export const createPicker = () => {
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
                                 } else if (mimeType.includes('spreadsheet')) {
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
+                                    // Update filename to have .xlsx extension for spreadsheets
+                                    fileName = fileName.endsWith('.xlsx') ? fileName : `${fileName}.xlsx`;
                                 } else if (mimeType.includes('presentation')) {
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
                                 } else {