Class: Axlsx::TwoCellAnchor

Inherits:
Object
  • Object
show all
Includes:
OptionsParser
Defined in:
lib/axlsx/drawing/two_cell_anchor.rb

Overview

Note:

The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.

This class details the anchor points for drawings.

See Also:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from OptionsParser

#parse_options

Constructor Details

- (TwoCellAnchor) initialize(drawing, options = {})

Creates a new TwoCellAnchor object c.start_at 5, 9

Options Hash (options):

  • :start_at (Array)

    the col, row to start at THIS IS DOCUMENTED BUT NOT IMPLEMENTED HERE!

  • :end_at (Array)

    the col, row to end at



35
36
37
38
39
40
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 35

def initialize(drawing, options={})
  @drawing = drawing
  drawing.anchors << self
  @from, @to =  Marker.new, Marker.new(:col => 5, :row=>10)
  parse_options options
end

Instance Attribute Details

- (Drawing) drawing (readonly)

The drawing that holds this anchor



28
29
30
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 28

def drawing
  @drawing
end

- (Marker) from (readonly)

A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively



12
13
14
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 12

def from
  @from
end

- (Pic, GraphicFrame) object (readonly)

The object this anchor hosts



24
25
26
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 24

def object
  @object
end

- (Marker) to (readonly)

A marker that returns the to cell anchor. The default to column and row are 5 and 10 respectively



15
16
17
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 15

def to
  @to
end

Instance Method Details

- (Chart) add_chart(chart_type, options)

Creates a graphic frame and chart object associated with this anchor



60
61
62
63
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 60

def add_chart(chart_type, options)
  @object = GraphicFrame.new(self, chart_type, options)
  @object.chart
end

- (Object) add_pic(options = {})

Creates an image associated with this anchor.



66
67
68
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 66

def add_pic(options={})
  @object = Pic.new(self, options)
end

- (Object) end_at(x, y = nil)

Note:

the recommended way to set the to position for graphical

sets the col, row attributes for the to marker objects is directly thru the object

See Also:

  • Char#end_at


54
55
56
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 54

def end_at(x, y=nil)
  to.coord x, y
end

- (Integer) index

The index of this anchor in the drawing



72
73
74
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 72

def index
  @drawing.anchors.index(self)
end

- (Object) start_at(x, y = nil)

Note:

The recommended way to set the start position for graphical

sets the col, row attributes for the from marker. objects is directly thru the object.

See Also:



46
47
48
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 46

def start_at(x, y=nil)
  from.coord x, y
end

- (String) to_xml_string(str = '')

Serializes the object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/axlsx/drawing/two_cell_anchor.rb', line 79

def to_xml_string(str = '')
  str << '<xdr:twoCellAnchor>'
  str << '<xdr:from>'
  from.to_xml_string str
  str << '</xdr:from>'
  str << '<xdr:to>'
  to.to_xml_string str
  str << '</xdr:to>'
  object.to_xml_string(str)
  str << '<xdr:clientData/>'
  str << '</xdr:twoCellAnchor>'
end