Skip to content

Commit

Permalink
Merge pull request #543 from renuo/fix/missing_coordinates
Browse files Browse the repository at this point in the history
Fix issue with spreadsheets containing filters
  • Loading branch information
patrickkulling authored Feb 6, 2023
2 parents 18b2e26 + bafb32b commit 92634fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/roo/excelx/workbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def defined_names
doc.xpath('//definedName').each_with_object({}) do |defined_name, hash|
# "Sheet1!$C$5"
sheet, coordinates = defined_name.text.split('!$', 2)
next unless coordinates
col, row = coordinates.split('$')
name = defined_name['name']
hash[name] = Label.new(name, sheet, row, col)
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/roo/excelx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,17 @@
end
end

describe 'opening a file with filters' do
let(:path) { 'test/files/wrong_coordinates.xlsx' }
subject(:xlsx) do
Roo::Spreadsheet.open(path)
end

it 'should properly extract defined_names' do
expect(subject.sheet(0).workbook.defined_names.length).to eq(1)
end
end

describe 'images' do
let(:path) { 'test/files/images.xlsx' }

Expand Down
Binary file added test/files/wrong_coordinates.xlsx
Binary file not shown.

0 comments on commit 92634fb

Please sign in to comment.