def export(output_file, format = :csv, overwrite = false)
      raise JSS::InvalidDataError, "Export format must be one of: :#{EXPORT_FORMATS.join ', :'}" unless EXPORT_FORMATS.include? format

      out = Pathname.new output_file

      unless overwrite
        raise JSS::AlreadyExistsError, "The output file already exists: #{out}" if out.exist?
      end

      case format
      when :csv
        require 'csv'
        CSV.open(out.to_s, 'wb') do |csv|
          csv << @result_display_keys
          @search_results.each do |row|
            csv << @result_display_keys.map { |key| row[key] }
          end # each do row
        end # CSV.open

      when :tab
        tabbed = @result_display_keys.join("\t") + "\n"
        @search_results.each do |row|
          tabbed << @result_display_keys.map { |key| row[key] }.join("\t") + "\n"
        end # each do row
        out.jss_save tabbed.chomp

      else # :xml
        doc = REXML::Document.new '<?xml version="1.0" encoding="ISO-8859-1"?>'
        members = doc.add_element self.class::RESULT_CLASS::RSRC_LIST_KEY.to_s
        @search_results.each do |row|
          member = members.add_element self.class::RESULT_CLASS::RSRC_OBJECT_KEY.to_s
          @result_display_keys.each do |field|
            member.add_element(field.to_s.tr(' ', '_')).text = row[field].empty? ? nil : row[field]
          end # ech do field
        end # each do row
        out.jss_save doc.to_s.gsub('><', ">\n<")
      end # case

      out
    end
def export(output_file, format = :csv, overwrite = false)
      raise JSS::InvalidDataError, "Export format must be one of: :#{EXPORT_FORMATS.join ', :'}" unless EXPORT_FORMATS.include? format

      out = Pathname.new output_file

      unless overwrite
        raise JSS::AlreadyExistsError, "The output file already exists: #{out}" if out.exist?
      end

      case format
      when :csv
        require 'csv'
        CSV.open(out.to_s, 'wb') do |csv|
          csv << @result_display_keys
          @search_results.each do |row|
            csv << @result_display_keys.map { |key| row[key] }
          end # each do row
        end # CSV.open

      when :tab
        tabbed = @result_display_keys.join("\t") + "\n"
        @search_results.each do |row|
          tabbed << @result_display_keys.map { |key| row[key] }.join("\t") + "\n"
        end # each do row
        out.jss_save tabbed.chomp

      else # :xml
        doc = REXML::Document.new '<?xml version="1.0" encoding="ISO-8859-1"?>'
        members = doc.add_element self.class::RESULT_CLASS::RSRC_LIST_KEY.to_s
        @search_results.each do |row|
          member = members.add_element self.class::RESULT_CLASS::RSRC_OBJECT_KEY.to_s
          @result_display_keys.each do |field|
            member.add_element(field.to_s.tr(' ', '_')).text = row[field].empty? ? nil : row[field]
          end # ech do field
        end # each do row
        out.jss_save doc.to_s.gsub('><', ">\n<")
      end # case

      out
    end
Export the display fields of the search results to a file.

 @param output_file[String,Pathname] The file in which to store the exported results

 @param format[Symbol] one of :csv, :tab, or :xml, defaults to :csv

 @param overwrite[Boolean] should the output_file be overwrite if it exists? Defaults to false

 @return [Pathname] the path to the output file

 @note This method only exports the display fields defined in this advanced search for
 the search_result members (computers, mobile_devices, or users)
 It doesn't currently provide the ability to export subsets of info about those objects, as the
 Web UI does (e.g. group memberships, applications, receipts, etc)