diff options
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 10 | ||||
| -rw-r--r-- | test/workbook/tc_workbook.rb | 7 |
3 files changed, 19 insertions, 1 deletions
@@ -149,6 +149,9 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem, #Change log --------- +- **October.??.12**: 1.3.2 + - Patched to handle sheet names with apostrophes + - refactored string and boolean attribute accessors - **September.30.12**: 1.3.1 - Improved control character handling - Added stored auto filter values and date grouping items diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index 956856ae..a1964883 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -152,6 +152,14 @@ require 'axlsx/workbook/worksheet/selection.rb' @@date1904 = false + # A quick helper to retrive a worksheet by name + # @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 + end + # lets come back to this later when we are ready for parsing. #def self.parse entry # io = entry.get_input_stream @@ -160,7 +168,7 @@ require 'axlsx/workbook/worksheet/selection.rb' # w.parse_string :date1904, "//xmlns:workbookPr/@date1904" # w #end - + # Creates a new Workbook # The recomended way to work with workbooks is via Package#workbook # @option options [Boolean] date1904. If this is not specified, date1904 is set to false. Office 2011 for Mac defaults to false. diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb index 537f9074..f10ad24a 100644 --- a/test/workbook/tc_workbook.rb +++ b/test/workbook/tc_workbook.rb @@ -16,6 +16,13 @@ class TestWorkbook < Test::Unit::TestCase assert_equal(@wb.use_autowidth, false) end + + def test_sheet_by_name_retrieval + @wb.add_worksheet(:name=>'foo') + @wb.add_worksheet(:name=>'bar') + assert_equal('foo', @wb.sheet_by_name('foo').name) + + end def test_date1904 assert_equal(Axlsx::Workbook.date1904, @wb.date1904) @wb.date1904 = :false |
