diff --git a/lib/roo/excelx/relationships.rb b/lib/roo/excelx/relationships.rb index 19f99191..754775d4 100644 --- a/lib/roo/excelx/relationships.rb +++ b/lib/roo/excelx/relationships.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'roo/excelx/extractor' module Roo @@ -11,10 +13,16 @@ def to_a @relationships ||= extract_relationships end + def include_type?(type) + to_a.any? do |_, rel| + rel["Type"]&.include? type + end + end + private def extract_relationships - return [] unless doc_exists? + return {} unless doc_exists? doc.xpath('/Relationships/Relationship').each_with_object({}) do |rel, hash| hash[rel['Id']] = rel diff --git a/lib/roo/excelx/sheet_doc.rb b/lib/roo/excelx/sheet_doc.rb index 2b3aa397..fe11b6b4 100755 --- a/lib/roo/excelx/sheet_doc.rb +++ b/lib/roo/excelx/sheet_doc.rb @@ -22,7 +22,7 @@ def cells(relationships) def hyperlinks(relationships) # If you're sure you're not going to need this hyperlinks you can discard it - @hyperlinks ||= if @options[:no_hyperlinks] + @hyperlinks ||= if @options[:no_hyperlinks] || !relationships.include_type?("hyperlink") {} else extract_hyperlinks(relationships)