Skip to content

Commit

Permalink
Merge branch 'master' of github.com:roo-rb/roo
Browse files Browse the repository at this point in the history
  • Loading branch information
stevendaniels committed Aug 21, 2016
2 parents d50b926 + 9d6887e commit ac4e681
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- Roo::Base::TEMP_PREFIX should be accessed via Roo::TEMP_PREFIX
- The private Roo::Base#make_tempdir is now available at the class level in
classes that use tempdirs, added via Roo::Tempdir
=======
### Added
- Discard hiperlinks lookups to allow streaming parsing without loading whole files

## [2.4.0] 2016-05-14
### Fixed
Expand Down
1 change: 1 addition & 0 deletions lib/roo/excelx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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 ac4e681

Please sign in to comment.