Sha256: 2a4345da6fcfe8bd1bf184c0d7aa0d2336f09e7723ea776e6fa5efc8e213c9a2
Contents?: true
Size: 1.6 KB
Versions: 70
Compression:
Stored size: 1.6 KB
Contents
# require "eitil_integrate/application_exporter/write_cells" require "eitil_integrate/application_exporter/initialize" module EitilIntegrate::RubyXL class ApplicationExporter def new_row(row_hash) row_hash.each { |x_axis, title| @sheet.add_cell(x, x_axis.to_s.to_i, title) } @x += 1 end def empty_row @x += 1 end def empty_rows(n_rows) @x += n_rows end def new_column(column_hash) column_hash.each { |y_axis, title| @sheet.add_cell(y_axis.to_s.to_i, y, title) } @y += 1 end def empty_column @y += 1 end def empty_columns(n_columns) @y += n_columns end def rows @sheet.sheet_data.rows end def row_indices (0...rows.count).to_a end def columns # RubyXl does not seem to be purposed around columns, but merely handle rows properly. end def column_indices n_rows = rows.map { |r| r&.cells&.count }.compact.max #temporary hack (0...n_rows).to_a end def array_to_row(array) new_row array_to_indexed_hash(array) end def row_values(row_index) rows.dig(row_index).cells.map &:value end def column_values(column_index) rows.map { |row| row&.cells&.dig(column_index)&.value } end def all_column_values column_indices.map { |i| { i => column_values(i) } }.inject &:merge end def all_row_values row_indices.map { |i| { i => row_values(i) } }.inject &:merge end def sum_row new_row EitilIntegrate::RubyXL::AutoSum.perform(all_column_values) style_row_bold previous_row end end end
Version data entries
70 entries across 70 versions & 1 rubygems