def add_style(options={})
      # Default to :xf
      options[:type] ||= :xf
      raise ArgumentError, "Type must be one of [:xf, :dxf]" unless [:xf, :dxf].include?(options[:type] )

      fill = parse_fill_options options
      font = parse_font_options options
      numFmt = parse_num_fmt_options options
      border = parse_border_options options
      alignment = parse_alignment_options options
      protection = parse_protection_options options

      case options[:type]
      when :dxf
        style = Dxf.new :fill => fill, :font => font, :numFmt => numFmt, :border => border, :alignment => alignment, :protection => protection
      else
        style = Xf.new :fillId=>fill || 0, :fontId=>font || 0, :numFmtId=>numFmt || 0, :borderId=>border || 0, :alignment => alignment, :protection => protection, :applyFill=>!fill.nil?, :applyFont=>!font.nil?, :applyNumberFormat =>!numFmt.nil?, :applyBorder=>!border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
      end

      options[:type] == :xf ? cellXfs << style : dxfs << style
    end
def add_style(options={})
      # Default to :xf
      options[:type] ||= :xf
      raise ArgumentError, "Type must be one of [:xf, :dxf]" unless [:xf, :dxf].include?(options[:type] )

      fill = parse_fill_options options
      font = parse_font_options options
      numFmt = parse_num_fmt_options options
      border = parse_border_options options
      alignment = parse_alignment_options options
      protection = parse_protection_options options

      case options[:type]
      when :dxf
        style = Dxf.new :fill => fill, :font => font, :numFmt => numFmt, :border => border, :alignment => alignment, :protection => protection
      else
        style = Xf.new :fillId=>fill || 0, :fontId=>font || 0, :numFmtId=>numFmt || 0, :borderId=>border || 0, :alignment => alignment, :protection => protection, :applyFill=>!fill.nil?, :applyFont=>!font.nil?, :applyNumberFormat =>!numFmt.nil?, :applyBorder=>!border.nil?, :applyAlignment => !alignment.nil?, :applyProtection => !protection.nil?
      end

      options[:type] == :xf ? cellXfs << style : dxfs << style
    end
Creates a new Styles object and prepopulates it with the requires objects to generate a valid package style part.
 Drastically simplifies style creation and management.
 @return [Integer]
 @option options [String] fg_color The text color
 @option options [Integer] sz The text size
 @option options [Boolean] b Indicates if the text should be bold
 @option options [Boolean] i Indicates if the text should be italicised
 @option options [Boolean] u Indicates if the text should be underlined
 @option options [Boolean] strike Indicates if the text should be rendered with a strikethrough
 @option options [Boolean] shadow Indicates if the text should be rendered with a shadow
 @option options [Integer] charset The character set to use.
 @option options [Integer] family The font family to use.
 @option options [String] font_name The name of the font to use
 @option options [Integer] num_fmt The number format to apply
 @option options [String] format_code The formatting to apply.
 @option options [Integer|Hash] border The border style to use.
   borders support style, color and edges options @see parse_border_options
 @option options [String] bg_color The background color to apply to the cell
 @option options [Boolean] hidden Indicates if the cell should be hidden
 @option options [Boolean] locked Indicates if the cell should be locked
 @option options [Symbol] type What type of style is this. Options are [:dxf, :xf]. :xf is default
 @option options [Hash] alignment A hash defining any of the attributes used in CellAlignment
 @see CellAlignment

 @example You Got Style
   require "rubygems" # if that is your preferred way to manage gems!
   require "axlsx"

   p = Axlsx::Package.new
   ws = p.workbook.add_worksheet

   # black text on a white background at 14pt with thin borders!
   title = ws.styles.add_style(:bg_color => "FFFF0000", :fg_color=>"#FF000000", :sz=>14,  :border=> {:style => :thin, :color => "FFFF0000"}

   ws.add_row ["Least Popular Pets"]
   ws.add_row ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"], :style=>title
   ws.add_row ["Votes", 6, 4, 1], :style=>Axlsx::STYLE_THIN_BORDER
   f = File.open('example_you_got_style.xlsx', 'w')
   p.serialize(f)

 @example Styling specifically
   # an example of applying specific styles to specific cells
   require "rubygems" # if that is your preferred way to manage gems!
   require "axlsx"

   p = Axlsx::Package.new
   ws = p.workbook.add_worksheet

   # define your styles
   title = ws.styles.add_style(:bg_color => "FFFF0000",
                              :fg_color=>"#FF000000",
                              :border=>Axlsx::STYLE_THIN_BORDER,
                              :alignment=>{:horizontal => :center})

   date_time = ws.styles.add_style(:num_fmt => Axlsx::NUM_FMT_YYYYMMDDHHMMSS,
                                  :border=>Axlsx::STYLE_THIN_BORDER)

   percent = ws.styles.add_style(:num_fmt => Axlsx::NUM_FMT_PERCENT,
                                :border=>Axlsx::STYLE_THIN_BORDER)

   currency = ws.styles.add_style(:format_code=>"¥#,##0;[Red]¥-#,##0",
                                 :border=>Axlsx::STYLE_THIN_BORDER)

   # build your rows
   ws.add_row ["Generated At:", Time.now], :styles=>[nil, date_time]
   ws.add_row ["Previous Year Quarterly Profits (JPY)"], :style=>title
   ws.add_row ["Quarter", "Profit", "% of Total"], :style=>title
   ws.add_row ["Q1", 4000, 40], :style=>[title, currency, percent]
   ws.add_row ["Q2", 3000, 30], :style=>[title, currency, percent]
   ws.add_row ["Q3", 1000, 10], :style=>[title, currency, percent]
   ws.add_row ["Q4", 2000, 20], :style=>[title, currency, percent]
   f = File.open('example_you_got_style.xlsx', 'w')
   p.serialize(f)

 @example Differential styling
   # Differential styles apply on top of cell styles. Used in Conditional Formatting. Must specify :type => :dxf, and you can't use :num_fmt.
   require "rubygems" # if that is your preferred way to manage gems!
   require "axlsx"

   p = Axlsx::Package.new
   wb = p.workbook
   ws = wb.add_worksheet

   # define your styles
   profitable = wb.styles.add_style(:bg_color => "FFFF0000",
                              :fg_color=>"#FF000000",
                              :type => :dxf)

   ws.add_row ["Genreated At:", Time.now], :styles=>[nil, date_time]
   ws.add_row ["Previous Year Quarterly Profits (JPY)"], :style=>title
   ws.add_row ["Quarter", "Profit", "% of Total"], :style=>title
   ws.add_row ["Q1", 4000, 40], :style=>[title, currency, percent]
   ws.add_row ["Q2", 3000, 30], :style=>[title, currency, percent]
   ws.add_row ["Q3", 1000, 10], :style=>[title, currency, percent]
   ws.add_row ["Q4", 2000, 20], :style=>[title, currency, percent]

   ws.add_conditional_formatting("A1:A7", { :type => :cellIs, :operator => :greaterThan, :formula => "2000", :dxfId => profitable, :priority => 1 })
   f = File.open('example_differential_styling', 'w')
   p.serialize(f)