lib/roo/excelx.rb in roo-1.0.1 vs lib/roo/excelx.rb in roo-1.0.2

- old
+ new

@@ -3,19 +3,20 @@ require 'rexml/document' require 'fileutils' require 'zip/zipfilesystem' require 'date' #require 'base64' - +require 'logger' class String def end_with?(str) self[-str.length,str.length] == str end end class Excelx < GenericSpreadsheet - + #$log = Logger.new("excelx.log",5,100*1024) + #$log.level = Logger::DEBUG @@nr = 0 # initialization and opening of a spreadsheet file # values for packed: :zip def initialize(filename, packed=nil) #, create = false) @@ -135,11 +136,11 @@ # * :percentage def celltype(row,col,sheet=nil) sheet = @default_sheet unless sheet read_cells(sheet) unless @cells_read[sheet] row,col = normalize(row,col) - if @formula[sheet]["#{row},#{col}"] + if @formula and @formula[sheet] and @formula[sheet]["#{row},#{col}"] return :formula else @cell_type[sheet]["#{row},#{col}"] end end @@ -290,11 +291,11 @@ if row.attributes['t'] == 's' tmp_type = :shared end if row.attributes['s'] == '2' tmp_type = :date - elsif row.attributes['s'] == '1' + elsif row.attributes['s'] == '1' and row.attributes['t'] == nil # and ergaenzt 2008-07-03 tmp_type = :formula end formula = nil f_element_found = false row.each_element do |cell| @@ -321,12 +322,13 @@ else vt = :float v = cell.text end x,y = split_coordinate(row.attributes['r']) - tr=nil #TODO: ??? + tr=nil #TODO: ???s set_cell_values(sheet,x,y,0,v,vt,formula,tr,str_v) + #$log.debug "#{sheet},#{x},#{y},0,#{v},#{vt},#{formula},#{tr},#{str_v})" end end end end end @@ -376,10 +378,10 @@ if entry.to_s.end_with?('sharedStrings.xml') open(@tmpdir+'/'+@file_nr.to_s+'_roo_sharedStrings.xml','wb') {|f| f << zip.read(entry) } end - if entry.to_s =~ /sheet([0-9]+).xml/ + if entry.to_s =~ /sheet([0-9]+).xml$/ nr = $1 # entry.extract("xaxa_sheet#{nr}.xml") open(@tmpdir+'/'+@file_nr.to_s+"_roo_sheet#{nr}",'wb') {|f| f << zip.read(entry) }