如何在Mac Osx上通过Microsoft Excel中的(ruby)脚本读取单元格的背景颜色?

我想获取Excel工作表单元格的背景颜色。 我已经尝试了以下内容:

begin; require 'rubygems'; rescue LoadError; end require 'appscript' f = MacTypes::Alias.path(File.join(File.dirname(__FILE__), "planning.xls")) excel = Appscript.app("Microsoft Excel") excel.activate excel.open f w1 = excel.worksheets[1] 1.upto(10) do |i| 1.upto(10) do |j| cell = w1.rows[i].cells[j] print cell.value.get.to_s + " (#{cell.style_object.interior_object.pattern_color.get})" end puts "" end 

不幸的是,我只能得到单元格的值,我似乎无法find应该给我背景颜色的方法。

这是给出背景颜色的值:

 cell.interior_object.color.get 
Interesting Posts