Google表格 - 范围

时间:2018-02-02 11:26:25

标签: python range jira google-sheets-api gspread

我的代码是从jira抓取值并将其添加到Google工作表。目前,它可以获得我需要的信息,并在谷歌表中输入1列。

如何在两个单独的列中获取信息?

谢谢!

# coding=utf-8

from jira.client import JIRA
import gspread
from oauth2client.service_account import ServiceAccountCredentials

SCOPES = ["https://spreadsheets.google.com/feeds"]

credentials = ServiceAccountCredentials.from_json_keyfile_name("blank", SCOPES)
connection = gspread.authorize(credentials)

options = {'server': 'https://jira.blank.com/'}
jira = JIRA(options, basic_auth=('blank', 'blabk'))
projects = jira.projects()

worksheet = connection.open("blank").sheet1

cell_list = worksheet.range('A2:A151')

for cell, x in zip(cell_list, jira.search_issues('filter=13360')):
issue = x
cell.value = x, issue.fields.summary

# Update in batch
worksheet.update_cells(cell_list)

print("Done updating, check the spreadsheet now")

1 个答案:

答案 0 :(得分:0)

此行代码仅从A列中获取:

cell_list = worksheet.range('A2:A151')

如果要获取其他列,如B,C等,请执行

cell_list = worksheet.range('A2:B') or

cell_list = worksheet.range('A2:B10')

您可以在Reading Cells中详细了解相关信息。