使用Python脚本将Excel数据导入Jira

使用Python脚本将Excel数据导入Jira,python,excel,python-2.7,jira,python-jira,Python,Excel,Python 2.7,Jira,Python Jira,我目前一直在使用一个简单的脚本,它从Excel文件中读取数据,然后将这些数据转换为Jira上的任务 from openpyxl import load_workbook from jira import JIRA print("Imports Work") jira = JIRA('http://jira-mycompany:8080/', basic_auth=('ZippertjeZappertje', 'Passwordhiddenforthepurpose of this')) w

我目前一直在使用一个简单的脚本,它从Excel文件中读取数据,然后将这些数据转换为Jira上的任务

from openpyxl import load_workbook
from jira import JIRA

print("Imports Work")

jira = JIRA('http://jira-mycompany:8080/', basic_auth=('ZippertjeZappertje', 
'Passwordhiddenforthepurpose of this'))
wb = load_workbook(filename = 'ImportTasksExcel.xlsx', read_only = True)
ws = wb['Sheet1']

def promp():
   print("Press Any Key To Continue...")
   input()

def getCellValue(worksheet,  r, c):
   if(worksheet.cell(row=r, column=c).value == None):
      print("Error: Empty Cell. Row " + str(r) + " Col " + str(c))
      promp()
   return worksheet.cell(row=r, column=c).value

print("Worksheet Loaded")

key = ''
parent = ''
child = ''
prename = ''
time = ''
crew = ''
team = ''
importance = ''
person = ''
desc = ''
i = 0

print("Variables Initialised")

for i in range (2, ws.max_row+1):
    pro = getCellValue(ws, i, 1)
    key = ws.cell(row=i, column=2).value
    parent_issue = jira.issue(key)
    parent = str(parent_issue.fields.summary)
    type = getCellValue(ws, i, 3)
    type = ws.cell(row=i, column=3).value
    prename = ws.cell(row=i, column=4).value 
    taskname = ws.cell(row=i, column=5).value 
    child = prename + taskname
    prio = ws.cell(row=i, column=6).value 
    imp = ws.cell(row=i, column=7).value
    confidence = getCellValue(ws, i, 8)
    team = getCellValue(ws, i, 9)
    person = ws.cell(row=i, column=10).value
    time = ws.cell(row=i, column=11).value
    desc = ws.cell(row=i, column=12).value
    sum = prename + " - " + taskname
    report = ws.cell(row=i, column=13).value
    print (sum)

    issue = jira.create_issue(project=pro, summary=sum, description=desc, 
    issuetype=type,  assignee={'name': person}, reporter={'name': report}, 
    timetracking =  {"originalEstimate": time,"remainingEstimate": time}, 
    customfield_11200 = { "value": team }, customfield_12306 = { "value": 
    confidence }, customfield_11100 = { "value": imp }, priority = {'name': 
    prio}    

    print("Successfuly Created: "+ str(issue))

    print('Linking Child: ' + str(issue) + '\t to Parent: ' + key)

    jira.create_issue_link('Broken into', key, str(issue))
    print("SUCCESS\n")



print("\n\nDONE\t Total New Issues Created and Linked: " + str(i-1))
input("prompt: ")
raw_input("Press Enter to Continue: ")
代码返回以下TypeError:

第39行,在 pro=getCellValue(ws,i,1)
第16行,在getCellValue中 如果(工作表.cell(行=r,列=c).值=None): TypeError:必须使用工作表实例作为第一个参数调用unbound方法cell()(但没有得到任何结果)


我真的不明白,因为“工作表”是我为
getCellValue
函数声明的参数?
cell()
方法访问行
r
和列
c
的单元格,然后
value()
方法应该返回该单元格的值?

让我们澄清一下:所讨论的方法
cell
是什么?b) 如果在
getCellValue
中添加
print(type(workeep))
您会看到什么?print(type(workeep))在范围(2,ws.max\u row+1)内返回i的Hm.
您在第一次迭代或最后一次迭代时是否会出错?在第一个单元格上同时获取i==2和i==ws.max\u row的错误。假设:-是否所有行都执行得很好,不是其中一行,有些行执行得很好,有些行执行得不好?(我希望你能看到这面墙)让我们澄清一下:所讨论的方法
cell
?b) 如果在
getCellValue
中添加
print(type(workeep))
您会看到什么?print(type(workeep))在范围(2,ws.max\u row+1)内返回i的Hm.
您在第一次迭代或最后一次迭代时是否会出错?在第一个单元格上同时获取i==2和i==ws.max\u row的错误。假设:-是否所有行都执行得很好,不是其中一行,有些行执行得很好,有些行执行得不好?(我希望你能看到这堵墙)