← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #653759]: How to fetch the cell value of excel sheet

 

Question #653759 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/653759

masuo proposed the following answer:
If you are using Sikuli IDE, try following codes.

import xlrd
import datetime
EXCELFILE  = "C:\\temp\\book1.xls"

book = xlrd.open_workbook(EXCELFILE)
sheet = book.sheet_by_index(0)
for col in range(sheet.ncols):
    for row in range(sheet.nrows):
        celltype = sheet.cell_type(row,col)
        value = sheet.cell_value(row,col)
        if celltype == 1:
            print "col:%d row:%d value:%s" % (col,row,value)
        elif celltype == 2:
            print "col:%d row:%d value:%d" % (col,row,value)
        elif celltype == 3:
            s = datetime.datetime(*xlrd.xldate_as_tuple(value,book.datemode)).strftime("%Y/%m/%d %H:%M:%S")
            print "col:%d row:%d value:%s" % (col,row,s)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.