Method: Axlsx::Package#serialize
- Defined in:
- lib/axlsx/package.rb
#serialize(output, options = {}, secondary_options = nil) ⇒ Boolean
Note:
A tremendous amount of effort has gone into ensuring that you cannot create invalid xlsx documents. options[:confirm_valid] should be used in the rare case that you cannot open the serialized file.
Serialize your workbook to disk as an xlsx document.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/axlsx/package.rb', line 108 def serialize(output, = {}, = nil) unless workbook.styles_applied workbook.apply_styles end confirm_valid, zip_command, password = (, ) return false unless !confirm_valid || validate.empty? zip_provider = if zip_command ZipCommand.new(zip_command) else BufferedZipOutputStream end Relationship.initialize_ids_cache zip_provider.open(output) do |zip| write_parts(zip) end if password && !password.empty? require_ooxml_crypt! OoxmlCrypt.encrypt_file(output, password, output) end true ensure Relationship.clear_ids_cache end |