openpyxl 2.5.1 - AttributeError: module 'openpyxl.utils' has no attribute 'dataframe'

openpyxl 2.5.1 - AttributeError: module 'openpyxl.utils' has no attribute 'dataframe'

我正在使用 openpyxl 2.5.1 将数据帧从 pandas 导出到 Excel,我需要函数

openpyxl.utils.dataframe.dataframe_to_rows

documentation page中所写。但是,我收到以下错误:

AttributeError: module 'openpyxl.utils' has no attribute 'dataframe'

我发现解决了同样的问题,但是回答只是指出是版本升级的问题,并没有具体说明如何解决。

我在文档中找不到任何更改,因此我想知道该功能已移至何处。

预先感谢您的帮助。


PS 我必须使用这种方法,因为我需要在 Excel 工作表中附加数据而不破坏另一个工作表上的数据透视表。

这样做:

from openpyxl.utils.dataframe import dataframe_to_rows