Product summary tab is working. Added total sums to bottom. Started working on coloring the total due in Summary tab

This commit is contained in:
Dan Dembinski
2019-06-27 16:50:28 -04:00
parent 988159af7e
commit f58ccd9896
2 changed files with 99 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
from openpyxl.styles import Font
from openpyxl.styles import PatternFill
from openpyxl.styles import numbers
bold = Font(bold=True)
@@ -18,7 +19,8 @@ def Write_Report(y, columnFormat, SSheader, sheet):
results.append(asdf)
count = count + 1
count = 0
sheet.append(results)
if results[0] != "":
sheet.append(results)
results = []
@@ -51,41 +53,82 @@ def Format_Report(sheet, SSheader, columnFormat):
#Sets any currency related fields to the correct format. Note that this is currently only checking the headers from the config file. Anything added after the headers are loaded will cause issues. Hence the or statement in the if.
#I'm working on a better way to handle this
count = 0
rowcount = 2
rowcount = 1
for column in SSheader:
check = columnFormat[SSheader[count]]
if check == "Currency" or sheet['H1'].value == "Balance Due":
for row in sheet.rows:
sheet.cell(column=count+1, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
if rowcount != 1:
sheet.cell(column=count+1, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
# if rowcount < sheet.max_row:
rowcount += 1
count += 1
rowcount = 2
rowcount = 1
def Save_Report(wb, sheet, sheet2, sheet3, SSheader, columnFormat):
# adds total fields at bottom of report
summarylength = sheet.max_row
itemlength = sheet2.max_row
productlength = sheet3.max_row
lightGreen = Font(color='006400')
darkGreen = PatternFill(bgColor="228B22", fill_type="solid")
sheet.cell(column = 5, row=summarylength+1, value="=SUM(E2:E"+str(summarylength)+")")
sheet.cell(column = 6, row=summarylength+1, value="=SUM(F2:F"+str(summarylength)+")")
sheet.cell(column = 7, row=summarylength+1, value="=SUM(G2:G"+str(summarylength)+")")
sheet.cell(column = 8, row=summarylength+1, value="=SUM(H2:H"+str(summarylength)+")")
# thisCell = str(summarylength+1)
# sheet[thisCell].Font = lightGreen
# sheet[thisCell].PatternFill = darkGreen
sheet2.cell(column=7, row=itemlength + 1, value="=SUM(G2:G" + str(itemlength)+")")
sheet2.cell(column=8, row=itemlength + 1, value="=SUM(H2:H" + str(itemlength)+")")
# Format_Report misses this one. Whoops
sheet2.cell(column=8, row=itemlength + 1).number_format = '$#,##0.00_);($#,##0.00)'
sheet3.cell(column=2, row=productlength + 1, value="=SUM(B2:B" + str(productlength)+")")
sheet3.cell(column=3, row=productlength + 1, value="=SUM(C2:C" + str(productlength)+")")
def Save_Report(wb, sheet, sheet2, SSheader, columnFormat):
count = 0
rowcount = 2
#Formats a few of the hardcoded currency fields in the Order Summary Tab
#Formats a few of the hardcoded currency fields
count = 0
rowcount = 2
rowcount = 1
for column in SSheader:
check = columnFormat[SSheader[count]]
for row in sheet.rows:
sheet.cell(column=5, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
sheet.cell(column=6, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
sheet.cell(column=7, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
rowcount += 1
if rowcount != 1:
# print("max", sheet.max_row)
# print("count", count)
sheet.cell(column=5, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
sheet.cell(column=6, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
sheet.cell(column=7, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)'
if rowcount < sheet.max_row:
rowcount += 1
count += 1
rowcount = 2
count = 0
count = 1
rowcount = 2
#Makes the header columns Bold
for row in sheet3.rows:
if count != 1:
sheet3.cell(column=3, row=count).number_format = '$#,##0.00_);($#,##0.00)'
count += 1
#Makes the header rows Bold
for cell in sheet["1:1"]:
cell.font = bold
for cell in sheet2["1:1"]:
cell.font = bold
for cell in sheet3["1:1"]:
cell.font = bold
# print("Enter a filename for the report: ")
# filename = input()