0
votes

I'm trying to make a function for creating Excel file and upload the excel file to Google Sheets (Google Drive maybe) via API (that's possible I think). Then, the function will publish Google Sheets to Web (like as Publish to Web function in Google Sheets web UI) in order to embed the Google Sheets in my website for Preview.

I could not figure out the API endpoint to do Publish To Web via Python.

There is the only Stackoverflow link I found out that someone did it via JS code (Google Sheets API: How to "publish to web" for embeddable sheet?), but it requires Authentication at the client side. For my case, I want to implement the function in Backend (server) with an Authorization Token (hard-code or managed by backend)

Really appreciate if anyone know a solution to achieve my goal. Thanks so much.

2

2 Answers

1
votes

Answer:

Unfortunately there is not API endpoint for Google Drive nor Google Sheets which have the same functionality as the Publish to the web menu item in the Google Sheets UI.

More Information & Feature Request:

As it is possible to use the result of the Publish to the web menu item to embed a Sheet into a web page or Google Sites, it could be a useful API method for either Sheets or even Drive.

You can however let Google know that this is a feature that is important for the Sheets API and that you would like to request they implement it. Google's Issue Tracker[1] is a place for developers to report issues and make feature requests for their development services.

The page to file a Feature Request for the Google Sheets API can be found here[2].

I hope this is helpful to you!

References:

  1. Google's Issue Tracker
  2. File a Google Sheets API Feature Request
0
votes

Instead of creating an excel sheet, try uploading directly to google sheets using gspread.

If you have an excel sheet you want to go through, try reading the cell in excel then writing that cell in google sheets

(Not my links, but should be a good reference to get started)

https://gspread.readthedocs.io/en/latest/

https://pypi.org/project/gspread/

https://www.youtube.com/watch?v=cnPlKLEGR7E