擅长:python、mysql、java
<p>这就是PIP(2.2.5)的最新版本最终对我起作用的地方</p>
<pre><code> # center all cells
for col in w_sheet.columns:
for cell in col:
# openpyxl styles aren't mutable,
# so you have to create a copy of the style, modify the copy, then set it back
alignment_obj = cell.alignment.copy(horizontal='center', vertical='center')
cell.alignment = alignment_obj
</code></pre>