This operation is not supported for this document – Sheets API
Question:
(<class ‘googleapiclient.errors.HttpError’>, <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1IcMY2TNLYZtGyKO_zcrhP1MudNFXbNdM/values/P%C3%A1gina1%21A%3AP?alt=json returned "This operation is not supported for this document">, <traceback object at 0x7fbb3dc3bec0>)
I am getting this error message when accessing a spreadsheet in Google Sheets, I know that the error occurs because it is hosted on the google drive and is in xlsx format. Does anyone know any alternative to performing this conversion from xlsx to gsheet directly in the code?
Answers:
Yes, you can convert an .xlsx to Google Sheets
For this, use the method Drive v2 method Files: Copy specifying convert
true
.
Sample:
service.files().copy(fileId=file_id,convert=true, body={"title": "specifyName"}).execute()
You can also convert the Excel file within Google Drive to use it with Google Sheets API.
See Google Workspace Learning Center: Sheets and Excel best practices, Convert Excel files to Sheets:
- Open Drive and double-click an Excel file. A preview of your file opens.
- At the top, click "Open with Google Sheets".
- Click "File" and then "Save as Google Sheets".
(<class ‘googleapiclient.errors.HttpError’>, <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1IcMY2TNLYZtGyKO_zcrhP1MudNFXbNdM/values/P%C3%A1gina1%21A%3AP?alt=json returned "This operation is not supported for this document">, <traceback object at 0x7fbb3dc3bec0>)
I am getting this error message when accessing a spreadsheet in Google Sheets, I know that the error occurs because it is hosted on the google drive and is in xlsx format. Does anyone know any alternative to performing this conversion from xlsx to gsheet directly in the code?
Yes, you can convert an .xlsx to Google Sheets
For this, use the method Drive v2 method Files: Copy specifying convert
true
.
Sample:
service.files().copy(fileId=file_id,convert=true, body={"title": "specifyName"}).execute()
You can also convert the Excel file within Google Drive to use it with Google Sheets API.
See Google Workspace Learning Center: Sheets and Excel best practices, Convert Excel files to Sheets:
- Open Drive and double-click an Excel file. A preview of your file opens.
- At the top, click "Open with Google Sheets".
- Click "File" and then "Save as Google Sheets".