Skip to content

Commit

Permalink
Removed hyperlinks when parsing files in streaming mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Uceda Pompa authored and pacoguzman committed May 29, 2016
1 parent 211f89b commit 1179278
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [Unreleased]
### Added
- Discard hiperlinks lookups to allow streaming parsing without loading whole files

## [2.4.0] 2016-05-14
### Fixed
- Fixed opening spreadsheets with charts [315](https://github.com/roo-rb/roo/pull/315)
Expand Down
1 change: 1 addition & 0 deletions lib/roo/excelx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def initialize(filename_or_stream, options = {})
cell_max = options.delete(:cell_max)
sheet_options = {}
sheet_options[:expand_merged_ranges] = (options[:expand_merged_ranges] || false)
sheet_options[:no_hyperlinks] = (options[:no_hyperlinks] || false)

unless is_stream?(filename_or_stream)
file_type_check(filename_or_stream, %w[.xlsx .xlsm], 'an Excel 2007', file_warning, packed)
Expand Down
9 changes: 7 additions & 2 deletions lib/roo/excelx/sheet_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ def each_row_streaming(&block)
def each_cell(row_xml)
return [] unless row_xml
row_xml.children.each do |cell_element|
key = ::Roo::Utils.ref_to_key(cell_element['r'])
yield cell_from_xml(cell_element, hyperlinks(@relationships)[key])
# If you're sure you're not going to need this hyperlinks you can discard it
hyperlinks = unless @options[:no_hyperlinks]
key = ::Roo::Utils.ref_to_key(cell_element['r'])
hyperlinks(@relationships)[key]
end

yield cell_from_xml(cell_element, hyperlinks)
end
end

Expand Down

0 comments on commit 1179278

Please sign in to comment.