Skip to content

Commit

Permalink
Merge d756d45 into b6d6479
Browse files Browse the repository at this point in the history
  • Loading branch information
chopraanmol1 committed Dec 26, 2018
2 parents b6d6479 + d756d45 commit 1f308f8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/roo/excelx/sheet_doc.rb
Expand Up @@ -46,7 +46,7 @@ def each_row_streaming(&block)
def each_cell(row_xml)
return [] unless row_xml
row_xml.children.each do |cell_element|
coordinate = ::Roo::Utils.extract_coordinate(cell_element[COMMON_STRINGS[:r]])
coordinate = ::Roo::Utils.extract_coordinate(cell_element["r"])
hyperlinks = hyperlinks(@relationships)[coordinate]

yield cell_from_xml(cell_element, hyperlinks, coordinate)
Expand Down Expand Up @@ -86,13 +86,13 @@ def cell_value_type(type, format)
#
# Returns a type of <Excelx::Cell>.
def cell_from_xml(cell_xml, hyperlink, coordinate, empty_cell=true)
coordinate ||= ::Roo::Utils.extract_coordinate(cell_xml[COMMON_STRINGS[:r]])
coordinate ||= ::Roo::Utils.extract_coordinate(cell_xml["r"])
cell_xml_children = cell_xml.children
return create_empty_cell(coordinate, empty_cell) if cell_xml_children.empty?

# NOTE: This is error prone, to_i will silently turn a nil into a 0.
# This works by coincidence because Format[0] is General.
style = cell_xml[COMMON_STRINGS[:s]].to_i
style = cell_xml["s"].to_i
formula = nil

cell_xml_children.each do |cell|
Expand All @@ -111,7 +111,7 @@ def cell_from_xml(cell_xml, hyperlink, coordinate, empty_cell=true)
formula = cell.content
when 'v'
format = style_format(style)
value_type = cell_value_type(cell_xml[COMMON_STRINGS[:t]], format)
value_type = cell_value_type(cell_xml["t"], format)

return create_cell_from_value(value_type, cell, formula, format, style, hyperlink, coordinate)
end
Expand Down Expand Up @@ -180,7 +180,7 @@ def extract_hyperlinks(relationships)

Hash[hyperlinks.map do |hyperlink|
if hyperlink.attribute('id') && (relationship = relationships[hyperlink.attribute('id').text])
[::Roo::Utils.ref_to_key(hyperlink.attributes[COMMON_STRINGS[:ref]].to_s), relationship.attribute('Target').text]
[::Roo::Utils.ref_to_key(hyperlink.attributes["ref"].to_s), relationship.attribute('Target').text]
end
end.compact]
end
Expand All @@ -189,7 +189,7 @@ def expand_merged_ranges(cells)
# Extract merged ranges from xml
merges = {}
doc.xpath('/worksheet/mergeCells/mergeCell').each do |mergecell_xml|
tl, br = mergecell_xml[COMMON_STRINGS[:ref]].split(/:/).map { |ref| ::Roo::Utils.ref_to_key(ref) }
tl, br = mergecell_xml["ref"].split(/:/).map { |ref| ::Roo::Utils.ref_to_key(ref) }
for row in tl[0]..br[0] do
for col in tl[1]..br[1] do
next if row == tl[0] && col == tl[1]
Expand All @@ -208,7 +208,7 @@ def extract_cells(relationships)
empty_cell = @options[:empty_cell]

doc.xpath('/worksheet/sheetData/row/c').each do |cell_xml|
coordinate = ::Roo::Utils.extract_coordinate(cell_xml[COMMON_STRINGS[:r]])
coordinate = ::Roo::Utils.extract_coordinate(cell_xml["r"])
cell = cell_from_xml(cell_xml, hyperlinks(relationships)[coordinate], coordinate, empty_cell)
extracted_cells[coordinate] = cell if cell
end
Expand All @@ -220,7 +220,7 @@ def extract_cells(relationships)

def extract_dimensions
Roo::Utils.each_element(@path, 'dimension') do |dimension|
return dimension.attributes[COMMON_STRINGS[:ref]].value
return dimension.attributes["ref"].value
end
end

Expand Down

0 comments on commit 1f308f8

Please sign in to comment.