Class: Writexlsx::Drawing
- Inherits:
-
Object
- Object
- Writexlsx::Drawing
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/drawing.rb
Constant Summary
Constants included from Utility
Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
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(*args) ⇒ Object
Add a chart, image or shape sub object to the drawing.
-
#assemble_xml_file ⇒ Object
Assemble and write the XML file.
-
#initialize ⇒ Drawing
constructor
A new instance of Drawing.
- #set_xml_writer(filename) ⇒ Object
- #xml_str ⇒ Object
Methods included from Utility
#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #dash_types, delete_files, #fill_properties, #float_to_str, #layout_properties, #line_fill_properties, #line_properties, #palette_color, #pixels_to_points, #ptrue?, #put_deprecate_message, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell
Constructor Details
#initialize ⇒ Drawing
Returns a new instance of Drawing.
11 12 13 14 15 16 |
# File 'lib/write_xlsx/drawing.rb', line 11 def initialize @writer = Package::XMLWriterSimple.new @drawings = [] @embedded = false @orientation = false end |
Instance Attribute Details
#embedded=(value) ⇒ Object (writeonly)
Sets the attribute embedded
9 10 11 |
# File 'lib/write_xlsx/drawing.rb', line 9 def (value) @embedded = value end |
#orientation=(value) ⇒ Object (writeonly)
Sets the attribute orientation
9 10 11 |
# File 'lib/write_xlsx/drawing.rb', line 9 def orientation=(value) @orientation = value end |
Instance Method Details
#add_drawing_object(*args) ⇒ Object
Add a chart, image or shape sub object to the drawing.
51 52 53 |
# File 'lib/write_xlsx/drawing.rb', line 51 def add_drawing_object(*args) @drawings << args.flatten end |
#assemble_xml_file ⇒ Object
Assemble and write the XML file.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/write_xlsx/drawing.rb', line 29 def assemble_xml_file write_xml_declaration do # Write the xdr:wsDr element. write_drawing_workspace do if @embedded index = 0 @drawings.each do |dimensions| # Write the xdr:twoCellAnchor element. index += 1 write_two_cell_anchor(index, *(dimensions.flatten)) end else # Write the xdr:absoluteAnchor element. write_absolute_anchor(1) end end end end |
#set_xml_writer(filename) ⇒ Object
22 23 24 |
# File 'lib/write_xlsx/drawing.rb', line 22 def set_xml_writer(filename) @writer.set_xml_writer(filename) end |
#xml_str ⇒ Object
18 19 20 |
# File 'lib/write_xlsx/drawing.rb', line 18 def xml_str @writer.string end |