Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created June 27, 2019 23:52
Show Gist options
  • Save DataSolveProblems/c0b4e0194c60bcf21ce225db492ea97f to your computer and use it in GitHub Desktop.
Save DataSolveProblems/c0b4e0194c60bcf21ce225db492ea97f to your computer and use it in GitHub Desktop.
from Google import Create_Service
import win32com.client as win32
xlApp = win32.Dispatch('Excel.Application')
wb = xlApp.Workbooks.Open(r"<Excel File Path>")
ws = wb.Worksheets('<Worksheet Name>')
rngData = ws.Range('A1').CurrentRegion()
# Google Sheet Id
gsheet_id = '<Google Sheet Id>'
CLIENT_SECRET_FILE = 'client_secret.json'
API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION, SCOPES)
response = service.spreadsheets().values().append(
spreadsheetId=gsheet_id,
valueInputOption='RAW',
range='WorksheetName!A1',
body=dict(
majorDimension='ROWS',
values=rngData
)
).execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment