Insert default value to cell if value is blank/conditional 格式化单元格,如果值为空
Insert default value to cell if value is blank/conditional format cell if value is blank
我的数据框可以包含 None
某些通常为百分比格式的值。
我想使用条件格式来查找插入值的位置 None
并将其更新为特定的字符串值,例如 '0.00%'
.
这可能吗,或者我应该使用内部 python 条件,例如 if val is None: val = '0.00%'
Is this possible, or should I instead be using internal python conditionals, eg if val is None: val = '0.00%'
不,这是不可能的,是的,您应该在写入数据之前或写入数据时清理数据。
具体来说,通过 xlsxwriter 的条件格式是不可能的。条件格式用于在文档中应用 Formats to cells based on certain criteria. Line 1 of the working with conditional formatting。
但是,如果您不想以编程方式执行此操作,则可以使用 xlsxwriter 的 write_formula 函数来实现。例如:
worksheet.write_formula(row, col, '=IF(ISBLANK(A1), "0.00%", A1)')
我的 A1 符号被你的替换了。
我的数据框可以包含 None
某些通常为百分比格式的值。
我想使用条件格式来查找插入值的位置 None
并将其更新为特定的字符串值,例如 '0.00%'
.
这可能吗,或者我应该使用内部 python 条件,例如 if val is None: val = '0.00%'
Is this possible, or should I instead be using internal python conditionals, eg if val is None: val = '0.00%'
不,这是不可能的,是的,您应该在写入数据之前或写入数据时清理数据。
具体来说,通过 xlsxwriter 的条件格式是不可能的。条件格式用于在文档中应用 Formats to cells based on certain criteria. Line 1 of the working with conditional formatting。
但是,如果您不想以编程方式执行此操作,则可以使用 xlsxwriter 的 write_formula 函数来实现。例如:
worksheet.write_formula(row, col, '=IF(ISBLANK(A1), "0.00%", A1)')
我的 A1 符号被你的替换了。