Skip to content

Extend no_hyperlinks option to non-streaming methods of Excelx #459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/roo/excelx/sheet_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def cells(relationships)
end

def hyperlinks(relationships)
@hyperlinks ||= extract_hyperlinks(relationships)
# If you're sure you're not going to need this hyperlinks you can discard it
@hyperlinks ||= if @options[:no_hyperlinks]
{}
else
extract_hyperlinks(relationships)
end
end

# Get the dimensions for the sheet.
Expand All @@ -41,11 +46,8 @@ def each_row_streaming(&block)
def each_cell(row_xml)
return [] unless row_xml
row_xml.children.each do |cell_element|
# If you're sure you're not going to need this hyperlinks you can discard it
coordinate = ::Roo::Utils.extract_coordinate(cell_element[COMMON_STRINGS[:r]])
hyperlinks = unless @options[:no_hyperlinks]
hyperlinks(@relationships)[coordinate]
end
hyperlinks = hyperlinks(@relationships)[coordinate]

yield cell_from_xml(cell_element, hyperlinks, coordinate)
end
Expand Down