Python在Excel单元格中未获取正确的值

Python在Excel单元格中未获取正确的值,excel,python-2.7,excel-formula,win32com,Excel,Python 2.7,Excel Formula,Win32com,我想根据单元格的内容为其内部着色,但是当我访问其值时,我总是得到“1.0”,该值是计算出来的 着色代码: def _colorizeTop10RejetsSheet(self): """Colore les position de la page "Top 10 Rejets" """ start_position = (5, 12) last_line = 47 for x in range(start_position[0], last_line+1):

我想根据单元格的内容为其内部着色,但是当我访问其值时,我总是得到“1.0”,该值是计算出来的

着色代码:

def _colorizeTop10RejetsSheet(self):
    """Colore les position de la page "Top 10 Rejets" """
    start_position = (5, 12)
    last_line = 47
    for x in range(start_position[0], last_line+1):
        current_cell = self.workbook.Sheets("Top 10 Rejets").Cells(x, start_position[1])
        current_cell.Interior.Color = self._computePositionColor(current_cell.Value)

def _computePositionColor(self, position):
    """Colore les position de 1 a 5 en rouge de et 6 a 10 en orange"""
    if position < 6:
        return self.RED
    elif position < 11:
        return self.ORANGE
    else:
        return self.WHITE
如何获得计算值

我正在使用Python2.7,并通过Win32 COM与Excel进行通信


谢谢,在“colorizeTop10Rejets”方法的开头添加了这一点,成功了

self.xl.Calculate()
self.xl是win32.Dispatch('Excel.Application')返回的对象

self.xl.Calculate()