Method: Axlsx::Package#to_stream

Defined in:
lib/axlsx/package.rb

#to_stream(confirm_valid = false) ⇒ StringIO|Boolean

Serialize your workbook to a StringIO instance

Parameters:

  • confirm_valid (Boolean) (defaults to: false)

    Validate the package prior to serialization.

Returns:

  • (StringIO|Boolean)

    False if confirm_valid and validation errors exist. rewound string IO if not.



114
115
116
117
118
119
120
121
# File 'lib/axlsx/package.rb', line 114

def to_stream(confirm_valid=false)
  return false unless !confirm_valid || self.validate.empty?
  Relationship.clear_cached_instances
  zip = write_parts(Zip::OutputStream.new(StringIO.new, true))
  stream = zip.close_buffer
  stream.rewind
  stream
end