openpyxl设置列宽
时间: 2023-08-26 21:19:30 浏览: 106
使用openpyxl可以通过设置column_dimensions属性来调整Excel中的列宽。可以使用以下代码来设置单列的宽度:
```
from openpyxl import load_workbook
wb = load_workbook('test.xlsx')
ws = wb请根据实际需求修改代码中的文件名和工作表索引。
希望对您有所帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Python使用OpenPyXl设置Excel表格中的单元格大小(行高和列宽)](https://blog.csdn.net/COCO56/article/details/108237690)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Python openpyxl 实现Excel自适应列宽的N种方法,亲测可用](https://blog.csdn.net/qq_33704787/article/details/124722917)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文