0

I want to access the cell which has formula from the excel workbook. I have a script that is working fine but only read the data from excel.

I only need to print the cells with formula. An example would be really appreciated.

fredtantini
  • 15,966
  • 8
  • 49
  • 55
Michael
  • 73
  • 1
  • 9
  • possible duplicate of [Get formula from Excel cell with python xlrd](http://stackoverflow.com/questions/4690423/get-formula-from-excel-cell-with-python-xlrd) – fredtantini Oct 06 '14 at 10:11
  • i want to check the cell the has formula or not. if the formula is there, print true else false @fredtantini – Michael Oct 06 '14 at 10:18

1 Answers1

0

How about this below function:- Input Parameter you need to pass in the below function like that below:-

Input Parameter:- validateExcelData("Desktop/test.xls,55")

Note:- Here 55 is the count using formula, for this below if condition will not work and you will get the result fail, but if the integer value is without formula then if condition will work and result you will get pass. Also this is not the efficient code. Just look if it helps:)

def validateExcelData(input):
    inputParam=input.split(",")
    filePath=inputParam[0].strip()
    value=inputParam[1].strip()
    outputParams="Fail"
    try:
        fs = os.sep.join((os.path.expanduser("~"),filePath))
        wb=xlrd.open_workbook(fs)
        for s in wb.sheets():
            for row in range(s.nrows):
                for col in range(s.ncols):
                    if s.cell(row,col).value==int(value):
                        outputParams ="PASS"
                        break
    except:
        outputParams = GetException()


    return outputParams
Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56