Sha256: ac10471c7acb4fd3b6b7562b9b31b67e0c1a3d190db9f7c76241d7853be33697
Contents?: true
Size: 930 Bytes
Versions: 6
Compression:
Stored size: 930 Bytes
Contents
# frozen_string_literal: true module Saxlsx class FileSystem IO_METHODS = [:tell, :seek, :read, :close] def self.open(filename) begin file_system = self.new(filename) yield file_system ensure file_system.close end end def initialize(filename) if IO_METHODS.map { |method| filename.respond_to?(method) }.all? @zip = Zip::File.open_buffer filename @io = true else @zip = Zip::File.open filename end end def close @zip.close unless @io end def workbook @zip.get_input_stream('xl/workbook.xml') end def shared_strings file = @zip.glob('xl/shared[Ss]trings.xml').first @zip.get_input_stream(file) if file end def styles @zip.get_input_stream('xl/styles.xml') end def sheet(i) @zip.get_input_stream("xl/worksheets/sheet#{i+1}.xml") end end end
Version data entries
6 entries across 6 versions & 1 rubygems