/ / Ändern Sie die Registerkarte Farbe der Excel-Blätter mit Ruby - Ruby, Windows, Excel

Ändern Sie die Registerkarte Farbe von Excel-Blättern mit Ruby - Ruby, Windows, Excel

Ich muss die Tab-Farbe von Excel-Blättern mit einer bestimmten Farbe ändern ... so etwas wie Ruby-ScriptingBildbeschreibung hier eingeben

Antworten:

3 für die Antwort № 1

Hier ist ein äquivalenter Ruby-Code mit stdlib WIN32OLE :

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

Ausgabe

Registerkarte Farbe

Siehe Dokumentation von Tab.Color property und Worksheet.Tab Property.