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?

Asked By: Lucas Ventura

||

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()
Answered By: ziganotschka

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:

  1. Open Drive and double-click an Excel file. A preview of your file opens.
  2. At the top, click "Open with Google Sheets".
  3. Click "File" and then "Save as Google Sheets".
Answered By: hc_dev
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.