class Axlsx::WorksheetDrawing

This is a utility class for serialing the drawing node in a worksheet. Drawing objects have their own serialization that exports a drawing document. This is only for the single node in the worksheet

Attributes

drawing[R]
worksheet[R]

Public Class Methods

new(worksheet) click to toggle source

Creates a new WorksheetDrawing @param [Worksheet] worksheet

# File lib/axlsx/workbook/worksheet/worksheet_drawing.rb, line 11
def initialize(worksheet)
  raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
  @worksheet = worksheet
  @drawing = nil
end

Public Instance Methods

add_chart(chart_type, options) click to toggle source

adds a chart to the drawing object @param [Class] chart_type The type of chart to add @param [Hash] options Options to pass on to the drawing and chart @see Worksheet#add_chart

# File lib/axlsx/workbook/worksheet/worksheet_drawing.rb, line 25
def add_chart(chart_type, options)
  @drawing ||= Drawing.new worksheet
  drawing.add_chart(chart_type, options)
end
add_image(options) click to toggle source

adds an image to the drawing object @param [Hash] options Options to pass on to the drawing and image @see Worksheet#add_image

# File lib/axlsx/workbook/worksheet/worksheet_drawing.rb, line 33
def add_image(options)
  @drawing ||= Drawing.new worksheet
  drawing.add_image(options)
end
has_drawing?() click to toggle source

helper method to tell us if the drawing has something in it or not @return [Boolean]

# File lib/axlsx/workbook/worksheet/worksheet_drawing.rb, line 40
def has_drawing?
  @drawing.is_a? Drawing
end
relationship() click to toggle source

The relationship instance for this drawing. @return [Relationship]

# File lib/axlsx/workbook/worksheet/worksheet_drawing.rb, line 46
def relationship
  return unless has_drawing?
  Relationship.new(self, DRAWING_R, "../#{drawing.pn}") 
end
to_xml_string(str = '') click to toggle source

Serialize the drawing for the worksheet @param [String] str

# File lib/axlsx/workbook/worksheet/worksheet_drawing.rb, line 53
def to_xml_string(str = '')
  return unless has_drawing? 
  str << "<drawing r:id='#{relationship.Id}'/>"
end