Skip to content
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

Bebanjo v2.4.0 streaming without hyperlinks #333

Merged
merged 2 commits into from
Aug 21, 2016
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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