Class: CopyTunerIncompatibleSearch::XlsxWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/copy_tuner_incompatible_search/xlsx_writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(results, incompatible_keys, ignored_keys) ⇒ XlsxWriter

Returns a new instance of XlsxWriter.



5
6
7
8
9
# File 'lib/copy_tuner_incompatible_search/xlsx_writer.rb', line 5

def initialize(results, incompatible_keys, ignored_keys)
  @results = results
  @incompatible_keys = incompatible_keys
  @ignored_keys = ignored_keys
end

Instance Method Details

#save_to(output_path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/copy_tuner_incompatible_search/xlsx_writer.rb', line 11

def save_to(output_path)
  Axlsx::Package.new do |pkg|
    pkg.workbook.add_worksheet(name: 'Data') do |sheet|
      style = sheet.styles.add_style(font_name: 'Courier New', sz: 14)
      sheet.add_row %w[Type Key Ignored File Line Code], style: style
      sheet.auto_filter = 'A1:F1'
      freeze_pane(sheet)

      results.each do |result|
        add_result_rows(sheet, result, style)
      end
    end
    pkg.serialize(output_path)
  end
end