解决方案 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
网友评论