[英]Change the tab color of excel sheets using ruby
I need to change the tab color of excel sheets with a particular color...something like this using ruby scripting 我需要使用特定颜色来更改excel工作表的标签颜色...使用ruby脚本编写类似的东西
Here is an equivalent Ruby code using stdlib WIN32OLE
: 这是使用stdlib WIN32OLE
的等效Ruby代码:
require 'win32ole'
# create an instance of the Excel application object
excel = WIN32OLE.new('Excel.Application')
# make Excel visible
excel.visible = true
# open the excel from the desired path
wb = excel.workbooks.open("C:\\Users\\test.xlsx")
#iterate through each worksheet and color the tab as you want
1.upto(3).each do |i|
# getting the worksheet
wbs = wb.worksheets(i)
#color it
wbs.tab.color = 255
end
output 输出
Look documentation of Tab.Color property
and Worksheet.Tab Property
. 查看Tab.Color property
和Worksheet.Tab Property
文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.