Serialize the workbook
 @param [String] str
 @return [String]
429678
def to_xml_string(str='')
      add_worksheet(name: 'Sheet1') unless worksheets.size > 0
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">')
      str << ('<workbookPr date1904="' << @@date1904.to_s << '"/>')
      views.to_xml_string(str)
      str << '<sheets>'
      if is_reversed
        worksheets.reverse_each { |sheet| sheet.to_sheet_node_xml_string(str) }
      else
        worksheets.each { |sheet| sheet.to_sheet_node_xml_string(str) }
      end
      str << '</sheets>'
      defined_names.to_xml_string(str)
      unless pivot_tables.empty?
        str << '<pivotCaches>'
        pivot_tables.each do |pivot_table|
          str << ('<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>')
        end
        str << '</pivotCaches>'
      end
      str << '</workbook>'
    end
1020926
def to_xml_string(str = '')
      str << '<c:catAx>'
      super(str)
      str << ('<c:auto val="' << @auto.to_s << '"/>')
      str << ('<c:lblAlgn val="' << @lbl_algn.to_s << '"/>')
      str << ('<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>')
      str << ('<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>')
      str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>')
      str << '</c:catAx>'
    end
1056445
def serialize(expr):
    """"""

    result = None

    if isinstance(expr, string_types):
        result = expr

    elif expr is not None:
        result = '=py:{0}'.format(expr)

    return result
437633
def serialize!(attributes)
      unless attributes.nil?
        attributes.each do |key, value|
          key = "id" if key == "_id"
          self.send("#{key}=", (value.dup rescue value))
        end
      end

      self.dup
    end
974047
def to_xml_string(str = '')
      str << ('<patternFill patternType="' << patternType.to_s << '">')
      if fgColor.is_a?(Color)
        fgColor.to_xml_string str, "fgColor"
      end

      if bgColor.is_a?(Color)
        bgColor.to_xml_string str, "bgColor"
      end
      str << '</patternFill>'
    end
179930
def to_xml_string(str = "")
      author = @comments.authors[author_index]
      str << ('<comment ref="' << ref << '" authorId="' << author_index.to_s << '">')
      str << '<text>'
      unless author.to_s == ""
        str << '<r><rPr><b/><color indexed="81"/></rPr>'
        str << ("<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>")
      end
      str << '<r>'
      str << '<rPr><color indexed="81"/></rPr>'
      str << ('<t>' << ::CGI.escapeHTML(text) << '</t></r></text>')
      str << '</comment>'
    end
1335374
def to_xml_string(str="")
      str << ('<c:' << tag_name.to_s << '>')
      if @f
        str << ('<c:' << @ref_tag_name.to_s << '>')
        str << ('<c:f>' << @f.to_s << '</c:f>')
      end
      @data.to_xml_string str
      if @f
        str << ('</c:' << @ref_tag_name.to_s << '>')
      end
      str << ('</c:' << tag_name.to_s << '>')
    end
588398
def to_xml_string(str = '')
      str << '<dxf>'
      # Dxf elements have no attributes. All of the instance variables
      # are child elements.
      CHILD_ELEMENTS.each do |element|
        self.send(element).to_xml_string(str) if self.send(element)
      end
      str << '</dxf>'
    end
1281157
def to_xml_string(str = '')
      super(str) do

        colors.each_with_index do |c, index|
          str << '<c:dPt>'
          str << ('<c:idx val="' << index.to_s << '"/>')
          str << '<c:spPr><a:solidFill>'
          str << ('<a:srgbClr val="' << c << '"/>')
          str << '</a:solidFill></c:spPr></c:dPt>'
        end

        @labels.to_xml_string(str) unless @labels.nil?
        @data.to_xml_string(str) unless @data.nil?
        # this is actually only required for shapes other than box 
        str << ('<c:shape val="' << shape.to_s << '"></c:shape>')
      end
    end
1127745
def to_xml_string(str = "")
      str << ('<c:' << @tag_name.to_s << '>')
      str << ('<c:ptCount val="' << @pt.size.to_s << '"/>')
      @pt.each_with_index do |value, index|
        value.to_xml_string index, str
      end
      str << ('</c:' << @tag_name.to_s << '>')
    end
1211708
def to_xml_string(str = '', options = {})
      if options[:ids]
        # CatAxis must come first in the XML (for Microsoft Excel at least)
        sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 }
        sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') }        
      else
        axes.each { |axis| axis[1].to_xml_string(str) }
      end
    end
1089864
def load_str(str=nil,format=nil)
      str = @data if str.nil?
      format = @format if format.nil?

      @value = {}
      case format
      when List::FORMAT_BINARY, List::FORMAT_XML, List::FORMAT_PLAIN then
        prsr = @@parsers[format-1].new
        @value = prsr.load({:data => str})

      when List::FORMAT_AUTO then # what we now do is ugly, but neccessary to recognize the file format
        filetype = str[0..5]
        version = str[6..7]

        prsr = nil

        if filetype == "bplist" then
          raise CFFormatError.new("Wrong file version #{version}") unless version == "00"
          prsr = Binary.new
          @format = List::FORMAT_BINARY
        else
          if str =~ /^<(\?xml|!DOCTYPE|plist)/
            prsr = CFPropertyList.xml_parser_interface.new
            @format = List::FORMAT_XML
          else
            prsr = PlainParser.new
            @format = List::FORMAT_PLAIN
          end
        end

        @value = prsr.load({:data => str})
      end
    end
825866
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ')
      str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ')
      str << ('xmlns:xsi="' << CORE_NS_XSI << '">')
      str << ('<dc:creator>' << self.creator << '</dc:creator>')
      str << ('<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>')
      str << '<cp:revision>0</cp:revision>'
      str << '</cp:coreProperties>'
    end
1117772
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<Types xmlns="' << XML_NS_T << '">')
      each { |type| type.to_xml_string(str) }
      str << '</Types>'
    end
1093477
def to_xml_string(str = '')
      str << '<xdr:pic>'
      str << '<xdr:nvPicPr>'
      str << ('<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">')
      hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink)
      str << '</xdr:cNvPr><xdr:cNvPicPr>'
      picture_locking.to_xml_string(str)
      str << '</xdr:cNvPicPr></xdr:nvPicPr>'
      str << '<xdr:blipFill>'
      str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
      if opacity
        str << "<a:alphaModFix amt=\"#{opacity}\"/>"
      end
      str << '</a:blip>'
      str << '<a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr>'
      str << '<a:xfrm><a:off x="0" y="0"/><a:ext cx="2336800" cy="2161540"/></a:xfrm>'
      str << '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>'
    end
280108
def to_xml_string(str = '')
      valid = RichTextRun::INLINE_STYLES
      data = Hash[self.instance_values.map{ |k, v| [k.to_sym, v] }]
      data = data.select { |key, value| valid.include?(key) && !value.nil? }

      str << '<r><rPr>'
      data.keys.each do |key|
        case key
        when :font_name
          str << ('<rFont val="' << font_name << '"/>')
        when :color
          str << data[key].to_xml_string
        else
          str << ('<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>')
        end
      end
      clean_value = Axlsx::trust_input ? @value.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@value.to_s))
      str << ('</rPr><t>' << clean_value << '</t></r>')
    end
1372309
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<Relationships xmlns="' << RELS_R << '">')
      each{ |rel| rel.to_xml_string(str) }
      str << '</Relationships>'
    end