diff options
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 4 | ||||
| -rw-r--r-- | test/workbook/tc_workbook.rb | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 92d3396f..cf7a02ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG - Added frozen string literals - Fix `SimpleTypedList#to_a` and `SimpleTypedList#to_ary` returning the internal list instance - Remove ability to set `u=` to true in favor of using :single or one of the other underline options + - Fix `Workbook#sheet_by_name` not returning sheets with encoded characters in the name - **April.23.23**: 3.4.1 - [PR #209](https://github.com/caxlsx/caxlsx/pull/209) - Revert characters other than `=` being considered as formulas. diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index 1a2f0488..da36e9a0 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -221,8 +221,8 @@ module Axlsx # @param [String] name The name of the sheet you are looking for # @return [Worksheet] The sheet found, or nil def sheet_by_name(name) - index = @worksheets.index { |sheet| sheet.name == name } - @worksheets[index] if index + encoded_name = Axlsx.coder.encode(name) + @worksheets.find { |sheet| sheet.name == encoded_name } end # Creates a new Workbook. diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb index d85c17d9..b1cfdc71 100644 --- a/test/workbook/tc_workbook.rb +++ b/test/workbook/tc_workbook.rb @@ -47,8 +47,10 @@ class TestWorkbook < Test::Unit::TestCase def test_sheet_by_name_retrieval @wb.add_worksheet(:name => 'foo') @wb.add_worksheet(:name => 'bar') + @wb.add_worksheet(:name => "testin'") assert_equal('foo', @wb.sheet_by_name('foo').name) + assert_equal("testin'", @wb.sheet_by_name("testin'").name) end def test_worksheet_empty_name |
