Class: Writexlsx::Package::DataBarFormat

Inherits:
ConditionalFormat show all
Defined in:
lib/write_xlsx/package/conditional_format.rb

Constant Summary

Constants included from Constants

Constants::COL_MAX, Constants::ROW_MAX, Constants::SHEETNAME_MAX, Constants::STR_MAX

Constants included from Utility::Common

Utility::Common::PERL_TRUE_VALUES

Instance Attribute Summary

Attributes inherited from ConditionalFormat

#range

Instance Method Summary collapse

Methods inherited from ConditionalFormat

#attributes, #bar_axis_color, #bar_axis_position, #bar_border_color, #bar_color, #bar_negative_color, #bar_negative_color_same, #bar_no_border, #bar_only, #criteria, #direction, factory, #format, #formula, #icon_style, #icons, #icons_only, #initialize, #max_color, #max_type, #max_value, #maximum, #mid_color, #mid_type, #mid_value, #min_color, #min_type, #min_value, #minimum, #priority, #range_param_for_conditional_formatting, #reverse_icons, #stop_if_true, #total_icons, #type, #value, #write_cf_rule_formula_tag, #write_cfvo, #write_formula_tag

Methods included from Utility::XmlPrimitives

#r_id_attributes, #write_color, #write_xml_declaration, #xml_str

Methods included from Utility::DateTime

#convert_date_time

Methods included from Utility::Dimensions

#check_dimensions, #check_dimensions_and_update_max_min_values, #store_col_max_min_values, #store_row_max_min_values

Methods included from Utility::CellReference

#row_col_notation, #substitute_cellref, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell

Methods included from Utility::Common

#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message

Constructor Details

This class inherits a constructor from Writexlsx::Package::ConditionalFormat

Instance Method Details

#write_cf_ruleObject



833
834
835
836
837
838
# File 'lib/write_xlsx/package/conditional_format.rb', line 833

def write_cf_rule
  @writer.tag_elements('cfRule', attributes) do
    write_data_bar
    write_data_bar_ext(@param) if ptrue?(@param[:is_data_bar_2010])
  end
end

#write_data_barObject

Write the <dataBar> element.



843
844
845
846
847
848
849
850
851
852
853
# File 'lib/write_xlsx/package/conditional_format.rb', line 843

def write_data_bar
  attributes = []

  attributes << ['showValue', 0] if ptrue?(bar_only)
  @writer.tag_elements('dataBar', attributes) do
    write_cfvo(min_type, min_value)
    write_cfvo(max_type, max_value)

    write_color('rgb', bar_color)
  end
end

#write_data_bar_ext(param) ⇒ Object

Write the <extLst> dataBar extension element.



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
# File 'lib/write_xlsx/package/conditional_format.rb', line 858

def write_data_bar_ext(param)
  # Create a pseudo GUID for each unique Excel 2010 data bar.
  worksheet_count = @worksheet.index + 1
  data_bar_count  = @worksheet.data_bars_2010.size + 1

  guid = sprintf(
    "{DA7ABA51-AAAA-BBBB-%04X-%012X}",
    worksheet_count, data_bar_count
  )

  # Store the 2010 data bar parameters to write the extLst elements.
  param[:guid] = guid
  @worksheet.data_bars_2010 << param

  @writer.tag_elements('extLst') do
    @worksheet.write_ext('{B025F937-C7B1-47D3-B67F-A62EFF666E3E}') do
      @writer.data_element('x14:id', guid)
    end
  end
end