lib/poi/workbook/named_range.rb in jruby-poi-0.6.0 vs lib/poi/workbook/named_range.rb in jruby-poi-0.6.1
- old
+ new
@@ -1,45 +1,30 @@
-class NamedRange
+module POI
+ class NamedRange
- # takes an instance of org.apache.poi.ss.usermodel.Name, and a POI::Workbook
- def initialize name, workbook
- @name = name
- @workbook = workbook
- end
+ # takes an instance of org.apache.poi.ss.usermodel.Name, and a POI::Workbook
+ def initialize name, workbook
+ @name = name
+ @workbook = workbook
+ end
- def name
- @name.getNameName
- end
+ def name
+ @name.getNameName
+ end
- def sheet
- @workbook[@name.getSheetName]
- end
+ def sheet
+ @workbook[@name.getSheetName]
+ end
- def formula
- @name.getRefersToFormula
- end
+ def formula
+ @name.getRefersToFormula
+ end
- def cells
- area_range? ? all_cells_from_area : @workbook.cell(formula)
- end
+ def cells
+ [@workbook.cell(formula)].flatten
+ end
- def values
- cells.collect{|c| c.value}
- end
-
- private
- def area_range?
- area.nil? == false
+ def values
+ cells.collect{|c| c.value}
end
-
- def area
- @area ||= begin
- org.apache.poi.ss.util.AreaReference.new formula
- rescue
- nil
- end
- end
-
- def all_cells_from_area
- area.getAllReferencedCells.collect{|c| @workbook.cell c.formatAsString}
- end
+ end
end
\ No newline at end of file