How can I add an entire array of cells to a row? I have something like this->
w = RubyXL::Workbook.new
w.add_worksheet("Test")
test_sheet = w["Test"]
test_sheet.add_cell(0, 0, "abc") #this adds abc to row 0 and column 0
arr = ["hello","again","hi","there"]
Is there anything like
test_sheet.add_row(a)
where I can all all contents of array arr to one row in the Test worksheet with each element of a in a separate cell?
Looks like there is no official way to do it. We use this code in our project:
row_index = sheet.sheet_data.rows.size
arr.each_with_index do |value, index|
sheet.add_cell(row_index, index, value)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With