使用ruby更改Excel表单的选项卡颜色
我需要用特定的颜色来改变excel表格的选项卡颜色…像这样使用ruby脚本
这是一个等价的使用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
产量
查看Tab.Color property
和Worksheet.Tab Property
文档。