删除单元格边框 [英] Remove cell borders

查看:124
本文介绍了删除单元格边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Applescript删除数据表中的单元格边框时遇到了麻烦. 我首先从包含C15:K31中数据的电子表格开始.这些单元中的每个单元都有一个边框.我要做的就是在索引4(D列)插入一列,然后将D列中的每个单元格设置为没有边框.我添加了一个重复项以查看D列中的每个单元格,但理想情况下,我将一次删除所有格式,而无需重复.

I'm having trouble using Applescript to remove cell borders in a table of data. I'm starting out with a spreadsheet that contains data in C15:K31. Each of these cells has a border around it. All I want to do is insert a column at index 4 (column D) and then set each of the cells in column D to not have any borders. I included a repeat to look at every cell in column D, but ideally I would simply remove the formatting all at once, without the repeat.

有什么想法吗?我的代码如下:

Any thoughts? My code is below:

告诉应用程序"Microsoft Excel"

tell application "Microsoft Excel"

activate workbook
try
    set maxCount to count of sheets of active workbook
    set sheetCounter to 1
    repeat maxCount times
        activate object worksheet sheetCounter
        set theWorksheetName to name of worksheet sheetCounter of active workbook
        if theWorksheetName contains "gap" then
                insert into range column 4 of active sheet
                set column width of column 4 of active sheet to 7.5
                set color index of interior object of column 4 to 0

                set startFormatHere to range "D1" of active sheet
                set nextRow to 1
                repeat 20 times
                    set formatCell to (get offset startFormatHere row offset nextRow)
                    set formatHere to (get address of formatCell)
                    set cellRange to range formatHere

-以下任何尝试均未删除边框

--None of the below attempts have worked to remove border lines

                    --clear contents range "D2" of active sheet of active workbook 
                    --tell border object of range "D2"
                    --set {line style, line weight, weight, visible} to {None, 0, 0, false}
                    --end tell

                    --set border of range "D2" to false
                    --set weight of (get border of cellRange which border edge bottom) to None
                    --set line style of border object of range "D2" to line style none                  

                    --set line weight of cellRange to 0

                    set nextRow to nextRow + 1
                end repeat
            end repeat
            set sheetCounter to sheetCounter + 1
        else
            set sheetCounter to sheetCounter + 1
        end if
    end repeat
end try

结束告诉

推荐答案

您需要get border命令-> get border (a range) which border (an enumeration),可以是以下之一:

You need the get border command --> get border (a range) which border (an enumeration), can be one of the following:

tell application "Microsoft Excel"
    activate workbook
    set maxCount to count of sheets of active workbook
    repeat with sheetCounter from 1 to maxCount
        activate object worksheet sheetCounter
        set theWorksheetName to name of worksheet sheetCounter of active workbook
        if theWorksheetName contains "gap" then
            insert into range column 4 of active sheet
            set column width of column 4 of active sheet to 7.5
            set color index of interior object of column 4 to 0

            set myRange to range "D1:D20" of active sheet
            set myBorders to {border top, border bottom, border left, border right}
            repeat with i from 1 to 4
                set theBorder to get border myRange which border (item i of myBorders)
                set line style of theBorder to line style none
            end repeat
        end if
    end repeat
end tell

这篇关于删除单元格边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆