Sha256: 4e622151f34faba780d7237add1708dba3ec964ab5810700361bc87ec6961520

Contents?: true

Size: 715 Bytes

Versions: 6

Compression:

Stored size: 715 Bytes

Contents

module Axlsx
  class RichText < SimpleTypedList
    def initialize(text = nil, options={})
      super(RichTextRun)
      add_run(text, options) unless text.nil?
      yield self if block_given?
    end

    attr_reader :cell
    
    def cell=(cell)
      @cell = cell
      each { |run| run.cell = cell }
    end
    
    def autowidth
      widtharray = [0] # Are arrays the best way of solving this problem?
      each { |run| run.autowidth(widtharray) }
      widtharray.max
    end

    def add_run(text, options={})
      self << RichTextRun.new(text, options)
    end
    
    def runs
      self
    end

    def to_xml_string(str='')
      each{ |run| run.to_xml_string(str) }
      str
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
bonio-axlsx-2.2.3 lib/axlsx/workbook/worksheet/rich_text.rb
bonio-axlsx-2.2.2 lib/axlsx/workbook/worksheet/rich_text.rb
bonio-axlsx-2.2.1 lib/axlsx/workbook/worksheet/rich_text.rb
dg-axlsx-2.1.0 lib/axlsx/workbook/worksheet/rich_text.rb
axlsx-2.1.0.pre lib/axlsx/workbook/worksheet/rich_text.rb
l_axlsx-2.0.1 lib/axlsx/workbook/worksheet/rich_text.rb