Reputation: 6388
With https://github.com/caxlsx/caxlsx gem I'm trying to access defined names created dynamically over iteration with an each_with_index
array method and giving each one with a name like "piece-0", "piece-1", "piece-3"... etc. On the file, the names are correctly created but I need the formula for sum many calling them by the name.
she.add_row ["Total","",""] + ["--the sum of cells by name must be here--"]
I create the names but I need to know how to use them.
Upvotes: 0
Views: 101
Reputation: 6388
Solved!
Solution was build a string that concatenate and reference the cells.
something like this.
build_string = ""
cellposition = "10"
cells.each do |cell|
build_string = @alphabet_with_letters[position_that_i_want] + cellposition + ":"
cellposition = cellposition.to_i
cellposition += 1
cellposition == cellposition.to_s
end
#then use this where you need to call it
"=SUM(#{build_string.chop})"
Upvotes: 0