class Docxi::Word::Contents::Table::TableRow::TableCell

Attributes

content[RW]
options[RW]

Public Class Methods

new(options={}) { |self| ... } click to toggle source
# File lib/docxi/word/contents/table.rb, line 110
def initialize(options={})
  @options = options
  @content = []

  if block_given?
    yield self
  else

  end
end

Public Instance Methods

image(image, options={}) click to toggle source
# File lib/docxi/word/contents/table.rb, line 167
def image(image, options={})
  img = Image.new(image, options)
  @content << img
  img
end
p(options={}, &block) click to toggle source
# File lib/docxi/word/contents/table.rb, line 179
def p(options={}, &block)
  element = Docxi::Word::Contents::Paragraph.new(options, &block)
  @content << element
  element
end
page_numbers() click to toggle source
# File lib/docxi/word/contents/table.rb, line 173
def page_numbers
  numbers = PageNumbers.new
  @content << numbers
  numbers
end
render(xml) click to toggle source
# File lib/docxi/word/contents/table.rb, line 121
def render(xml)
  if options[:fill].blank?
    options[:fill] = 'FFFFFF'
  end
  xml['w'].tc do
    xml['w'].tcPr do
      xml['w'].tcW( 'w:w' => ( options[:width].to_i * 14.92 ).to_i, 'w:type' => "dxa" ) if options[:width]
      xml['w'].shd( 'w:val' => "clear", 'w:color' => "auto", 'w:fill' => options[:fill] ) if options[:fill]
      if options[:borders]
        xml['w'].tcBorders do
          options[:borders].each do |k, v|
            if v.nil?
              xml['w'].send(k, 'w:val' => "nil" )
            else
              xml['w'].send(k, 'w:val' => "single", 'w:sz' => v, 'w:space' => "0", 'w:color' => "auto" )
            end
          end
        end
      end
      if options[:merged]
        xml['w'].vMerge
      else
        xml['w'].vAlign( 'w:val' => options[:valign] ) if options[:valign]
        xml['w'].gridSpan( 'w:val' => options[:colspan] ) if options[:colspan]
        xml['w'].vMerge( 'w:val' => "restart" ) if options[:rowspan]
      end
    end
    if options[:merged]
      xml['w'].p
    else
      @content.each do |element|
        element.render(xml)
      end
    end
  end
end
text(text, options={}) click to toggle source
# File lib/docxi/word/contents/table.rb, line 158
def text(text, options={})
  options = @options.merge(options)
  element = Docxi::Word::Contents::Paragraph.new(options) do |p|
    p.text(text)
  end
  @content << element
  element
end