lib/excelfile/worksheet.rb in rubyfromexcel-0.0.10 vs lib/excelfile/worksheet.rb in rubyfromexcel-0.0.13

- old
+ new

@@ -1,11 +1,11 @@ module RubyFromExcel class Worksheet - def self.from_file(filename) + def self.from_file(filename,workbook = nil) xml = File.open(filename) { |f| Nokogiri::XML(f).root } - worksheet = Worksheet.new(xml) + worksheet = Worksheet.new(xml,File.basename(filename,'.xml'),workbook) relationships = Relationships.for_file(filename) xml.css('tablePart').each do |table_reference_xml| table_xml = File.open(relationships[table_reference_xml['id']]) {|f| Nokogiri::XML(f).root } Table.from_xml(worksheet,table_xml) end @@ -15,11 +15,13 @@ attr_accessor :cells attr_accessor :name attr_reader :named_references attr_accessor :workbook - def initialize(xml) + def initialize(xml,name = nil,workbook = nil) + self.name = name + self.workbook = workbook self.cells = {} @named_references = {} load_cells_from xml GC.start end @@ -56,9 +58,10 @@ end def work_out_dependencies cells.each do |reference,cell| cell.work_out_dependencies + RubyFromExcel.debug(:dependences,"#{name}.#{cell.reference} -> #{cell.dependencies.inspect}") end end def cell(reference) cells[reference] \ No newline at end of file