class Reports::OfflineExporter::Row
Attributes
Public Class Methods
Source
# File app/lib/reports/offline_exporter.rb, line 543 def initialize(columns, style: {}) @columns = columns @row_style = style @cells = columns.map { Cell.new } yield self if block_given? end
Public Instance Methods
Source
# File app/lib/reports/offline_exporter.rb, line 550 def []=(column, value) index = columns.index(column) raise "Column #{column} not in row." if index.nil? @cells[index] = (value.is_a?(Cell) ? value : Cell.new(value)) end
Source
# File app/lib/reports/offline_exporter.rb, line 557 def add_to(sheet:, cached_styles:) row_index = sheet.rows.count values = cells.map(&:value) types = cells.map(&:type) style = cells.map { cached_styles.find_or_create(row_style.merge(_1.style)) } sheet.add_row(values, types:, style:) cells.each_with_index do |cell, column_index| cell.add_data_validation_to(sheet:, row_index:, column_index:) end end