You can do this using the Drive API by setting the MIME type to application/vnd.google-apps.spreadsheet
:
To do this in Python:
from apiclient.discovery import build
service = build('drive', 'v2')
import httplib2
credentials = ... # Obtain OAuth 2.0 credentials
http = credentials.authorize(httplib2.Http())
body = {
'mimeType': 'application/vnd.google-apps.spreadsheet',
'title': 'Name of Spreadsheet',
}
file = service.files().insert(body=body).execute(http=http)
# or for version 3 it would be
# file = service.files().create(body=body).execute(http=http)
Head over to the Google APIs Explorer to try it out!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…