# require "eitil_integrate/application_exporter/style_cells" require "eitil_integrate/application_exporter/initialize" module EitilIntegrate::RubyXL class ApplicationExporter COLOURS = { white: 'ffffff', black: '000000', red: 'FF0000', blue: '0000FF', green: '00FF00', yellow: 'FFFF00', cyan: '00FFFF', magenta: 'FF00FF', dark_grey: '464646', grey: '7E7E7E', light_grey: 'C1C1C1', eitje_blue: '0496FF' } private def style_file style_general style_custom end def style_general style_row_height style_column_width style_first_row_bold style_first_column_bold style_first_column_width end def style_custom %i[ style_first_x_columns_width style_x_columns_width style_first_x_rows_height style_x_rows_height ].each { |_method| safe_send _method } end # multi rows def style_row_height(height = 15) base_style_x_rows_height row_indices, height end def style_first_x_rows_height(n_rows, height) base_style_x_rows_height (0...n_rows), height end def style_x_rows_height(row_indices = [], height) row_indices.each { |i| @sheet.change_row_height(i, height) } end alias_method :base_style_x_rows_height, :style_x_rows_height # multi columns def style_column_width(width = 40) base_style_x_columns_width column_indices, width end def style_first_x_columns_width(n_columns, width) base_style_x_columns_width (0...n_columns), width end def style_first_column_width(width = 35) style_first_x_columns_width 1, width end alias_method :base_style_first_x_columns_width, :style_first_x_columns_width def style_x_columns_width(column_indices = [], width) column_indices.each { |i| @sheet.change_column_width(i, width) } end alias_method :base_style_x_columns_width, :style_x_columns_width # single row def style_first_row_bold style_row_bold first_row end def style_row_bold(row) @sheet.change_row_bold(row, true) end def style_row_font_colour(row, colour) @sheet.change_row_font_color row, COLOURS[colour.to_sym] end def style_row_background_colour(row, colour) sheet[row].cells.each { |cell| cell.change_fill COLOURS[colour.to_sym] } end # single column def style_first_column_bold style_column_bold first_column end def style_column_bold(column) @sheet.change_column_bold(column, true) end end end