Openpyxl 3.1.1 'TextBlock' object has no attribute 'name'

解决方案 pip install lxml

As I wrote on the [mailing list](https://groups.google.com/g/openpyxl-users/c/ztrHJwWwfRU/m/ce3lFIvPGgAJ), this problem only occurs with **etree**, and not with **lxml**.
This explains why it works on some machines and fails on others.

See:

*   [text = r.name in etree_write_cell()](https://foss.heptapod.net/openpyxl/openpyxl/-/blob/e106fc0e5b3033d2e2846d2fffc1e29f0ab7d260/openpyxl/cell/_writer.py#L82)
*   [value = r.text in lxml_write_cell()](https://foss.heptapod.net/openpyxl/openpyxl/-/blob/e106fc0e5b3033d2e2846d2fffc1e29f0ab7d260/openpyxl/cell/_writer.py#L139)

So, if you have this issue, try installing lxml.
If you don't have this issue and want to reproduce it, set the environment variable OPENPYXL_LXML to False
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容