covert me this python data to excel sheet please

138 views
Skip to first unread message

ABHI

unread,
Aug 29, 2025, 7:26:09 AM8/29/25
to openpyxl-users
import openpyxl
from openpyxl.styles import PatternFill, Font, Alignment, Border, Side
from openpyxl.utils import get_column_letter

# Create workbook
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "Team Rating"

# Headers
headers = ["Abhijin", "Amal", "Sruthy", "Sarath"]
ws.append(headers)

# Data (like your sketch)
data = [
    [1, "", "", ""],
    ["", 1, "", ""],
    ["", "", 1, ""],
    ["", "", "", 1]
]
for row in data:
    ws.append(row)

# Header style
header_fill = PatternFill(start_color="FFD966", end_color="FFD966", fill_type="solid")
header_font = Font(bold=True, color="000000")
for col_num, header in enumerate(headers, 1):
    cell = ws.cell(row=1, column=col_num)
    cell.fill = header_fill
    cell.font = header_font
    cell.alignment = Alignment(horizontal="center", vertical="center")

# Data cell style
highlight_fill = PatternFill(start_color="E2EFDA", end_color="E2EFDA", fill_type="solid")
for row in ws.iter_rows(min_row=2, max_row=5, min_col=1, max_col=4):
    for cell in row:
        cell.alignment = Alignment(horizontal="center", vertical="center")
        if cell.value == 1:
            cell.fill = highlight_fill
            cell.font = Font(bold=True)

# Borders
thin = Side(border_style="thin", color="000000")
border = Border(left=thin, right=thin, top=thin, bottom=thin)
for row in ws.iter_rows(min_row=1, max_row=5, min_col=1, max_col=4):
    for cell in row:
        cell.border = border

# Adjust width
for col in range(1, 5):
    ws.column_dimensions[get_column_letter(col)].width = 15

# Save
wb.save("Team_Rating.xlsx")
print("✅ Excel file 'Team_Rating.xlsx' created successfully!")

ephrem tamiru

unread,
Jan 10, 2026, 1:16:25 PM (6 days ago) Jan 10
to openpyxl-users
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side

wb = Workbook()
ws = wb.active
ws.title = "Payroll & Benefits BSC"

headers = ["Perspective","Objective","Initiatives","KPIs","Targets","Owner","Target Year"]
ws.append(headers)

rows = [
["Learning & Growth","Build payroll & benefits competency",
 "Annual training; Knowledge repository; Cross-functional rotation",
 "Training hours/FTE; Completion rate; Competency index",
 "40 hrs; 95%; ≥4.5/5","HR L&D / Payroll Lead","FY2026-27"],

["Learning & Growth","Strengthen HRIS & analytics",
 "HRIS upgrade; Data governance; Self-service dashboards",
 "System uptime; Data accuracy; Adoption rate",
 "≥99.5%; ≥99.9%; ≥85%","HRIS Lead","FY2026-27"],

["Internal Processes","Improve payroll accuracy & timeliness",
 "Automation; Standard SLAs; Reconciliation",
 "Error rate; Cycle time; Enrollment accuracy",
 "<0.5%; ≤2 days; ≥99%","Payroll Ops Manager","FY2026-27"],

["Customer","Reliable payroll & benefits experience",
 "Self-service portal; Employee communication",
 "Satisfaction; Adoption; FCR",
 "≥90%; ≥75%; ≥80%","Employee Experience Lead","FY2026-27"],

["Financial","Optimize payroll & benefits cost",
 "Vendor renegotiation; Automation",
 "Cost per payslip; Cost %; ROI",
 "5–10% YoY; ↓ to 2.0%; ≥150%","Finance & Vendor Lead","FY2026-27"]
]

for r in rows:
    ws.append(r)

header_fill = PatternFill("solid", fgColor="4472C4")
header_font = Font(bold=True, color="FFFFFF")
border = Border(left=Side(style="thin"), right=Side(style="thin"),
                top=Side(style="thin"), bottom=Side(style="thin"))

for col in range(1,len(headers)+1):
    c = ws.cell(row=1,column=col)
    c.fill = header_fill
    c.font = header_font
    c.alignment = Alignment(horizontal="center",vertical="center")
    c.border = border
    ws.column_dimensions[chr(64+col)].width = 32

for row in ws.iter_rows(min_row=2):
    for cell in row:
        cell.alignment = Alignment(wrap_text=True,vertical="top")
        cell.border = border

path = "/mnt/data/Payroll_Benefits_Balanced_Scorecard.xlsx"
wb.save(path)

path
Reply all
Reply to author
Forward
0 new messages