Modify specific cell value using Axlsx gem given the column number and row numer

StackOverflow https://stackoverflow.com/questions/18178196

  •  24-06-2022
  •  | 
  •  

سؤال

I am trying to use asxlx gem to write an excel sheet but I have failed miserably trying to access individual cell values..

For example for do I get the value of the cell 2 in column 2

How do I change the value of cell 10 in column 19 ??

هل كانت مفيدة؟

المحلول

You should be able to access the value of any given cell via standard index references.

A trivial example:

p = Axlsx::Package.new
ws = p.workbook.add_worksheet
ws.add_row [1, 2, 3, 4]

ws.rows[0].cells[1].value = 5

would set the value of the second cell in the first row to 5

Please note, however that axlsx is a sparse generator. You cannot arbitrarily set the value for a cell that has not been added to the sheet via add_row.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top