lib/roo/excelx.rb in roo-2.8.3 vs lib/roo/excelx.rb in roo-2.9.0

- old
+ new

@@ -58,19 +58,20 @@ @shared = Shared.new(@tmpdir, shared_options) @filename = local_filename(filename_or_stream, @tmpdir, packed) process_zipfile(@filename || filename_or_stream) - @sheet_names = workbook.sheets.map do |sheet| - unless options[:only_visible_sheets] && sheet['state'] == 'hidden' - sheet['name'] - end - end.compact + @sheet_names = [] @sheets = [] @sheets_by_name = {} - @sheet_names.each_with_index do |sheet_name, n| - @sheets_by_name[sheet_name] = @sheets[n] = Sheet.new(sheet_name, @shared, n, sheet_options) + + workbook.sheets.each_with_index do |sheet, index| + next if options[:only_visible_sheets] && sheet['state'] == 'hidden' + + sheet_name = sheet['name'] + @sheet_names << sheet_name + @sheets_by_name[sheet_name] = @sheets[index] = Sheet.new(sheet_name, @shared, index, sheet_options) end if cell_max cell_count = ::Roo::Utils.num_cells_in_range(sheet_for(options.delete(:sheet)).dimensions) raise ExceedsMaxError.new("Excel file exceeds cell maximum: #{cell_count} > #{cell_max}") if cell_count > cell_max @@ -426,9 +427,14 @@ extract_images(entries, @tmpdir) entries.each do |entry| path = case entry.name.downcase + when /richdata/ + # FIXME: Ignore richData as parsing is not implemented yet and can cause + # Zip::DestinationFileExistsError when including a second "styles.xml" entry + # see http://schemas.microsoft.com/office/spreadsheetml/2017/richdata2 + nil when /sharedstrings.xml$/ "#{@tmpdir}/roo_sharedStrings.xml" when /styles.xml$/ "#{@tmpdir}/roo_styles.xml" when /comments([0-9]+).xml$/