Added option to disable the red color for empty cells.
Applies only when using colors for column types. Is for HTML and XLSX
This commit is contained in:
parent
77bf713b26
commit
78cfcd16c0
|
|
@ -98,6 +98,7 @@ def content_table(html, groups, headings, head_names, cfg, link_datasheet, link_
|
|||
|
||||
html.write(" <tbody>\n")
|
||||
rc = 0
|
||||
hl_empty = cfg.html.highlight_empty
|
||||
for i, group in enumerate(groups):
|
||||
if (cfg.ignore_dnf and not group.is_fitted()) != dnf:
|
||||
continue
|
||||
|
|
@ -114,7 +115,7 @@ def content_table(html, groups, headings, head_names, cfg, link_datasheet, link_
|
|||
r = '<a href="' + datasheet + '">' + r + '</a>'
|
||||
if col_colors:
|
||||
# Empty cell?
|
||||
if len(r) == 0 or r.strip() == "~":
|
||||
if hl_empty and (len(r) == 0 or r.strip() == "~"):
|
||||
cl = 'empty'
|
||||
else:
|
||||
cl = cell_class(headings[n])
|
||||
|
|
@ -241,7 +242,8 @@ def write_html(filename, groups, headings, head_names, cfg):
|
|||
html.write('<tr><td class="td-kicad0">KiCad Fields (default)</td></tr>\n')
|
||||
html.write('<tr><td class="td-gen0">Generated Fields</td></tr>\n')
|
||||
html.write('<tr><td class="td-user0">User Fields</td></tr>\n')
|
||||
html.write('<tr><td class="td-empty0">Empty Fields</td></tr>\n')
|
||||
if hl_empty:
|
||||
html.write('<tr><td class="td-empty0">Empty Fields</td></tr>\n')
|
||||
html.write('</table>\n')
|
||||
|
||||
html.write("</body></html>")
|
||||
|
|
|
|||
|
|
@ -170,13 +170,14 @@ def insert_logo(worksheet, image_data):
|
|||
return 0
|
||||
|
||||
|
||||
def create_color_ref(workbook, col_colors, fmt_cols):
|
||||
def create_color_ref(workbook, col_colors, hl_empty, fmt_cols):
|
||||
if col_colors:
|
||||
worksheet = workbook.add_worksheet('Colors')
|
||||
worksheet.write_string(0, 0, 'KiCad Fields (default)', fmt_cols[0][0])
|
||||
worksheet.write_string(1, 0, 'Generated Fields', fmt_cols[1][0])
|
||||
worksheet.write_string(2, 0, 'User Fields', fmt_cols[2][0])
|
||||
worksheet.write_string(3, 0, 'Empty Fields', fmt_cols[3][0])
|
||||
if hl_empty:
|
||||
worksheet.write_string(3, 0, 'Empty Fields', fmt_cols[3][0])
|
||||
worksheet.set_column(0, 0, 50)
|
||||
|
||||
|
||||
|
|
@ -252,6 +253,7 @@ def write_xlsx(filename, groups, col_fields, head_names, cfg):
|
|||
|
||||
# Body
|
||||
row_count += 1
|
||||
hl_empty = cfg.xlsx.highlight_empty
|
||||
for i, group in enumerate(groups):
|
||||
if (cfg.ignore_dnf and not group.is_fitted()) != dnf:
|
||||
continue
|
||||
|
|
@ -263,7 +265,7 @@ def write_xlsx(filename, groups, col_fields, head_names, cfg):
|
|||
# Fill the row
|
||||
for i in range(len(row)):
|
||||
cell = row[i]
|
||||
if len(cell) == 0 or cell.strip() == "~":
|
||||
if hl_empty and (len(cell) == 0 or cell.strip() == "~"):
|
||||
fmt = col_fmt[-1][row_count % 2]
|
||||
else:
|
||||
fmt = col_fmt[i][row_count % 2]
|
||||
|
|
@ -327,7 +329,7 @@ def write_xlsx(filename, groups, col_fields, head_names, cfg):
|
|||
worksheet.set_landscape()
|
||||
|
||||
# Add a sheet for the color references
|
||||
create_color_ref(workbook, cfg.xlsx.col_colors, fmt_cols)
|
||||
create_color_ref(workbook, cfg.xlsx.col_colors, hl_empty, fmt_cols)
|
||||
workbook.close()
|
||||
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ class BoMHTML(Optionable):
|
|||
""" Hide project information """
|
||||
self.hide_stats_info = False
|
||||
""" Hide statistics information """
|
||||
self.highlight_empty = True
|
||||
""" Use a color for empty cells. Applies only when `col_colors` is `true` """
|
||||
self.logo = Optionable
|
||||
""" [string|boolean] PNG file to use as logo, use false to remove """
|
||||
self.style = 'modern-blue'
|
||||
|
|
@ -143,6 +145,8 @@ class BoMXLSX(Optionable):
|
|||
""" Hide project information """
|
||||
self.hide_stats_info = False
|
||||
""" Hide statistics information """
|
||||
self.highlight_empty = True
|
||||
""" Use a color for empty cells. Applies only when `col_colors` is `true` """
|
||||
self.logo = Optionable
|
||||
""" [string|boolean] PNG file to use as logo, use false to remove """
|
||||
self.max_col_width = 60
|
||||
|
|
|
|||
Loading…
Reference in New Issue