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.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/axlsx/stylesheet/styles.rb', line 331 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 |