Class: Writexlsx::Drawings
- Inherits:
-
Object
- Object
- Writexlsx::Drawings
- Includes:
- Utility::XmlPrimitives
- Defined in:
- lib/write_xlsx/drawing.rb
Instance Attribute Summary collapse
-
#embedded ⇒ Object
writeonly
Sets the attribute embedded.
-
#orientation ⇒ Object
writeonly
Sets the attribute orientation.
Instance Method Summary collapse
-
#add_drawing_object(drawing) ⇒ Object
Add a chart, image or shape sub object to the drawing.
-
#assemble_xml_file ⇒ Object
Assemble and write the XML file.
-
#initialize ⇒ Drawings
constructor
A new instance of Drawings.
- #set_xml_writer(filename) ⇒ Object
- #xml_str ⇒ Object
Methods included from Utility::XmlPrimitives
#r_id_attributes, #write_color, #write_xml_declaration
Constructor Details
#initialize ⇒ Drawings
Returns a new instance of Drawings.
880 881 882 883 884 885 |
# File 'lib/write_xlsx/drawing.rb', line 880 def initialize @writer = Package::XMLWriterSimple.new @drawings = [] @embedded = false @orientation = false end |
Instance Attribute Details
#embedded=(value) ⇒ Object (writeonly)
Sets the attribute embedded
878 879 880 |
# File 'lib/write_xlsx/drawing.rb', line 878 def (value) @embedded = value end |
#orientation=(value) ⇒ Object (writeonly)
Sets the attribute orientation
878 879 880 |
# File 'lib/write_xlsx/drawing.rb', line 878 def orientation=(value) @orientation = value end |
Instance Method Details
#add_drawing_object(drawing) ⇒ Object
Add a chart, image or shape sub object to the drawing.
924 925 926 |
# File 'lib/write_xlsx/drawing.rb', line 924 def add_drawing_object(drawing) @drawings << drawing end |
#assemble_xml_file ⇒ Object
Assemble and write the XML file.
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
# File 'lib/write_xlsx/drawing.rb', line 898 def assemble_xml_file write_xml_declaration do # Write the xdr:wsDr element. write_drawing_workspace do if @embedded @drawings.each_with_index do |drawing, index| # Write the xdr:twoCellAnchor element. drawing.writer = @writer drawing. = @embedded drawing.write_two_cell_anchor(index + 1) end else # Write the xdr:absoluteAnchor element. drawing = Drawing.new(nil, nil, nil, nil, nil, nil) drawing.writer = @writer drawing. = @embedded drawing.orientation = @orientation drawing.write_absolute_anchor(1) end end end end |
#set_xml_writer(filename) ⇒ Object
891 892 893 |
# File 'lib/write_xlsx/drawing.rb', line 891 def set_xml_writer(filename) @writer.set_xml_writer(filename) end |
#xml_str ⇒ Object
887 888 889 |
# File 'lib/write_xlsx/drawing.rb', line 887 def xml_str @writer.string end |