# Read row data from Excel and returns it as a list
# Input Excel file
# sheetx = number of sheet within the Excel file (beginning with 1) OR its name
# row0 is the actual row as displayed in Excel
# startC and endC are the respective columns using the Excel letters, end is inclusive

def extXLS(file,sheetx,row0,startC,endC):
row = row0 - 1 #Excel starts at 1, Python at 0

if len(startC) == 1:
start = string.ascii_uppercase.index(startC)
else:
start = ((string.ascii_uppercase.index(startC[0]) + 1) * 26 +
string.ascii_uppercase.index(startC[1]))

if len(endC) == 1:
end = string.ascii_uppercase.index(endC) + 1
else:
end = ((string.ascii_uppercase.index(endC[0]) + 1) * 26 +
string.ascii_uppercase.index(endC[1]) + 1)

xlsFile = xlrd.open_workbook(file) #Open Excel File

if isinstance(sheet,int): #if sheet is integer, sheet will be chosen by index
sheet = sheetx - 1 #Excel starts at 1, Python at 0
xlsSheet = xlsFile.sheet_by_index(sheet)
else:
xlsSheet = xlsFile.sheet_by_name(sheet) #Choose the sheet by name instead

dataRow = xlsSheet.row_values(row, start, end)

return dataRow