From bcba4f53b58484a2469fdcc267ad74e67480625b Mon Sep 17 00:00:00 2001 From: shuikulangzi <1284617092@qq.com> Date: Wed, 25 Jun 2025 23:38:19 +0800 Subject: [PATCH] =?UTF-8?q?day24=E5=A2=9E=E5=8A=A0xlwt=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E8=AE=BE=E7=BD=AE=E8=BE=B9=E6=A1=86=E7=94=A8?= =?UTF-8?q?=E6=B3=95=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Day21-30/24.Python读写Excel文件-1.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Day21-30/24.Python读写Excel文件-1.md b/Day21-30/24.Python读写Excel文件-1.md index 6ddbc41..02d903c 100755 --- a/Day21-30/24.Python读写Excel文件-1.md +++ b/Day21-30/24.Python读写Excel文件-1.md @@ -145,12 +145,14 @@ props = ( ) # 通过循环对四个方向的边框样式及颜色进行设定 for position, color in props: - # 使用setattr内置函数动态给对象指定的属性赋值 + # 使用setattr内置函数动态给对象指定的属性赋值 0-无边框、1-实线 2-虚线、3-点线、4-细双线、5-中粗线、6-双线、7-粗线 setattr(borders, position, xlwt.Borders.DASHED) setattr(borders, color, 5) header_style.borders = borders ``` +> **注意**:在某些版本(如 xlwt 1.3.0+)中,实线边框是通过整数常量来表示的,而不是使用类似DASHED的属性名,例如setattr(borders, position, 1) + 如果要调整单元格的宽度(列宽)和表头的高度(行高),可以按照下面的代码进行操作。 ```python