lib/webdrone/xlsx.rb in webdrone-1.1.0 vs lib/webdrone/xlsx.rb in webdrone-1.1.2
- old
+ new
@@ -105,13 +105,19 @@
row.cells.collect do |cell|
cell.value if cell != nil
end
end
head = rows.shift
- @both.each_with_index do |entry, i|
+ @both.each_with_index do |entry, rowi|
entry.each do |k, v|
- index = head.index(k)
- worksheet[i + 1][index].change_contents(v) if index
+ coli = head.index(k)
+ if coli
+ if worksheet[rowi + 1] == nil || worksheet[rowi + 1][coli] == nil
+ worksheet.add_cell(rowi + 1, coli, v)
+ else
+ worksheet[rowi + 1][coli].change_contents(v)
+ end
+ end
end
end
end
k = workbook.write(@filename)
reset