axlsx 2.0.1 → 2.1.0.pre
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/README.md +6 -3
- data/Rakefile +9 -10
- data/examples/IMAGE1UP.JPEG +0 -0
- data/examples/auto_filter.rb +10 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +3 -3
- data/examples/example.rb +72 -4
- data/examples/merge_cells.rb +17 -0
- data/examples/no_grid_with_borders.rb +18 -0
- data/examples/pivot_test.rb +63 -0
- data/examples/split.rb +16 -0
- data/lib/axlsx.rb +30 -16
- data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +5 -5
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +12 -9
- data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
- data/lib/axlsx/drawing/bar_series.rb +9 -9
- data/lib/axlsx/drawing/bubble_chart.rb +59 -0
- data/lib/axlsx/drawing/bubble_series.rb +63 -0
- data/lib/axlsx/drawing/cat_axis.rb +5 -5
- data/lib/axlsx/drawing/chart.rb +44 -7
- data/lib/axlsx/drawing/drawing.rb +3 -1
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +1 -3
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/line_chart.rb +10 -10
- data/lib/axlsx/drawing/line_series.rb +14 -2
- data/lib/axlsx/drawing/marker.rb +1 -1
- data/lib/axlsx/drawing/num_data.rb +4 -4
- data/lib/axlsx/drawing/num_data_source.rb +6 -6
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/pic.rb +2 -3
- data/lib/axlsx/drawing/picture_locking.rb +1 -3
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
- data/lib/axlsx/drawing/pie_series.rb +6 -6
- data/lib/axlsx/drawing/scaling.rb +4 -4
- data/lib/axlsx/drawing/scatter_chart.rb +10 -10
- data/lib/axlsx/drawing/scatter_series.rb +26 -7
- data/lib/axlsx/drawing/ser_axis.rb +2 -2
- data/lib/axlsx/drawing/series.rb +3 -3
- data/lib/axlsx/drawing/series_title.rb +2 -2
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +1 -1
- data/lib/axlsx/drawing/title.rb +3 -3
- data/lib/axlsx/drawing/val_axis.rb +1 -1
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +39 -28
- data/lib/axlsx/rels/relationship.rb +1 -1
- data/lib/axlsx/rels/relationships.rb +2 -2
- data/lib/axlsx/stylesheet/border_pr.rb +2 -2
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
- data/lib/axlsx/stylesheet/cell_style.rb +1 -3
- data/lib/axlsx/stylesheet/color.rb +1 -3
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -3
- data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +6 -6
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/constants.rb +106 -101
- data/lib/axlsx/util/options_parser.rb +2 -1
- data/lib/axlsx/util/parser.rb +4 -4
- data/lib/axlsx/util/serialized_attributes.rb +16 -6
- data/lib/axlsx/util/simple_typed_list.rb +28 -52
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/string.rb +7 -0
- data/lib/axlsx/util/validators.rb +20 -13
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +11 -12
- data/lib/axlsx/workbook/defined_names.rb +2 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
- data/lib/axlsx/workbook/workbook.rb +19 -12
- data/lib/axlsx/workbook/workbook_view.rb +78 -0
- data/lib/axlsx/workbook/workbook_views.rb +22 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
- data/lib/axlsx/workbook/worksheet/break.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +128 -73
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +50 -40
- data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +7 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
- data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
- data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
- data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +17 -24
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
- data/lib/axlsx/workbook/worksheet/rich_text.rb +35 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +254 -0
- data/lib/axlsx/workbook/worksheet/row.rb +33 -51
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/table.rb +6 -6
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +59 -30
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
- data/test/drawing/tc_axis.rb +27 -0
- data/test/drawing/tc_bubble_chart.rb +44 -0
- data/test/drawing/tc_bubble_series.rb +21 -0
- data/test/drawing/tc_data_source.rb +6 -0
- data/test/drawing/tc_line_chart.rb +5 -5
- data/test/drawing/tc_line_series.rb +10 -2
- data/test/drawing/tc_pic.rb +4 -0
- data/test/drawing/tc_scatter_series.rb +25 -1
- data/test/tc_helper.rb +1 -1
- data/test/tc_package.rb +7 -1
- data/test/util/tc_simple_typed_list.rb +1 -2
- data/test/workbook/tc_defined_name.rb +12 -4
- data/test/workbook/tc_workbook.rb +16 -2
- data/test/workbook/tc_workbook_view.rb +50 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
- data/test/workbook/worksheet/tc_break.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +30 -4
- data/test/workbook/worksheet/tc_col.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +11 -11
- data/test/workbook/worksheet/tc_header_footer.rb +2 -2
- data/test/workbook/worksheet/tc_icon_set.rb +1 -1
- data/test/workbook/worksheet/tc_page_setup.rb +3 -3
- data/test/workbook/worksheet/tc_print_options.rb +1 -1
- data/test/workbook/worksheet/tc_rich_text.rb +44 -0
- data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
- data/test/workbook/worksheet/tc_row.rb +2 -2
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
- data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
- data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
- data/test/workbook/worksheet/tc_worksheet.rb +49 -10
- metadata +81 -55
- data/test/axlsx.qcachegrind +0 -2226
|
@@ -3,43 +3,32 @@ module Axlsx
|
|
|
3
3
|
# The Cell Serializer class contains the logic for serializing cells based on their type.
|
|
4
4
|
class CellSerializer
|
|
5
5
|
class << self
|
|
6
|
-
|
|
7
|
-
|
|
8
6
|
# Calls the proper serialization method based on type.
|
|
9
7
|
# @param [Integer] row_index The index of the cell's row
|
|
10
8
|
# @param [Integer] column_index The index of the cell's column
|
|
11
9
|
# @param [String] str The string to apend serialization to.
|
|
12
10
|
# @return [String]
|
|
13
11
|
def to_xml_string(row_index, column_index, cell, str='')
|
|
14
|
-
str << '<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" '
|
|
12
|
+
str << ('<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ')
|
|
15
13
|
return str << '/>' if cell.value.nil?
|
|
16
|
-
method =
|
|
14
|
+
method = cell.type
|
|
17
15
|
self.send(method, cell, str)
|
|
18
16
|
str << '</c>'
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
|
|
22
19
|
# builds an xml text run based on this cells attributes.
|
|
23
20
|
# @param [String] str The string instance this run will be concated to.
|
|
24
21
|
# @return [String]
|
|
25
22
|
def run_xml_string(cell, str = '')
|
|
26
23
|
if cell.is_text_run?
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
str << "<rFont val='"<< cell.font_name << "'/>"
|
|
34
|
-
when 'color'
|
|
35
|
-
str << data[key].to_xml_string
|
|
36
|
-
else
|
|
37
|
-
str << "<" << key.to_s << " val='" << data[key].to_s << "'/>"
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
str << "</rPr>" << "<t>" << cell.value.to_s << "</t></r>"
|
|
24
|
+
valid = RichTextRun::INLINE_STYLES - [:value, :type]
|
|
25
|
+
data = Hash[cell.instance_values.map{ |k, v| [k.to_sym, v] }]
|
|
26
|
+
data = data.select { |key, value| valid.include?(key) && !value.nil? }
|
|
27
|
+
RichText.new(cell.value.to_s, data).to_xml_string(str)
|
|
28
|
+
elsif cell.contains_rich_text?
|
|
29
|
+
cell.value.to_xml_string(str)
|
|
41
30
|
else
|
|
42
|
-
str <<
|
|
31
|
+
str << ('<t>' << cell.clean_value << '</t>')
|
|
43
32
|
end
|
|
44
33
|
str
|
|
45
34
|
end
|
|
@@ -48,16 +37,15 @@ module Axlsx
|
|
|
48
37
|
# @param [Cell] cell The cell that is being serialized
|
|
49
38
|
# @param [String] str The string the serialized content will be appended to.
|
|
50
39
|
# @return [String]
|
|
51
|
-
def
|
|
40
|
+
def iso_8601(cell, str='')
|
|
52
41
|
value_serialization 'd', cell.value, str
|
|
53
42
|
end
|
|
54
43
|
|
|
55
|
-
|
|
56
44
|
# serializes cells that are type date
|
|
57
45
|
# @param [Cell] cell The cell that is being serialized
|
|
58
46
|
# @param [String] str The string the serialized content will be appended to.
|
|
59
47
|
# @return [String]
|
|
60
|
-
def
|
|
48
|
+
def date(cell, str='')
|
|
61
49
|
value_serialization false, DateTimeConverter::date_to_serial(cell.value).to_s, str
|
|
62
50
|
end
|
|
63
51
|
|
|
@@ -65,7 +53,7 @@ module Axlsx
|
|
|
65
53
|
# @param [Cell] cell The cell that is being serialized
|
|
66
54
|
# @param [String] str The string the serialized content will be appended to.
|
|
67
55
|
# @return [String]
|
|
68
|
-
def
|
|
56
|
+
def time(cell, str='')
|
|
69
57
|
value_serialization false, DateTimeConverter::time_to_serial(cell.value).to_s, str
|
|
70
58
|
end
|
|
71
59
|
|
|
@@ -73,7 +61,7 @@ module Axlsx
|
|
|
73
61
|
# @param [Cell] cell The cell that is being serialized
|
|
74
62
|
# @param [String] str The string the serialized content will be appended to.
|
|
75
63
|
# @return [String]
|
|
76
|
-
def
|
|
64
|
+
def boolean(cell, str='')
|
|
77
65
|
value_serialization 'b', cell.value.to_s, str
|
|
78
66
|
end
|
|
79
67
|
|
|
@@ -81,26 +69,34 @@ module Axlsx
|
|
|
81
69
|
# @param [Cell] cell The cell that is being serialized
|
|
82
70
|
# @param [String] str The string the serialized content will be appended to.
|
|
83
71
|
# @return [String]
|
|
84
|
-
def
|
|
85
|
-
|
|
72
|
+
def float(cell, str='')
|
|
73
|
+
numeric cell, str
|
|
86
74
|
end
|
|
87
75
|
|
|
88
76
|
# Serializes cells that are type integer
|
|
89
77
|
# @param [Cell] cell The cell that is being serialized
|
|
90
78
|
# @param [String] str The string the serialized content will be appended to.
|
|
91
79
|
# @return [String]
|
|
92
|
-
def
|
|
93
|
-
|
|
80
|
+
def integer(cell, str = '')
|
|
81
|
+
numeric cell, str
|
|
94
82
|
end
|
|
95
83
|
|
|
96
|
-
|
|
97
84
|
# Serializes cells that are type formula
|
|
98
85
|
# @param [Cell] cell The cell that is being serialized
|
|
99
86
|
# @param [String] str The string the serialized content will be appended to.
|
|
100
87
|
# @return [String]
|
|
101
88
|
def formula_serialization(cell, str='')
|
|
102
|
-
str << 't="str"
|
|
103
|
-
str << '<v>' << cell.formula_value.to_s << '</v>' unless cell.formula_value.nil?
|
|
89
|
+
str << ('t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>')
|
|
90
|
+
str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Serializes cells that are type array formula
|
|
94
|
+
# @param [Cell] cell The cell that is being serialized
|
|
95
|
+
# @param [String] str The string the serialized content will be appended to.
|
|
96
|
+
# @return [String]
|
|
97
|
+
def array_formula_serialization(cell, str='')
|
|
98
|
+
str << ('t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>')
|
|
99
|
+
str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
|
|
104
100
|
end
|
|
105
101
|
|
|
106
102
|
# Serializes cells that are type inline_string
|
|
@@ -108,7 +104,7 @@ module Axlsx
|
|
|
108
104
|
# @param [String] str The string the serialized content will be appended to.
|
|
109
105
|
# @return [String]
|
|
110
106
|
def inline_string_serialization(cell, str = '')
|
|
111
|
-
str << 't="inlineStr"
|
|
107
|
+
str << 't="inlineStr"><is>'
|
|
112
108
|
run_xml_string cell, str
|
|
113
109
|
str << '</is>'
|
|
114
110
|
end
|
|
@@ -117,25 +113,39 @@ module Axlsx
|
|
|
117
113
|
# @param [Cell] cell The cell that is being serialized
|
|
118
114
|
# @param [String] str The string the serialized content will be appended to.
|
|
119
115
|
# @return [String]
|
|
120
|
-
def
|
|
121
|
-
if cell.
|
|
116
|
+
def string(cell, str='')
|
|
117
|
+
if cell.is_array_formula?
|
|
118
|
+
array_formula_serialization cell, str
|
|
119
|
+
elsif cell.is_formula?
|
|
122
120
|
formula_serialization cell, str
|
|
123
121
|
elsif !cell.ssti.nil?
|
|
124
|
-
value_serialization 's', cell.ssti
|
|
122
|
+
value_serialization 's', cell.ssti, str
|
|
125
123
|
else
|
|
126
124
|
inline_string_serialization cell, str
|
|
127
125
|
end
|
|
128
126
|
end
|
|
127
|
+
|
|
128
|
+
# Serializes cells that are of the type richtext
|
|
129
|
+
# @param [Cell] cell The cell that is being serialized
|
|
130
|
+
# @param [String] str The string the serialized content will be appended to.
|
|
131
|
+
# @return [String]
|
|
132
|
+
def richtext(cell, str)
|
|
133
|
+
if cell.ssti.nil?
|
|
134
|
+
inline_string_serialization cell, str
|
|
135
|
+
else
|
|
136
|
+
value_serialization 's', cell.ssti, str
|
|
137
|
+
end
|
|
138
|
+
end
|
|
129
139
|
|
|
130
140
|
private
|
|
131
141
|
|
|
132
|
-
def
|
|
133
|
-
value_serialization 'n', cell.value
|
|
142
|
+
def numeric(cell, str = '')
|
|
143
|
+
value_serialization 'n', cell.value, str
|
|
134
144
|
end
|
|
135
145
|
|
|
136
146
|
def value_serialization(serialization_type, serialization_value, str = '')
|
|
137
|
-
str << 't="' << serialization_type << '"' if serialization_type
|
|
138
|
-
str << '><v>' << serialization_value << '</v>'
|
|
147
|
+
str << ('t="' << serialization_type.to_s << '"') if serialization_type
|
|
148
|
+
str << ('><v>' << serialization_value.to_s << '</v>')
|
|
139
149
|
end
|
|
140
150
|
|
|
141
151
|
|
|
@@ -122,22 +122,19 @@ module Axlsx
|
|
|
122
122
|
# @param [Boolean] use_autowidth If this is false, the cell's
|
|
123
123
|
# autowidth value will be ignored.
|
|
124
124
|
def update_width(cell, fixed_width=nil, use_autowidth=true)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
end
|
|
125
|
+
if fixed_width.is_a? Numeric
|
|
126
|
+
self.width = fixed_width
|
|
127
|
+
elsif use_autowidth
|
|
128
|
+
cell_width = cell.autowidth
|
|
129
|
+
self.width = cell_width unless (width || 0) > (cell_width || 0)
|
|
130
|
+
end
|
|
132
131
|
end
|
|
133
132
|
|
|
134
133
|
# Serialize this columns data to an xml string
|
|
135
134
|
# @param [String] str
|
|
136
135
|
# @return [String]
|
|
137
136
|
def to_xml_string(str = '')
|
|
138
|
-
|
|
139
|
-
serialized_attributes str
|
|
140
|
-
str << '/>'
|
|
137
|
+
serialized_tag('col', str)
|
|
141
138
|
end
|
|
142
139
|
|
|
143
140
|
end
|
|
@@ -16,7 +16,7 @@ module Axlsx
|
|
|
16
16
|
# Break will be passed to the created break object.
|
|
17
17
|
# @see Break
|
|
18
18
|
def add_break(options)
|
|
19
|
-
|
|
19
|
+
self << Break.new(options.merge(:max => 1048575, :man => true))
|
|
20
20
|
last
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@ module Axlsx
|
|
|
27
27
|
# </colBreaks>
|
|
28
28
|
def to_xml_string(str='')
|
|
29
29
|
return if empty?
|
|
30
|
-
str << '<colBreaks count="' <<
|
|
30
|
+
str << ('<colBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">')
|
|
31
31
|
each { |brk| brk.to_xml_string(str) }
|
|
32
32
|
str << '</colBreaks>'
|
|
33
33
|
end
|
|
@@ -24,11 +24,10 @@ module Axlsx
|
|
|
24
24
|
string_attr_accessor :text, :author
|
|
25
25
|
boolean_attr_accessor :visible
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
# The owning Comments object
|
|
28
28
|
# @return [Comments]
|
|
29
29
|
attr_reader :comments
|
|
30
30
|
|
|
31
|
-
|
|
32
31
|
# The string based cell position reference (e.g. 'A1') that determines the positioning of this comment
|
|
33
32
|
# @return [String|Cell]
|
|
34
33
|
attr_reader :ref
|
|
@@ -53,7 +52,7 @@ module Axlsx
|
|
|
53
52
|
|
|
54
53
|
# @see ref
|
|
55
54
|
def ref=(v)
|
|
56
|
-
Axlsx::DataTypeValidator.validate
|
|
55
|
+
Axlsx::DataTypeValidator.validate :comment_ref, [String, Cell], v
|
|
57
56
|
@ref = v if v.is_a?(String)
|
|
58
57
|
@ref = v.r if v.is_a?(Cell)
|
|
59
58
|
end
|
|
@@ -63,15 +62,15 @@ module Axlsx
|
|
|
63
62
|
# @return [String]
|
|
64
63
|
def to_xml_string(str = "")
|
|
65
64
|
author = @comments.authors[author_index]
|
|
66
|
-
str << '<comment ref="' << ref << '" authorId="' << author_index.to_s << '">'
|
|
65
|
+
str << ('<comment ref="' << ref << '" authorId="' << author_index.to_s << '">')
|
|
67
66
|
str << '<text>'
|
|
68
67
|
unless author.to_s == ""
|
|
69
68
|
str << '<r><rPr><b/><color indexed="81"/></rPr>'
|
|
70
|
-
str << "<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>"
|
|
69
|
+
str << ("<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>")
|
|
71
70
|
end
|
|
72
71
|
str << '<r>'
|
|
73
72
|
str << '<rPr><color indexed="81"/></rPr>'
|
|
74
|
-
str << '<t>' << ::CGI.escapeHTML(text) << '</t></r></text>'
|
|
73
|
+
str << ('<t>' << ::CGI.escapeHTML(text) << '</t></r></text>')
|
|
75
74
|
str << '</comment>'
|
|
76
75
|
end
|
|
77
76
|
|
|
@@ -42,23 +42,22 @@ module Axlsx
|
|
|
42
42
|
raise ArgumentError, "Comment require an author" unless options[:author]
|
|
43
43
|
raise ArgumentError, "Comment requires text" unless options[:text]
|
|
44
44
|
raise ArgumentError, "Comment requires ref" unless options[:ref]
|
|
45
|
-
|
|
46
|
-
yield
|
|
47
|
-
|
|
45
|
+
self << Comment.new(self, options)
|
|
46
|
+
yield last if block_given?
|
|
47
|
+
last
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# A sorted list of the unique authors in the contained comments
|
|
51
51
|
# @return [Array]
|
|
52
52
|
def authors
|
|
53
|
-
|
|
53
|
+
map { |comment| comment.author.to_s }.uniq.sort
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# The relationships required by this object
|
|
57
57
|
# @return [Array]
|
|
58
58
|
def relationships
|
|
59
59
|
[Relationship.new(self, VML_DRAWING_R, "../#{vml_drawing.pn}"),
|
|
60
|
-
Relationship.new(self, COMMENT_R, "../#{pn}")
|
|
61
|
-
Relationship.new(self, COMMENT_R_NULL, "NULL")]
|
|
60
|
+
Relationship.new(self, COMMENT_R, "../#{pn}")]
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
# serialize the object
|
|
@@ -66,14 +65,12 @@ module Axlsx
|
|
|
66
65
|
# @return [String]
|
|
67
66
|
def to_xml_string(str="")
|
|
68
67
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
69
|
-
str << '<comments xmlns="' << XML_NS << '">'
|
|
70
|
-
str << '<authors>'
|
|
68
|
+
str << ('<comments xmlns="' << XML_NS << '"><authors>')
|
|
71
69
|
authors.each do |author|
|
|
72
|
-
str << '<author>' << author.to_s << '</author>'
|
|
70
|
+
str << ('<author>' << author.to_s << '</author>')
|
|
73
71
|
end
|
|
74
|
-
str << '</authors>'
|
|
75
|
-
|
|
76
|
-
@list.each do |comment|
|
|
72
|
+
str << '</authors><commentList>'
|
|
73
|
+
each do |comment|
|
|
77
74
|
comment.to_xml_string str
|
|
78
75
|
end
|
|
79
76
|
str << '</commentList></comments>'
|
|
@@ -74,7 +74,7 @@ module Axlsx
|
|
|
74
74
|
# @param [String] str
|
|
75
75
|
# @return [String]
|
|
76
76
|
def to_xml_string(str = '')
|
|
77
|
-
str << '<conditionalFormatting sqref="' << sqref << '">'
|
|
77
|
+
str << ('<conditionalFormatting sqref="' << sqref << '">')
|
|
78
78
|
str << rules.collect{ |rule| rule.to_xml_string }.join(' ')
|
|
79
79
|
str << '</conditionalFormatting>'
|
|
80
80
|
end
|
|
@@ -210,7 +210,7 @@ module Axlsx
|
|
|
210
210
|
str << '<cfRule '
|
|
211
211
|
serialized_attributes str
|
|
212
212
|
str << '>'
|
|
213
|
-
str << '<formula>' << [*self.formula].join('</formula><formula>') << '</formula>' if @formula
|
|
213
|
+
str << ('<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula
|
|
214
214
|
@color_scale.to_xml_string(str) if @color_scale && @type == :colorScale
|
|
215
215
|
@data_bar.to_xml_string(str) if @data_bar && @type == :dataBar
|
|
216
216
|
@icon_set.to_xml_string(str) if @icon_set && @type == :iconSet
|
|
@@ -107,12 +107,10 @@ module Axlsx
|
|
|
107
107
|
# @param [String] str
|
|
108
108
|
# @return [String]
|
|
109
109
|
def to_xml_string(str="")
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
self.color.to_xml_string(str)
|
|
115
|
-
str << '</dataBar>'
|
|
110
|
+
serialized_tag('dataBar', str) do
|
|
111
|
+
value_objects.to_xml_string(str)
|
|
112
|
+
self.color.to_xml_string(str)
|
|
113
|
+
end
|
|
116
114
|
end
|
|
117
115
|
|
|
118
116
|
private
|
|
@@ -33,7 +33,7 @@ module Axlsx
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# instance values that must be serialized as their own elements - e.g. not attributes.
|
|
36
|
-
CHILD_ELEMENTS = [:formula1, :formula2]
|
|
36
|
+
CHILD_ELEMENTS = [:formula1, :formula2].freeze
|
|
37
37
|
|
|
38
38
|
# Formula1
|
|
39
39
|
# Available for type whole, decimal, date, time, textLength, list, custom
|
|
@@ -216,10 +216,12 @@ module Axlsx
|
|
|
216
216
|
valid_attributes = get_valid_attributes
|
|
217
217
|
|
|
218
218
|
str << '<dataValidation '
|
|
219
|
-
str << instance_values.map
|
|
219
|
+
str << instance_values.map do |key, value|
|
|
220
|
+
'' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym))
|
|
221
|
+
end.join(' ')
|
|
220
222
|
str << '>'
|
|
221
|
-
str << '<formula1>' << self.formula1 << '</formula1>' if @formula1 and valid_attributes.include?(:formula1)
|
|
222
|
-
str << '<formula2>' << self.formula2 << '</formula2>' if @formula2 and valid_attributes.include?(:formula2)
|
|
223
|
+
str << ('<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1)
|
|
224
|
+
str << ('<formula2>' << self.formula2 << '</formula2>') if @formula2 and valid_attributes.include?(:formula2)
|
|
223
225
|
str << '</dataValidation>'
|
|
224
226
|
end
|
|
225
227
|
|
|
@@ -43,13 +43,13 @@ module Axlsx
|
|
|
43
43
|
# The first cell in the dimension
|
|
44
44
|
# @return [String]
|
|
45
45
|
def first_cell_reference
|
|
46
|
-
dimension_reference(worksheet.rows.first.
|
|
46
|
+
dimension_reference(worksheet.rows.first.first, Dimension.default_first)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# the last cell in the dimension
|
|
50
50
|
# @return [String]
|
|
51
51
|
def last_cell_reference
|
|
52
|
-
dimension_reference(worksheet.rows.last.
|
|
52
|
+
dimension_reference(worksheet.rows.last.last, Dimension.default_last)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
private
|
|
@@ -19,8 +19,8 @@ module Axlsx
|
|
|
19
19
|
# @option options [String] odd_footer The content for footers on odd numbered pages.
|
|
20
20
|
# @option options [String] even_header The content for headers on even numbered pages.
|
|
21
21
|
# @option options [String] even_footer The content for footers on even numbered pages.
|
|
22
|
-
# @option options [String] first_header The content for headers on
|
|
23
|
-
# @option options [String] first_footer The content for footers on
|
|
22
|
+
# @option options [String] first_header The content for headers on the first page.
|
|
23
|
+
# @option options [String] first_footer The content for footers on the first page.
|
|
24
24
|
# @option options [Boolean] different_odd_even Setting this to true will show different headers/footers on odd and even pages. When false, the odd headers/footers are used on each page. (Default: false)
|
|
25
25
|
# @option options [Boolean] different_first If true, will use the first header/footer on page 1. Otherwise, the odd header/footer is used.
|
|
26
26
|
def initialize(options = {})
|
|
@@ -42,13 +42,11 @@ module Axlsx
|
|
|
42
42
|
# @param [String] str
|
|
43
43
|
# @return [String]
|
|
44
44
|
def to_xml_string(str = '')
|
|
45
|
-
str
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value = ::CGI.escapeHTML(value)
|
|
45
|
+
serialized_tag('headerFooter', str) do
|
|
46
|
+
serialized_element_attributes(str) do |value|
|
|
47
|
+
value = ::CGI.escapeHTML(value)
|
|
48
|
+
end
|
|
50
49
|
end
|
|
51
|
-
str << "</headerFooter>"
|
|
52
50
|
end
|
|
53
51
|
end
|
|
54
52
|
end
|