Method: Axlsx::Styles#parse_num_fmt_options
- Defined in:
- lib/axlsx/stylesheet/styles.rb
#parse_num_fmt_options(options = {}) ⇒ NumFmt|Integer
Parses Style#add_style options for number formatting. noop if neither :format_code or :num_format options are set.
468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/axlsx/stylesheet/styles.rb', line 468 def ( = {}) return if (.keys & [:format_code, :num_fmt]).empty? # When the user provides format_code - we always need to create a new numFmt object # When the type is :dxf we always need to create a new numFmt object if [:format_code] || [:type] == :dxf # If this is a standard xf we pull from numFmts the highest current and increment for num_fmt [:num_fmt] ||= (@numFmts.map { |num_fmt| num_fmt.numFmtId }.max + 1) if [:type] != :dxf numFmt = NumFmt.new(:numFmtId => [:num_fmt] || 0, :formatCode => [:format_code].to_s) [:type] == :dxf ? numFmt : (numFmts << numFmt; numFmt.numFmtId) else [:num_fmt] end end |