コード例 #1
0
 def test_conditional_formatting_addCellIs_greaterThan(self):
     cf = ConditionalFormatting()
     redFill = Fill()
     redFill.start_color.index = 'FFEE1111'
     redFill.end_color.index = 'FFEE1111'
     redFill.fill_type = Fill.FILL_SOLID
     cf.addCellIs('U10:U18', 'greaterThan', ['U$7'], True, self.workbook,
                                                     None, None, redFill)
     cf.addCellIs('V10:V18', '>', ['V$7'], True, self.workbook,
                                                     None, None, redFill)
     rules = cf.cf_rules
     assert 'U10:U18' in rules
     assert len(cf.cf_rules['U10:U18']) == 1
     assert rules['U10:U18'][0]['priority'] == 1
     assert rules['U10:U18'][0]['type'] == 'cellIs'
     assert rules['U10:U18'][0]['dxfId'] == 0
     assert rules['U10:U18'][0]['operator'] == 'greaterThan'
     assert rules['U10:U18'][0]['formula'][0] == 'U$7'
     assert rules['U10:U18'][0]['stopIfTrue'] == '1'
     assert 'V10:V18' in rules
     assert len(cf.cf_rules['V10:V18']) == 1
     assert rules['V10:V18'][0]['priority'] == 2
     assert rules['V10:V18'][0]['type'] == 'cellIs'
     assert rules['V10:V18'][0]['dxfId'] == 1
     assert rules['V10:V18'][0]['operator'] == 'greaterThan'
     assert rules['V10:V18'][0]['formula'][0] == 'V$7'
     assert rules['V10:V18'][0]['stopIfTrue'] == '1'
コード例 #2
0
 def test_conditional_formatting_add2ColorScale(self):
     cf = ConditionalFormatting()
     cf.add2ColorScale('A1:A10', 'min', None, 'FFAA0000', 'max', None, 'FF00AA00')
     rules = cf.cf_rules
     assert 'A1:A10' in rules
     assert len(cf.cf_rules['A1:A10']) == 1
     assert rules['A1:A10'][0]['priority'] == 1
     assert rules['A1:A10'][0]['type'] == 'colorScale'
     assert rules['A1:A10'][0]['colorScale']['cfvo'][0]['type'] == 'min'
     assert rules['A1:A10'][0]['colorScale']['cfvo'][1]['type'] == 'max'
コード例 #3
0
 def test_conditional_formatting_add3ColorScale(self):
     cf = ConditionalFormatting()
     cf.add3ColorScale('B1:B10', 'percentile', 10, 'FFAA0000', 'percentile', 50,
                                                          'FF0000AA', 'percentile', 90, 'FF00AA00')
     rules = cf.cf_rules
     assert 'B1:B10' in rules
     assert len(cf.cf_rules['B1:B10']) == 1
     assert rules['B1:B10'][0]['priority'] == 1
     assert rules['B1:B10'][0]['type'] == 'colorScale'
     assert rules['B1:B10'][0]['colorScale']['cfvo'][0]['type'] == 'percentile'
     assert rules['B1:B10'][0]['colorScale']['cfvo'][0]['val'] == '10'
     assert rules['B1:B10'][0]['colorScale']['cfvo'][1]['type'] == 'percentile'
     assert rules['B1:B10'][0]['colorScale']['cfvo'][1]['val'] == '50'
     assert rules['B1:B10'][0]['colorScale']['cfvo'][2]['type'] == 'percentile'
     assert rules['B1:B10'][0]['colorScale']['cfvo'][2]['val'] == '90'
コード例 #4
0
 def test_conditional_formatting_addDxfStyle(self):
     cf = ConditionalFormatting()
     fill = Fill()
     fill.start_color.index = 'FFEE1111'
     fill.end_color.index = 'FFEE1111'
     fill.fill_type = Fill.FILL_SOLID
     font = Font()
     font.name = 'Arial'
     font.size = 12
     font.bold = True
     font.underline = Font.UNDERLINE_SINGLE
     borders = Borders()
     borders.top.border_style = Border.BORDER_THIN
     borders.top.color.index = Color.DARKYELLOW
     borders.bottom.border_style = Border.BORDER_THIN
     borders.bottom.color.index = Color.BLACK
     dxfId = cf.addDxfStyle(self.workbook, font, borders, fill)
     assert dxfId == 0
     dxfId = cf.addDxfStyle(self.workbook, None, None, fill)
     assert dxfId == 1
     assert len(self.workbook.style_properties['dxf_list']) == 2