🔧 Revising xlsx file
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
import openpyxl
# Load the workbook and select the active worksheet
workbook = openpyxl.load_workbook('Lab_3.xlsx')
sheet = workbook.active
# Function to get the RGB color of a cell fill
def get_rgb_color(cell):
if cell.fill.start_color.index == '00000000': # cell.fill is a complex object
return None
return cell.fill.start_color.rgb # so we just need to access the start_color attribute
# Iterate through the rows in the worksheet
count = 0
reference_color = None
for row in sheet.iter_rows(min_row=1, min_col=1, max_col=3):
count += 1
cell = row[1] # Access the second column in the row
if count == 1:
reference_color = get_rgb_color(cell) # Get the fill color of the reference cell
continue
cell_color = get_rgb_color(cell)
if cell_color == reference_color:
sheet.cell(row=count, column=4, value=1) # Set value to 1 in the new column (D)
else:
sheet.cell(row=count, column=4, value=0) # Set value to 0 in the new column (D)
# Save the workbook
workbook.save('Lab_3_updated.xlsx')
🔧 Revising xlsx file
📈 56.1 Punkte
🔧 Programmierung
🔧 Revising MERN for blockchain.
📈 28.58 Punkte
🔧 Programmierung
🕵️ http://www.sib.gov.ar/archivos/payitaht.xlsx
📈 23.91 Punkte
🕵️ Hacking
🪟 How to Open .XLSX Files: 4 Ways to do it
📈 23.91 Punkte
🪟 Windows Tipps
🔧 How to Merge Excel XLSX Files in Java
📈 23.91 Punkte
🔧 Programmierung