Fix switch case + removed utils module
This commit is contained in:
55
write.py
Normal file
55
write.py
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
import xlsxwriter
|
||||
import tkinter as tk
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
|
||||
def write_excel(value_update):
|
||||
today = datetime.now().strftime('%d-%m-%Y_%H-%M')
|
||||
filename = f'Articoli_Modificati{today}.xlsx'
|
||||
workbook = xlsxwriter.Workbook(filename)
|
||||
worksheet = workbook.add_worksheet()
|
||||
updated_format = workbook.add_format({'bg_color': '#D9EAD3'})
|
||||
created_format = workbook.add_format({'bg_color': '#FFF2CC'})
|
||||
error_format = workbook.add_format({'bg_color': '#F4CCCC'})
|
||||
|
||||
worksheet.set_column(0, 0, 30)
|
||||
worksheet.set_column(2, 6, 30)
|
||||
|
||||
worksheet.write('A1', 'ARTICOLO')
|
||||
worksheet.write('B1', 'UM')
|
||||
worksheet.write('C1', 'CODICE A BARRE')
|
||||
worksheet.write('D1', 'LISTINO DI ACQUISTO (ID LSA)')
|
||||
worksheet.write('E1', 'LISTINO DI VENDITA 1 (ID LSV)')
|
||||
worksheet.write('F1', 'LISTINO DI VENDITA 2 (ID LSV)')
|
||||
worksheet.write('G1', 'LISTINO DI VENDITA 4 (ID LSV)')
|
||||
|
||||
for row_index, row_data in enumerate(value_update):
|
||||
|
||||
for col_index, value in enumerate(row_data):
|
||||
|
||||
if col_index == 4:
|
||||
for listino, lsv in row_data[value].items():
|
||||
if lsv[0]==0:
|
||||
worksheet.write(row_index + 1, col_index, str(lsv[1]), error_format)
|
||||
elif lsv[0]==1:
|
||||
worksheet.write(row_index + 1, col_index, str(lsv[1]), created_format)
|
||||
elif lsv[0]==2:
|
||||
worksheet.write(row_index + 1, col_index, str(lsv[1]), updated_format)
|
||||
col_index+=1
|
||||
else:
|
||||
if row_data[value][0]==0:
|
||||
worksheet.write(row_index + 1, col_index, str(row_data[value][1]), error_format)
|
||||
elif row_data[value][0]==1:
|
||||
worksheet.write(row_index + 1, col_index, str(row_data[value][1]), created_format)
|
||||
elif row_data[value][0]==2:
|
||||
worksheet.write(row_index + 1, col_index, str(row_data[value][1]), updated_format)
|
||||
|
||||
|
||||
root = tk.Tk()
|
||||
loading_label = tk.Label(root, text="")
|
||||
loading_label.pack(pady=20)
|
||||
loading_label.config(text="Aggiornamento in corso... Attendere...")
|
||||
|
||||
workbook.close()
|
||||
Reference in New Issue
Block a user