summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-09 21:49:08 +0900
committerRandy Morgan <[email protected]>2012-10-09 21:49:08 +0900
commitf0bc5f17ddafd8172646a04bbbc0d3b958c0205f (patch)
treefc95c9f43d917c11820e0f21950804560e52fe4b /lib
parent682e0c1a950b9ca9498e0f4c89402d6f3f25657c (diff)
downloadcaxlsx-f0bc5f17ddafd8172646a04bbbc0d3b958c0205f.tar.gz
caxlsx-f0bc5f17ddafd8172646a04bbbc0d3b958c0205f.zip
Added a helper to find and return a worksheet from the workbook by name
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/workbook/workbook.rb10
1 files changed, 9 insertions, 1 deletions
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.