找回密码
 加入
搜索
查看: 3640|回复: 9

[系统综合] excel单元格 添加边框

  [复制链接]
发表于 2013-3-14 15:28:27 | 显示全部楼层 |阅读模式
excel中,如何添加单元格的边框?
边框类型如何选择?
哪位知道?
发表于 2013-3-14 19:13:22 | 显示全部楼层
;加边框
        With $oExcel.Activesheet.Range("a3:O16").Borders($xlEdgeLeft)
                .LineStyle = $xlContinuous
                .Weight = $xlThin
                .ColorIndex = $xlAutomatic
        EndWith
        With $oExcel.Activesheet.Range("a3:O16").Borders($xlEdgeTop)
                .LineStyle = $xlContinuous
                .Weight = $xlThin
                .ColorIndex = $xlAutomatic
        EndWith
        With $oExcel.Activesheet.Range("a3:O16").Borders($xlEdgeBottom)
                .LineStyle = $xlContinuous
                .Weight = $xlThin
                .ColorIndex = $xlAutomatic
        EndWith
        With $oExcel.Activesheet.Range("a3:O16").Borders($xlEdgeRight)
                .LineStyle = $xlContinuous
                .Weight = $xlThin
                .ColorIndex = $xlAutomatic
        EndWith
        With $oExcel.Activesheet.Range("a3:O16").Borders($xlInsideVertical)
                .LineStyle = $xlContinuous
                .Weight = $xlThin
                .ColorIndex = $xlAutomatic
        EndWith
        With $oExcel.Activesheet.Range("a3:O16").Borders($xlInsideHorizontal)
                .LineStyle = $xlContinuous
                .Weight = $xlThin
                .ColorIndex = $xlAutomatic
        EndWith
发表于 2013-3-14 19:15:33 | 显示全部楼层
Range 和 Style 对象具有四个分立的边框:左边框、右边框、顶部边框和底部边框,这四个边框既可单独返回,也可作为一个组同时返回。可用 Borders 属性返回 Borders 集合,该集合包含所有四个边框,并将这些边框作为一个单位。下例向第一张工作表上的单元格 A1 添加双边框。

Worksheets(1).Range("A1").Borders.LineStyle = xlDouble
               
可用 Borders(index)(其中 index 指定要返回的边框)返回单个 Border 对象。下例设置单元格区域 A1:G1 的底部边框的颜色。

Worksheets("Sheet1").Range("A1:G1"). _
    Borders(xlEdgeBottom).Color = RGB(255, 0, 0)
               
Index 可为以下 XlBordersIndex 常量之一:xlDiagonalDown、xlDiagonalUp、xlEdgeBottom、xlEdgeLeft、xlEdgeRight、xlEdgeTop、xlInsideHorizontal 或 xlInsideVertical。

$oExcel.activesheet.range("a1").borders.linestyle=1
细线边框
其他类型参阅帮助文件里的枚举"XlLineStyle"

评分

参与人数 1金钱 +10 收起 理由
peter13447 + 10 谢谢,老大

查看全部评分

 楼主| 发表于 2013-3-14 20:18:39 | 显示全部楼层
回复 3# kevinch

谢谢你的帮助!
 楼主| 发表于 2013-3-14 20:19:07 | 显示全部楼层
回复 2# h20040606


    谢谢你的帮助!
发表于 2013-4-4 09:34:25 | 显示全部楼层
路過,谢谢你的帮助!
发表于 2013-5-3 21:06:34 | 显示全部楼层
想知道的是这些语法规则都是从哪里看到的。。帮助文档里貌似没有。。
发表于 2013-5-3 21:41:21 | 显示全部楼层
Worksheets(1).Range("A1").Borders.LineStyle = xlDouble
上面这句输入到vbe编辑器里,然后用鼠标高亮选中LineStyle然后按F1
发表于 2013-5-4 15:30:42 | 显示全部楼层
又学到一招,果断高人呀!
发表于 2013-5-29 23:44:36 | 显示全部楼层
真是厉害,牛,学习一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-18 13:02 , Processed in 0.142790 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表