如何使用openpyxl / python读取Excel文件的合并单元格值?

时间:2019-02-14 17:46:38

标签: python excel python-3.x openpyxl

我一直在尝试使用openpyxl模块读取合并单元格的值。但是,它给出以下错误:

if ws.cell(row=i, column=j).value == q.get(): #and ws.cell(row=i+1, column=j).value == 'tot.':

AttributeError:'MergedCell'对象没有属性'value'

您有什么建议?预先感谢!

1 个答案:

答案 0 :(得分:0)

为避免混淆,Private Sub Befehl83_Click() With Me.RecordsetClone .MoveFirst Do Until .EOF .Edit !visited = True .update .MoveNext Loop End With End Sub 没有值:它们仅用于在合并的单元格范围内设置边框,实际上不应视为单元格。使用Private Sub chkVisited_Click() If Not visitedList.Contains(Me.Form.Recordset.Fields("trainingMeasureID").Value) Then visitedList.Add Me.Form.Recordset.Fields("trainingMeasureID").Value Else visitedList.Remove Me.Form.Recordset.Fields("trainingMeasureID").Value End If End Sub update Stock set MIN_LVL=UnitsYearToDate/5 set ORD_QUANT=UnitsYearToDate/5*3 where (only using one of the following) REGULAR_SU='xxx' or SUBDEPARTM='xxx' or CODE between 'xxx' and 'xxx'