htot_conv 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +135 -135
- data/.travis.yml +12 -12
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +138 -138
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/exe/htot_conv +8 -8
- data/htot_conv.gemspec +37 -37
- data/lib/htot_conv/cli.rb +174 -160
- data/lib/htot_conv/generator/base.rb +35 -35
- data/lib/htot_conv/generator/xlsx_type0.rb +24 -24
- data/lib/htot_conv/generator/xlsx_type1.rb +69 -69
- data/lib/htot_conv/generator/xlsx_type2.rb +104 -104
- data/lib/htot_conv/generator/xlsx_type3.rb +85 -85
- data/lib/htot_conv/generator/xlsx_type4.rb +84 -84
- data/lib/htot_conv/generator/xlsx_type5.rb +62 -62
- data/lib/htot_conv/generator.rb +30 -30
- data/lib/htot_conv/outline.rb +176 -176
- data/lib/htot_conv/parser/base.rb +15 -15
- data/lib/htot_conv/parser/dir_tree.rb +54 -54
- data/lib/htot_conv/parser/html_list.rb +71 -71
- data/lib/htot_conv/parser/opml.rb +70 -70
- data/lib/htot_conv/parser/simple_text.rb +70 -70
- data/lib/htot_conv/parser.rb +27 -27
- data/lib/htot_conv/util.rb +13 -13
- data/lib/htot_conv/version.rb +4 -4
- data/lib/htot_conv.rb +20 -20
- metadata +3 -3
@@ -1,69 +1,69 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'axlsx'
|
4
|
-
|
5
|
-
require 'htot_conv/generator/base'
|
6
|
-
|
7
|
-
module HTOTConv
|
8
|
-
module Generator
|
9
|
-
class XlsxType1 < XlsxBase
|
10
|
-
def self.option_help
|
11
|
-
{
|
12
|
-
:outline_rows => {
|
13
|
-
:default => false,
|
14
|
-
:pat => FalseClass,
|
15
|
-
:desc => "group rows (default: no)",
|
16
|
-
},
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def output_to_worksheet(ws)
|
21
|
-
max_value_length = @data.max_value_length
|
22
|
-
|
23
|
-
ws.add_row([@data.key_header[0]].concat(
|
24
|
-
HTOTConv::Util.pad_array(@data.value_header, max_value_length)),
|
25
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
26
|
-
|
27
|
-
@data.item.each do |item|
|
28
|
-
ws.add_row([item.key].concat(
|
29
|
-
HTOTConv::Util.pad_array(item.value, max_value_length)),
|
30
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
31
|
-
end
|
32
|
-
|
33
|
-
if @option[:outline_rows]
|
34
|
-
max_level = @data.max_level
|
35
|
-
outline_begin = Array.new(max_level, nil)
|
36
|
-
dummy_end_item = HTOTConv::Outline::Item.new(nil, 1, nil)
|
37
|
-
@data.item.concat([dummy_end_item]).each_with_index do |item, item_index|
|
38
|
-
(item.level..max_level).each do |level|
|
39
|
-
if outline_begin[level - 1]
|
40
|
-
if outline_begin[level - 1] < item_index - 1
|
41
|
-
ws.outline_level_rows((outline_begin[level - 1] + 1) + 1, (item_index - 1) + 1, level, false)
|
42
|
-
end
|
43
|
-
outline_begin[level - 1] = nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
outline_begin[item.level - 1] = item_index
|
47
|
-
end
|
48
|
-
|
49
|
-
# PR randym/axlsx#440 has been added to master branch
|
50
|
-
# https://github.com/randym/axlsx/commit/c80c8b9d9be5542471d66afcc2ce4ddd80cac1f7
|
51
|
-
# but latest release on rubygems does not contain this.
|
52
|
-
# So apply monkey patch to ws.sheet_pr.
|
53
|
-
if defined? ws.sheet_pr.outline_pr
|
54
|
-
ws.sheet_pr.outline_pr.summary_below = false
|
55
|
-
else
|
56
|
-
class << ws.sheet_pr # monkey patch
|
57
|
-
def to_xml_string(str="".dup)
|
58
|
-
tmp_str = "".dup
|
59
|
-
super(tmp_str)
|
60
|
-
str << tmp_str.sub('<pageSetUpPr', '<outlinePr summaryBelow="0" /><pageSetUpPr')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'axlsx'
|
4
|
+
|
5
|
+
require 'htot_conv/generator/base'
|
6
|
+
|
7
|
+
module HTOTConv
|
8
|
+
module Generator
|
9
|
+
class XlsxType1 < XlsxBase
|
10
|
+
def self.option_help
|
11
|
+
{
|
12
|
+
:outline_rows => {
|
13
|
+
:default => false,
|
14
|
+
:pat => FalseClass,
|
15
|
+
:desc => "group rows (default: no)",
|
16
|
+
},
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def output_to_worksheet(ws)
|
21
|
+
max_value_length = @data.max_value_length
|
22
|
+
|
23
|
+
ws.add_row([@data.key_header[0]].concat(
|
24
|
+
HTOTConv::Util.pad_array(@data.value_header, max_value_length)),
|
25
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
26
|
+
|
27
|
+
@data.item.each do |item|
|
28
|
+
ws.add_row([item.key].concat(
|
29
|
+
HTOTConv::Util.pad_array(item.value, max_value_length)),
|
30
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
31
|
+
end
|
32
|
+
|
33
|
+
if @option[:outline_rows]
|
34
|
+
max_level = @data.max_level
|
35
|
+
outline_begin = Array.new(max_level, nil)
|
36
|
+
dummy_end_item = HTOTConv::Outline::Item.new(nil, 1, nil)
|
37
|
+
@data.item.concat([dummy_end_item]).each_with_index do |item, item_index|
|
38
|
+
(item.level..max_level).each do |level|
|
39
|
+
if outline_begin[level - 1]
|
40
|
+
if outline_begin[level - 1] < item_index - 1
|
41
|
+
ws.outline_level_rows((outline_begin[level - 1] + 1) + 1, (item_index - 1) + 1, level, false)
|
42
|
+
end
|
43
|
+
outline_begin[level - 1] = nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
outline_begin[item.level - 1] = item_index
|
47
|
+
end
|
48
|
+
|
49
|
+
# PR randym/axlsx#440 has been added to master branch
|
50
|
+
# https://github.com/randym/axlsx/commit/c80c8b9d9be5542471d66afcc2ce4ddd80cac1f7
|
51
|
+
# but latest release on rubygems does not contain this.
|
52
|
+
# So apply monkey patch to ws.sheet_pr.
|
53
|
+
if defined? ws.sheet_pr.outline_pr
|
54
|
+
ws.sheet_pr.outline_pr.summary_below = false
|
55
|
+
else
|
56
|
+
class << ws.sheet_pr # monkey patch
|
57
|
+
def to_xml_string(str="".dup)
|
58
|
+
tmp_str = "".dup
|
59
|
+
super(tmp_str)
|
60
|
+
str << tmp_str.sub('<pageSetUpPr', '<outlinePr summaryBelow="0" /><pageSetUpPr')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -1,104 +1,104 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'axlsx'
|
3
|
-
|
4
|
-
require 'htot_conv/generator/base'
|
5
|
-
|
6
|
-
module HTOTConv
|
7
|
-
module Generator
|
8
|
-
class XlsxType2 < XlsxBase
|
9
|
-
def self.option_help
|
10
|
-
{
|
11
|
-
:integrate_cells => {
|
12
|
-
:default => nil,
|
13
|
-
:pat => [:colspan, :rowspan],
|
14
|
-
:desc => "integrate key cells (specify 'colspan' or 'rowspan')",
|
15
|
-
},
|
16
|
-
:outline_rows => {
|
17
|
-
:default => false,
|
18
|
-
:pat => FalseClass,
|
19
|
-
:desc => "group rows (default: no)",
|
20
|
-
},
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def output_to_worksheet(ws)
|
25
|
-
max_level = @data.max_level
|
26
|
-
max_value_length = @data.max_value_length
|
27
|
-
|
28
|
-
ws.add_row(((1..max_level).map {|l| @data.key_header[l - 1] || nil }).concat(
|
29
|
-
HTOTConv::Util.pad_array(@data.value_header, max_value_length)),
|
30
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
31
|
-
|
32
|
-
@data.item.each_with_index do |item, item_index|
|
33
|
-
key_cell = Array.new(max_level, nil)
|
34
|
-
key_cell[item.level - 1] = item.key
|
35
|
-
value_cell = HTOTConv::Util.pad_array(item.value, max_value_length)
|
36
|
-
|
37
|
-
ws.add_row(key_cell.concat(value_cell),
|
38
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
39
|
-
|
40
|
-
(1..max_level).each do |level|
|
41
|
-
edges = []
|
42
|
-
edges << :left if (level <= item.level)
|
43
|
-
edges << :right if ((level < item.level) || (level == max_level))
|
44
|
-
edges << :top if ((level >= item.level) || (item_index == 0))
|
45
|
-
edges << :bottom if ((level > item.level) || (item_index == @data.item.length - 1))
|
46
|
-
ws.rows.last.cells[level - 1].style = ws.styles.add_style(
|
47
|
-
:border => { :style => :thin, :color => "00", :edges => edges })
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
if @option[:outline_rows]
|
52
|
-
outline_begin = Array.new(max_level, nil)
|
53
|
-
dummy_end_item = HTOTConv::Outline::Item.new(nil, 1, nil)
|
54
|
-
@data.item.concat([dummy_end_item]).each_with_index do |item, item_index|
|
55
|
-
(item.level..max_level).each do |level|
|
56
|
-
if outline_begin[level - 1]
|
57
|
-
if outline_begin[level - 1] < item_index - 1
|
58
|
-
ws.outline_level_rows((outline_begin[level - 1] + 1) + 1, (item_index - 1) + 1, level, false)
|
59
|
-
end
|
60
|
-
outline_begin[level - 1] = nil
|
61
|
-
end
|
62
|
-
end
|
63
|
-
outline_begin[item.level - 1] = item_index
|
64
|
-
end
|
65
|
-
|
66
|
-
# PR randym/axlsx#440 has been added to master branch
|
67
|
-
# https://github.com/randym/axlsx/commit/c80c8b9d9be5542471d66afcc2ce4ddd80cac1f7
|
68
|
-
# but latest release on rubygems does not contain this.
|
69
|
-
# So apply monkey patch to ws.sheet_pr.
|
70
|
-
if defined? ws.sheet_pr.outline_pr
|
71
|
-
ws.sheet_pr.outline_pr.summary_below = false
|
72
|
-
else
|
73
|
-
class << ws.sheet_pr # monkey patch
|
74
|
-
def to_xml_string(str="".dup)
|
75
|
-
tmp_str = "".dup
|
76
|
-
super(tmp_str)
|
77
|
-
str << tmp_str.sub('<pageSetUpPr', '<outlinePr summaryBelow="0" /><pageSetUpPr')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
case @option[:integrate_cells]
|
84
|
-
when :colspan
|
85
|
-
@data.item.each_with_index do |item, item_index|
|
86
|
-
if item.level < max_level
|
87
|
-
ws.merge_cells(ws.rows[item_index + 1].cells[((item.level - 1)..(max_level - 1))])
|
88
|
-
end
|
89
|
-
end
|
90
|
-
when :rowspan
|
91
|
-
@data.item.each_with_index do |item, item_index|
|
92
|
-
cells = [ws.rows[item_index + 1].cells[item.level - 1]]
|
93
|
-
((item_index + 1)..(@data.item.length - 1)).each do |i|
|
94
|
-
break if @data.item[i].level <= item.level
|
95
|
-
cells << ws.rows[i + 1].cells[item.level - 1]
|
96
|
-
end
|
97
|
-
|
98
|
-
ws.merge_cells(cells) if cells.length > 1
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'axlsx'
|
3
|
+
|
4
|
+
require 'htot_conv/generator/base'
|
5
|
+
|
6
|
+
module HTOTConv
|
7
|
+
module Generator
|
8
|
+
class XlsxType2 < XlsxBase
|
9
|
+
def self.option_help
|
10
|
+
{
|
11
|
+
:integrate_cells => {
|
12
|
+
:default => nil,
|
13
|
+
:pat => [:colspan, :rowspan],
|
14
|
+
:desc => "integrate key cells (specify 'colspan' or 'rowspan')",
|
15
|
+
},
|
16
|
+
:outline_rows => {
|
17
|
+
:default => false,
|
18
|
+
:pat => FalseClass,
|
19
|
+
:desc => "group rows (default: no)",
|
20
|
+
},
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def output_to_worksheet(ws)
|
25
|
+
max_level = @data.max_level
|
26
|
+
max_value_length = @data.max_value_length
|
27
|
+
|
28
|
+
ws.add_row(((1..max_level).map {|l| @data.key_header[l - 1] || nil }).concat(
|
29
|
+
HTOTConv::Util.pad_array(@data.value_header, max_value_length)),
|
30
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
31
|
+
|
32
|
+
@data.item.each_with_index do |item, item_index|
|
33
|
+
key_cell = Array.new(max_level, nil)
|
34
|
+
key_cell[item.level - 1] = item.key
|
35
|
+
value_cell = HTOTConv::Util.pad_array(item.value, max_value_length)
|
36
|
+
|
37
|
+
ws.add_row(key_cell.concat(value_cell),
|
38
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
39
|
+
|
40
|
+
(1..max_level).each do |level|
|
41
|
+
edges = []
|
42
|
+
edges << :left if (level <= item.level)
|
43
|
+
edges << :right if ((level < item.level) || (level == max_level))
|
44
|
+
edges << :top if ((level >= item.level) || (item_index == 0))
|
45
|
+
edges << :bottom if ((level > item.level) || (item_index == @data.item.length - 1))
|
46
|
+
ws.rows.last.cells[level - 1].style = ws.styles.add_style(
|
47
|
+
:border => { :style => :thin, :color => "00", :edges => edges })
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if @option[:outline_rows]
|
52
|
+
outline_begin = Array.new(max_level, nil)
|
53
|
+
dummy_end_item = HTOTConv::Outline::Item.new(nil, 1, nil)
|
54
|
+
@data.item.concat([dummy_end_item]).each_with_index do |item, item_index|
|
55
|
+
(item.level..max_level).each do |level|
|
56
|
+
if outline_begin[level - 1]
|
57
|
+
if outline_begin[level - 1] < item_index - 1
|
58
|
+
ws.outline_level_rows((outline_begin[level - 1] + 1) + 1, (item_index - 1) + 1, level, false)
|
59
|
+
end
|
60
|
+
outline_begin[level - 1] = nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
outline_begin[item.level - 1] = item_index
|
64
|
+
end
|
65
|
+
|
66
|
+
# PR randym/axlsx#440 has been added to master branch
|
67
|
+
# https://github.com/randym/axlsx/commit/c80c8b9d9be5542471d66afcc2ce4ddd80cac1f7
|
68
|
+
# but latest release on rubygems does not contain this.
|
69
|
+
# So apply monkey patch to ws.sheet_pr.
|
70
|
+
if defined? ws.sheet_pr.outline_pr
|
71
|
+
ws.sheet_pr.outline_pr.summary_below = false
|
72
|
+
else
|
73
|
+
class << ws.sheet_pr # monkey patch
|
74
|
+
def to_xml_string(str="".dup)
|
75
|
+
tmp_str = "".dup
|
76
|
+
super(tmp_str)
|
77
|
+
str << tmp_str.sub('<pageSetUpPr', '<outlinePr summaryBelow="0" /><pageSetUpPr')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
case @option[:integrate_cells]
|
84
|
+
when :colspan
|
85
|
+
@data.item.each_with_index do |item, item_index|
|
86
|
+
if item.level < max_level
|
87
|
+
ws.merge_cells(ws.rows[item_index + 1].cells[((item.level - 1)..(max_level - 1))])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
when :rowspan
|
91
|
+
@data.item.each_with_index do |item, item_index|
|
92
|
+
cells = [ws.rows[item_index + 1].cells[item.level - 1]]
|
93
|
+
((item_index + 1)..(@data.item.length - 1)).each do |i|
|
94
|
+
break if @data.item[i].level <= item.level
|
95
|
+
cells << ws.rows[i + 1].cells[item.level - 1]
|
96
|
+
end
|
97
|
+
|
98
|
+
ws.merge_cells(cells) if cells.length > 1
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'axlsx'
|
3
|
-
|
4
|
-
require 'htot_conv/generator/base'
|
5
|
-
|
6
|
-
module HTOTConv
|
7
|
-
module Generator
|
8
|
-
class XlsxType3 < XlsxBase
|
9
|
-
def self.option_help
|
10
|
-
{
|
11
|
-
:integrate_cells => {
|
12
|
-
:default => nil,
|
13
|
-
:pat => [:colspan, :rowspan, :both],
|
14
|
-
:desc => "integrate key cells (specify 'colspan', 'rowspan' or 'both')",
|
15
|
-
},
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def output_to_worksheet(ws)
|
20
|
-
max_level = @data.max_level
|
21
|
-
max_value_length = @data.max_value_length
|
22
|
-
|
23
|
-
ws.add_row([
|
24
|
-
@data.key_header[0],
|
25
|
-
*(HTOTConv::Util.pad_array([@data.value_header[0]], max_level)),
|
26
|
-
*(HTOTConv::Util.pad_array(
|
27
|
-
(@data.value_header.length <= 1)? [] : @data.value_header.last(@data.value_header.length - 1),
|
28
|
-
[max_value_length - 1, 0].max)),
|
29
|
-
], :style => Axlsx::STYLE_THIN_BORDER)
|
30
|
-
1.upto(max_level) do |col_idx|
|
31
|
-
edges = [:top, :bottom]
|
32
|
-
edges << :left if (col_idx <= 1)
|
33
|
-
edges << :right if (col_idx >= max_level)
|
34
|
-
ws.rows.last.cells[col_idx].style = ws.styles.add_style(
|
35
|
-
:border => { :style => :thin, :color => "00", :edges => edges })
|
36
|
-
end
|
37
|
-
|
38
|
-
@data.item.each_with_index do |item, item_index|
|
39
|
-
key_value_cell = Array.new(max_level + 1, nil)
|
40
|
-
key_value_cell[item.level - 1] = item.key
|
41
|
-
key_value_cell[item.level ] = item.value[0]
|
42
|
-
rest_value_cell = HTOTConv::Util.pad_array(
|
43
|
-
(item.value.length <= 1)? [] : item.value.last(item.value.length - 1),
|
44
|
-
[max_value_length - 1, 0].max)
|
45
|
-
|
46
|
-
ws.add_row(key_value_cell.concat(rest_value_cell),
|
47
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
48
|
-
|
49
|
-
0.upto(max_level) do |col_idx|
|
50
|
-
edges = []
|
51
|
-
|
52
|
-
edges << :left if (col_idx <= item.level)
|
53
|
-
edges << :right if ((col_idx < item.level) || (col_idx >= max_level))
|
54
|
-
edges << :top if ((col_idx > (item.level - 2)) || (item_index == 0))
|
55
|
-
edges << :bottom if ((col_idx > (item.level - 1)) || (item_index == @data.item.length - 1))
|
56
|
-
ws.rows.last.cells[col_idx].style = ws.styles.add_style(
|
57
|
-
:border => { :style => :thin, :color => "00", :edges => edges })
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
if [:colspan, :both].include?(@option[:integrate_cells])
|
62
|
-
if max_level > 1
|
63
|
-
ws.merge_cells(ws.rows[0].cells[1..(max_level)])
|
64
|
-
end
|
65
|
-
@data.item.each_with_index do |item, item_index|
|
66
|
-
if item.level < max_level
|
67
|
-
ws.merge_cells(ws.rows[item_index + 1].cells[(item.level..max_level)])
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
if [:rowspan, :both].include?(@option[:integrate_cells])
|
72
|
-
@data.item.each_with_index do |item, item_index|
|
73
|
-
cells = [ws.rows[item_index + 1].cells[item.level - 1]]
|
74
|
-
((item_index + 1)..(@data.item.length - 1)).each do |i|
|
75
|
-
break if @data.item[i].level <= item.level
|
76
|
-
cells << ws.rows[i + 1].cells[item.level - 1]
|
77
|
-
end
|
78
|
-
|
79
|
-
ws.merge_cells(cells) if cells.length > 1
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'axlsx'
|
3
|
+
|
4
|
+
require 'htot_conv/generator/base'
|
5
|
+
|
6
|
+
module HTOTConv
|
7
|
+
module Generator
|
8
|
+
class XlsxType3 < XlsxBase
|
9
|
+
def self.option_help
|
10
|
+
{
|
11
|
+
:integrate_cells => {
|
12
|
+
:default => nil,
|
13
|
+
:pat => [:colspan, :rowspan, :both],
|
14
|
+
:desc => "integrate key cells (specify 'colspan', 'rowspan' or 'both')",
|
15
|
+
},
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def output_to_worksheet(ws)
|
20
|
+
max_level = @data.max_level
|
21
|
+
max_value_length = @data.max_value_length
|
22
|
+
|
23
|
+
ws.add_row([
|
24
|
+
@data.key_header[0],
|
25
|
+
*(HTOTConv::Util.pad_array([@data.value_header[0]], max_level)),
|
26
|
+
*(HTOTConv::Util.pad_array(
|
27
|
+
(@data.value_header.length <= 1)? [] : @data.value_header.last(@data.value_header.length - 1),
|
28
|
+
[max_value_length - 1, 0].max)),
|
29
|
+
], :style => Axlsx::STYLE_THIN_BORDER)
|
30
|
+
1.upto(max_level) do |col_idx|
|
31
|
+
edges = [:top, :bottom]
|
32
|
+
edges << :left if (col_idx <= 1)
|
33
|
+
edges << :right if (col_idx >= max_level)
|
34
|
+
ws.rows.last.cells[col_idx].style = ws.styles.add_style(
|
35
|
+
:border => { :style => :thin, :color => "00", :edges => edges })
|
36
|
+
end
|
37
|
+
|
38
|
+
@data.item.each_with_index do |item, item_index|
|
39
|
+
key_value_cell = Array.new(max_level + 1, nil)
|
40
|
+
key_value_cell[item.level - 1] = item.key
|
41
|
+
key_value_cell[item.level ] = item.value[0]
|
42
|
+
rest_value_cell = HTOTConv::Util.pad_array(
|
43
|
+
(item.value.length <= 1)? [] : item.value.last(item.value.length - 1),
|
44
|
+
[max_value_length - 1, 0].max)
|
45
|
+
|
46
|
+
ws.add_row(key_value_cell.concat(rest_value_cell),
|
47
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
48
|
+
|
49
|
+
0.upto(max_level) do |col_idx|
|
50
|
+
edges = []
|
51
|
+
|
52
|
+
edges << :left if (col_idx <= item.level)
|
53
|
+
edges << :right if ((col_idx < item.level) || (col_idx >= max_level))
|
54
|
+
edges << :top if ((col_idx > (item.level - 2)) || (item_index == 0))
|
55
|
+
edges << :bottom if ((col_idx > (item.level - 1)) || (item_index == @data.item.length - 1))
|
56
|
+
ws.rows.last.cells[col_idx].style = ws.styles.add_style(
|
57
|
+
:border => { :style => :thin, :color => "00", :edges => edges })
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if [:colspan, :both].include?(@option[:integrate_cells])
|
62
|
+
if max_level > 1
|
63
|
+
ws.merge_cells(ws.rows[0].cells[1..(max_level)])
|
64
|
+
end
|
65
|
+
@data.item.each_with_index do |item, item_index|
|
66
|
+
if item.level < max_level
|
67
|
+
ws.merge_cells(ws.rows[item_index + 1].cells[(item.level..max_level)])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if [:rowspan, :both].include?(@option[:integrate_cells])
|
72
|
+
@data.item.each_with_index do |item, item_index|
|
73
|
+
cells = [ws.rows[item_index + 1].cells[item.level - 1]]
|
74
|
+
((item_index + 1)..(@data.item.length - 1)).each do |i|
|
75
|
+
break if @data.item[i].level <= item.level
|
76
|
+
cells << ws.rows[i + 1].cells[item.level - 1]
|
77
|
+
end
|
78
|
+
|
79
|
+
ws.merge_cells(cells) if cells.length > 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|