finspin
unread,Dec 12, 2012, 6:09:04 AM12/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to robotframe...@googlegroups.com
I'm testing an excel library I found copy/pasted on this forum. I'm running into problem with one keyword though.
Here is the library:
# ExcelKeywords.py
from xlrd import open_workbook
class ExcelKeywords(object):
book=None
currentSheet=None
def __init__(self):
self.book=None
def open_excel_file(self, file, sheetIndex=0):
self.book = open_workbook(file)
self.currentSheet = self.book.sheet_by_index(sheetIndex)
def get_excel_column_count(self):
return self.currentSheet.ncols
def get_excel_row_count(self):
return self.currentSheet.nrows
def get_excel_row_values(self, row):
return [self.currentSheet.cell(row,col).value for col in range(self.currentSheet.ncols)]
def get_excel_cell_value(self, row, column):
return self.currentSheet.cell(int(row),int(column)).value
My tests:
Test Excel Library
Open Excel File test.xlsx
${row_column}= Get Excel Column Count
${row_count}= Get Excel Row Count
@{row_values}= Get Excel Row Values 0
${cell_value}= Get Excel Cell Value 0 0
All keywords work fine except the second last - Get Excel Row Count. I'm getting an error: TypeError: list indices must be integers, not unicode.
I can't figure out what's the problem. Any ideas?