0

在 excel 2011 中,使用苹果脚本创建了一个额外的系列。

   tell application "Microsoft Excel"
    make new workbook
    tell worksheet "sheet1" of active workbook
        set value of cell "A1" to 10
        set value of cell "B1" to 5
        set obj to make new chart object at end with properties {left position:100,      top:100, height:200, width:300, name:"MyChart"}
        set ochart1 to chart of chart object "MyChart"
        tell ochart1
            set chart type to bar clustered
            make new series at end with properties {series values:"=Sheet1!$A$1:$B$1", name:"2"}

        end tell
    end tell
end tell

我的问题是,在 sheet1 中创建了一个额外的系列(即系列 1)。

在此处输入图像描述

在此处输入图像描述

4

2 回答 2

0

当您创建更有意义的系列时,似乎一切正常:

tell application "Microsoft Excel"
    make new workbook
    tell worksheet "sheet1" of active workbook
        set value of cell "A1" to 2
        set value of cell "B1" to 3
        set value of cell "A2" to 4
        set value of cell "B2" to 6
        set value of cell "A3" to 10
        set value of cell "B3" to 5
        set obj to make new chart object at end with properties {left position:100, top:100, height:200, width:300, name:"MyChart"}
        set ochart1 to chart of chart object "MyChart"
        tell ochart1
            set chart type to bar clustered
            #remove  first series
            make new series at end with properties {series values:"=Sheet1!$A$1:$A$3", name:"one"}
            make new series at end with properties {series values:"=Sheet1!$B$1:$B$3", name:"two"}
        end tell
    end tell
end tell

注意 - 我单独创建了这个系列,因为我不知道如何在单个语句中为它们命名。

于 2013-02-12T05:48:54.630 回答
0

我确信这不是正确的做法,但它应该可以完成工作。

tell application "Microsoft Excel"
    make new workbook
    tell worksheet "sheet1" of active workbook
        set value of cell "A1" to 10
        set value of cell "B1" to 5
        set obj to make new chart object at end with properties {left position:100, top:100, height:200, width:300, name:"MyChart"}
        set ochart1 to chart of chart object "MyChart"
        tell ochart1
            set chart type to bar clustered
            make new series at end with properties {series values:"=Sheet1!$A$1:$B$1", name:"2"}
            delete (every series whose name ≠ "2")
        end tell
    end tell
end tell
于 2013-02-07T15:01:49.180 回答