Class: HTOTConv::Generator::XlsxType0

Inherits:
XlsxBase show all
Defined in:
lib/htot_conv/generator/xlsx_type0.rb

Instance Method Summary collapse

Methods inherited from XlsxBase

option_help, #output

Methods inherited from Base

#initialize, option_help, #output

Constructor Details

This class inherits a constructor from HTOTConv::Generator::Base

Instance Method Details

#output_to_worksheet(ws) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/htot_conv/generator/xlsx_type0.rb', line 8

def output_to_worksheet(ws)
  row_index = 0
  max_value_length = @data.max_value_length

  [@data.key_header[0], 'Outline Level'].concat(
    HTOTConv::Util.pad_array(@data.value_header, max_value_length)
  ).each_with_index do |v, col_index|
    ws.add_cell(row_index, col_index, v)
    [:top, :bottom, :left, :right].each do |edge|
      ws[row_index][col_index].change_border(edge, "thin")
    end
  end
  row_index = row_index.succ

  @data.item.each do |item|
    [item.key, item.level.to_i].concat(
      HTOTConv::Util.pad_array(item.value, max_value_length)
    ).each_with_index do |v, col_index|
      ws.add_cell(row_index, col_index, v)
      [:top, :bottom, :left, :right].each do |edge|
        ws[row_index][col_index].change_border(edge, "thin")
      end
    end
    row_index = row_index.succ
  end
end