使用python gdata.spreadsheets将列标题添加到Google表格?

时间:2015-09-04 14:06:53

标签: python google-sheets gdata

我正在使用带有gauth的谷歌电子表格的python gdata API。我可以轻松插入一行并仅填充某些列,但我无法弄清楚如何添加新列。

我用这个连接到电子表格:

import json, gdata.gauth, gdata.spreadsheets.client
from oauth2client.client import Signed JwtAssertionCredentials

def connect():
        json_key = json.load(open('jsonfile.json'))
        scope = ['https://spreadsheets.google.com/feeds']
        credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
        client = gdata.spreadsheets.client.SpreadsheetsClient()
auth2token.authorize(client)



        entry = gdata.spreadsheets.data.ListEntry()


        key = "spreadsheetkey"
        return entry, client, key

然后添加一行填充某些列,我使用:

entry, client, key = connect()
entry.set_value('column_name',cell_value)
entry.set_value('column2_name',cell_value)
client.add_list_entry(entry,key,'od6')

只要列已经存在,这就有效。有没有办法创建具有特定名称的新列?

0 个答案:

没有答案