Zavrsni informatika excel
Pythonunknown
plain_text
10 months ago
1.7 kB
19
Indexable
from openpyxl import Workbook
from openpyxl.styles import numbers
# Kreiranje Excel fajla sa tačnim vrijednostima (bez formula)
wb = Workbook()
ws = wb.active
ws.title = "Zavrsni ispit"
# -----------------
# Zaglavlje
# -----------------
headers = ["Mjesec", "Radnja", "Prihodi", "Rashodi", "Razlika", "Porez", "Taksa", "Popust", "Dug", "PDV", "Račun"]
ws.append(headers)
# -----------------
# Tačne vrijednosti po zadatku
# -----------------
data = [
["Januar", "Adidas", 18500.00, 12600.00, 5900.00, 1180.00, 590.00, 500.00, 200.00, 1180.00, 8550.00],
["Februar", "Reebok", 20700.00, 13500.00, 7200.00, 1440.00, 720.00, 700.00, 300.00, 1440.00, 10400.00],
["Mart", "Nike", 19200.00, 12200.00, 7000.00, 1400.00, 700.00, 600.00, 250.00, 1400.00, 10150.00],
["April", "Adidas", 23700.00, 12950.00, 10750.00, 2150.00, 1075.00, 800.00, 400.00, 2150.00, 15425.00],
]
for row in data:
ws.append(row)
# -----------------
# Srednja vrijednost i suma (red 16 i 17)
# -----------------
ws["A16"] = "Srednja vrijednost"
ws["A17"] = "Ukupna vrijednost"
for col in range(3, 12): # od C do K
values = [r[col-1] for r in data]
avg_val = sum(values) / len(values)
sum_val = sum(values)
ws.cell(row=16, column=col, value=round(avg_val, 2))
ws.cell(row=17, column=col, value=round(sum_val, 2))
# -----------------
# Formatiranje u eurima
# -----------------
currency_fmt = numbers.FORMAT_CURRENCY_EUR_SIMPLE
for row in range(2, 18):
for col in range(3, 12):
ws.cell(row=row, column=col).number_format = currency_fmt
# -----------------
# Snimanje fajla
# -----------------
file_path = "zavrsni_informatika_rezultati.xlsx"
wb.save(file_path)
print(f"Fajl sacuvan kao {file_path}")Editor is loading...
Leave a Comment