create excel for product
This commit is contained in:
@@ -19,6 +19,9 @@ ORANGE_CELL = PatternFill(start_color="FFC000", fill_type="solid")
|
||||
BLUE_CELL = PatternFill(start_color="538DD5", fill_type="solid")
|
||||
LIGHT_GREEN_CELL = PatternFill(start_color="92D050", fill_type="solid")
|
||||
VERY_LIGHT_GREEN_CELL = PatternFill(start_color="5AFC56", fill_type="solid")
|
||||
GRAY_CELL = PatternFill(start_color="B0B0B0", fill_type="solid")
|
||||
CREAM_CELL = PatternFill(start_color="D8AA72", fill_type="solid")
|
||||
LIGHT_CREAM_CELL = PatternFill(start_color="E8C6A0", fill_type="solid")
|
||||
|
||||
|
||||
def shamsi_date(date, in_value=None):
|
||||
@@ -55,7 +58,7 @@ def create_header(worksheet, list, num, row, height=None, width=None, color=None
|
||||
else:
|
||||
cell.fill = PatternFill(start_color=color, fill_type="solid")
|
||||
else:
|
||||
cell.fill = blue_fill
|
||||
cell.fill = CREAM_CELL
|
||||
if text_color is not None:
|
||||
cell.font = Font(size=9, bold=True, color=text_color)
|
||||
else:
|
||||
@@ -79,8 +82,8 @@ def create_header_freez(worksheet, list, num, row, header_row, height=None, widt
|
||||
col_letter = get_column_letter(col_num)
|
||||
cell = worksheet.cell(row=row, column=col_num, value=option)
|
||||
cell.alignment = Alignment_CELL
|
||||
cell.fill = blue_fill
|
||||
cell.font = Font(size=10, bold=True, color='D9FFFFFF')
|
||||
cell.fill = LIGHT_CREAM_CELL
|
||||
cell.font = Font(size=10, bold=True, color='404040')
|
||||
|
||||
if height is not None:
|
||||
worksheet.row_dimensions[row].height = height
|
||||
@@ -123,7 +126,8 @@ def create_value(worksheet, list, l, num, border_style=None, m=None, height=None
|
||||
'blue': BLUE_CELL,
|
||||
'red': RED_CELL,
|
||||
'light_green': LIGHT_GREEN_CELL,
|
||||
'very_light_green': VERY_LIGHT_GREEN_CELL
|
||||
'very_light_green': VERY_LIGHT_GREEN_CELL,
|
||||
'gray': GRAY_CELL
|
||||
}
|
||||
|
||||
for item in range(len(list)):
|
||||
@@ -147,7 +151,7 @@ def create_value(worksheet, list, l, num, border_style=None, m=None, height=None
|
||||
cell.font = Font(size=10, bold=True)
|
||||
|
||||
if m is not None and m % 2 != 0:
|
||||
cell.fill = PatternFill(start_color="D6F6FE", fill_type="solid")
|
||||
cell.fill = PatternFill(start_color="FAF0E7", fill_type="solid")
|
||||
|
||||
if height is not None:
|
||||
worksheet.row_dimensions[l + 1].height = height
|
||||
@@ -291,4 +295,11 @@ def to_locale_str(a):
|
||||
|
||||
|
||||
def convert_str_to_date(string):
|
||||
return datetime.strptime(str(string), '%Y-%m-%d').date()
|
||||
string = str(string).strip()
|
||||
try:
|
||||
return datetime.strptime(string, '%Y-%m-%dT%H:%M:%S.%fZ').date()
|
||||
except ValueError:
|
||||
try:
|
||||
return datetime.strptime(string, '%Y-%m-%d').date()
|
||||
except ValueError:
|
||||
return None
|
||||
Reference in New Issue
Block a user