axlsx 1.1.6 → 1.2.0

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.
Files changed (173) hide show
  1. data/.yardopts +5 -2
  2. data/CHANGELOG.md +39 -0
  3. data/README.md +97 -46
  4. data/Rakefile +3 -2
  5. data/examples/basic_charts.rb +54 -0
  6. data/examples/chart_colors.rb +18 -3
  7. data/examples/example.rb +118 -42
  8. data/examples/example.xlsx +0 -0
  9. data/examples/example_streamed.xlsx +0 -0
  10. data/examples/extractive.pdf +0 -0
  11. data/examples/no-use_autowidth.xlsx +0 -0
  12. data/examples/scraping_html.rb +91 -0
  13. data/examples/shared_strings_example.xlsx +0 -0
  14. data/examples/sheet_view.rb +34 -0
  15. data/lib/axlsx/content_type/content_type.rb +2 -0
  16. data/lib/axlsx/content_type/default.rb +21 -12
  17. data/lib/axlsx/content_type/override.rb +22 -11
  18. data/lib/axlsx/doc_props/app.rb +36 -32
  19. data/lib/axlsx/doc_props/core.rb +9 -5
  20. data/lib/axlsx/drawing/ax_data_source.rb +7 -6
  21. data/lib/axlsx/drawing/axis.rb +64 -25
  22. data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
  23. data/lib/axlsx/drawing/bar_series.rb +1 -0
  24. data/lib/axlsx/drawing/cat_axis.rb +43 -39
  25. data/lib/axlsx/drawing/chart.rb +65 -54
  26. data/lib/axlsx/drawing/d_lbls.rb +100 -0
  27. data/lib/axlsx/drawing/drawing.rb +7 -5
  28. data/lib/axlsx/drawing/graphic_frame.rb +2 -2
  29. data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
  30. data/lib/axlsx/drawing/num_data.rb +2 -2
  31. data/lib/axlsx/drawing/num_data_source.rb +1 -1
  32. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
  33. data/lib/axlsx/drawing/scatter_chart.rb +2 -8
  34. data/lib/axlsx/drawing/title.rb +21 -9
  35. data/lib/axlsx/drawing/two_cell_anchor.rb +41 -9
  36. data/lib/axlsx/drawing/view_3D.rb +41 -31
  37. data/lib/axlsx/drawing/vml_drawing.rb +1 -1
  38. data/lib/axlsx/package.rb +20 -16
  39. data/lib/axlsx/rels/relationship.rb +3 -3
  40. data/lib/axlsx/stylesheet/styles.rb +1 -1
  41. data/lib/axlsx/util/constants.rb +4 -0
  42. data/lib/axlsx/util/simple_typed_list.rb +15 -8
  43. data/lib/axlsx/util/validators.rb +28 -4
  44. data/lib/axlsx/version.rb +2 -7
  45. data/lib/axlsx/workbook/defined_name.rb +174 -0
  46. data/lib/axlsx/workbook/defined_names.rb +21 -0
  47. data/lib/axlsx/workbook/workbook.rb +46 -17
  48. data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
  49. data/lib/axlsx/workbook/worksheet/cell.rb +28 -1
  50. data/lib/axlsx/workbook/worksheet/col.rb +15 -0
  51. data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
  52. data/lib/axlsx/workbook/worksheet/comments.rb +8 -0
  53. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
  54. data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
  55. data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
  56. data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
  57. data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
  58. data/lib/axlsx/workbook/worksheet/page_setup.rb +10 -1
  59. data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
  60. data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
  61. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
  62. data/lib/axlsx/workbook/worksheet/row.rb +1 -1
  63. data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
  64. data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
  65. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
  66. data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
  67. data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
  68. data/lib/axlsx/workbook/worksheet/worksheet.rb +315 -291
  69. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
  70. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
  71. data/lib/axlsx.rb +24 -16
  72. data/test/content_type/tc_content_type.rb +1 -6
  73. data/test/doc_props/tc_core.rb +1 -1
  74. data/test/drawing/tc_axis.rb +27 -2
  75. data/test/drawing/tc_bar_3D_chart.rb +12 -12
  76. data/test/drawing/tc_bar_series.rb +1 -2
  77. data/test/drawing/tc_cat_axis.rb +3 -3
  78. data/test/drawing/tc_chart.rb +8 -6
  79. data/test/drawing/tc_d_lbls.rb +47 -0
  80. data/test/drawing/tc_drawing.rb +5 -4
  81. data/test/drawing/tc_line_series.rb +1 -1
  82. data/test/drawing/tc_num_data.rb +5 -1
  83. data/test/drawing/tc_pie_3D_chart.rb +4 -8
  84. data/test/drawing/tc_pie_series.rb +1 -1
  85. data/test/drawing/tc_scatter_series.rb +1 -1
  86. data/test/drawing/tc_series.rb +1 -1
  87. data/test/drawing/tc_title.rb +16 -0
  88. data/test/drawing/tc_view_3D.rb +18 -18
  89. data/test/tc_package.rb +41 -4
  90. data/test/util/tc_validators.rb +68 -11
  91. data/test/workbook/tc_defined_name.rb +41 -0
  92. data/test/workbook/tc_workbook.rb +5 -3
  93. data/test/workbook/worksheet/table/tc_table.rb +0 -8
  94. data/test/workbook/worksheet/tc_cell.rb +2 -4
  95. data/test/workbook/worksheet/tc_page_setup.rb +20 -3
  96. data/test/workbook/worksheet/tc_pane.rb +94 -0
  97. data/test/workbook/worksheet/tc_protected_range.rb +17 -0
  98. data/test/workbook/worksheet/tc_row.rb +2 -2
  99. data/test/workbook/worksheet/tc_selection.rb +94 -0
  100. data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
  101. data/test/workbook/worksheet/tc_worksheet.rb +53 -41
  102. metadata +104 -97
  103. data/examples/chart_colors.xlsx +0 -0
  104. data/examples/conditional_formatting/getting_barred.xlsx +0 -0
  105. data/examples/doc/_index.html +0 -84
  106. data/examples/doc/class_list.html +0 -47
  107. data/examples/doc/css/common.css +0 -1
  108. data/examples/doc/css/full_list.css +0 -55
  109. data/examples/doc/css/style.css +0 -322
  110. data/examples/doc/file_list.html +0 -46
  111. data/examples/doc/frames.html +0 -13
  112. data/examples/doc/index.html +0 -84
  113. data/examples/doc/js/app.js +0 -205
  114. data/examples/doc/js/full_list.js +0 -173
  115. data/examples/doc/js/jquery.js +0 -16
  116. data/examples/doc/method_list.html +0 -46
  117. data/examples/doc/top-level-namespace.html +0 -95
  118. data/examples/examples_saved.xlsx +0 -0
  119. data/examples/fish.xlsx +0 -0
  120. data/examples/pareto.rb +0 -28
  121. data/examples/pareto.xlsx +0 -0
  122. data/examples/pie_chart.rb +0 -16
  123. data/examples/pie_chart.xlsx +0 -0
  124. data/examples/pie_chart_saved.xlsx +0 -0
  125. data/examples/sheet_protection.xlsx +0 -0
  126. data/examples/two_cell_anchor_image.xlsx +0 -0
  127. data/examples/~$pie_chart_saved.xlsx +0 -0
  128. data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
  129. data/lib/axlsx/drawing/data_source.rb~ +0 -51
  130. data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
  131. data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
  132. data/lib/axlsx/drawing/num_data.rb~ +0 -51
  133. data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
  134. data/lib/axlsx/drawing/num_val.rb~ +0 -40
  135. data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
  136. data/lib/axlsx/drawing/ref.rb~ +0 -41
  137. data/lib/axlsx/drawing/str_data.rb~ +0 -58
  138. data/lib/axlsx/drawing/str_val.rb~ +0 -35
  139. data/lib/axlsx/drawing/vml_drawing.rb~ +0 -6
  140. data/lib/axlsx/drawing/vml_shape.rb~ +0 -61
  141. data/lib/axlsx/util/cbf.rb +0 -333
  142. data/lib/axlsx/util/cfb.rb~ +0 -201
  143. data/lib/axlsx/util/font_tables.rb~ +0 -0
  144. data/lib/axlsx/util/ms_off_crypto.rb +0 -189
  145. data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
  146. data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
  147. data/lib/axlsx/util/parser.rb~ +0 -6
  148. data/lib/axlsx/util/storage.rb~ +0 -0
  149. data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
  150. data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
  151. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  152. data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
  153. data/lib/axlsx/workbook/worksheet/comment.rb~ +0 -91
  154. data/lib/axlsx/workbook/worksheet/comments.rb~ +0 -86
  155. data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
  156. data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
  157. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  158. data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
  159. data/lib/schema/dc.xsd~ +0 -118
  160. data/lib/schema/dcterms.xsd~ +0 -331
  161. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  162. data/test/drawing/tc_data_source.rb~ +0 -30
  163. data/test/drawing/tc_num_data.rb~ +0 -35
  164. data/test/drawing/tc_num_val.rb~ +0 -29
  165. data/test/drawing/tc_str_data.rb~ +0 -30
  166. data/test/drawing/tc_str_val.rb~ +0 -26
  167. data/test/drawing/tc_vml_drawing.rb~ +0 -0
  168. data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
  169. data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
  170. data/test/workbook/worksheet/tc_col.rb~ +0 -10
  171. data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
  172. data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
  173. data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
@@ -0,0 +1,144 @@
1
+ # encoding: UTF-8
2
+ module Axlsx
3
+ # Pane options for a worksheet.
4
+ #
5
+ # @note The recommended way to manage the pane options is via SheetView#pane
6
+ # @see SheetView#pane
7
+ class Pane
8
+
9
+ # Active Pane
10
+ # The pane that is active.
11
+ # Options are
12
+ # * bottom_left: Bottom left pane, when both vertical and horizontal
13
+ # splits are applied. This value is also used when only
14
+ # a horizontal split has been applied, dividing the pane
15
+ # into upper and lower regions. In that case, this value
16
+ # specifies the bottom pane.
17
+ # * bottom_right: Bottom right pane, when both vertical and horizontal
18
+ # splits are applied.
19
+ # * top_left: Top left pane, when both vertical and horizontal splits
20
+ # are applied. This value is also used when only a horizontal
21
+ # split has been applied, dividing the pane into upper and lower
22
+ # regions. In that case, this value specifies the top pane.
23
+ # This value is also used when only a vertical split has
24
+ # been applied, dividing the pane into right and left
25
+ # regions. In that case, this value specifies the left pane
26
+ # * top_right: Top right pane, when both vertical and horizontal
27
+ # splits are applied. This value is also used when only
28
+ # a vertical split has been applied, dividing the pane
29
+ # into right and left regions. In that case, this value
30
+ # specifies the right pane.
31
+ # @see type
32
+ # @return [Symbol]
33
+ # default nil
34
+ attr_reader :active_pane
35
+
36
+
37
+ # Split State
38
+ # Indicates whether the pane has horizontal / vertical
39
+ # splits, and whether those splits are frozen.
40
+ # Options are
41
+ # * frozen: Panes are frozen, but were not split being frozen. In
42
+ # this state, when the panes are unfrozen again, a single
43
+ # pane results, with no split. In this state, the split
44
+ # bars are not adjustable.
45
+ # * frozen_split: Panes are frozen and were split before being frozen. In
46
+ # this state, when the panes are unfrozen again, the split
47
+ # remains, but is adjustable.
48
+ # * split: Panes are split, but not frozen. In this state, the split
49
+ # bars are adjustable by the user.
50
+ # @see type
51
+ # @return [Symbol]
52
+ # default nil
53
+ attr_reader :state
54
+
55
+
56
+ # Top Left Visible Cell
57
+ # Location of the top left visible cell in the bottom
58
+ # right pane (when in Left-To-Right mode).
59
+ # @see type
60
+ # @return [String]
61
+ # default nil
62
+ attr_reader :top_left_cell
63
+
64
+
65
+ # Horizontal Split Position
66
+ # Horizontal position of the split, in 1/20th of a point; 0 (zero)
67
+ # if none. If the pane is frozen, this value indicates the number
68
+ # of columns visible in the top pane.
69
+ # @see type
70
+ # @return [Integer]
71
+ # default 0
72
+ attr_reader :x_split
73
+
74
+
75
+ # Vertical Split Position
76
+ # Vertical position of the split, in 1/20th of a point; 0 (zero)
77
+ # if none. If the pane is frozen, this value indicates the number
78
+ # of rows visible in the left pane.
79
+ # @see type
80
+ # @return [Integer]
81
+ # default 0
82
+ attr_reader :y_split
83
+
84
+
85
+ # Creates a new {Pane} object
86
+ # @option options [Symbol] active_pane Active Pane
87
+ # @option options [Symbol] state Split State
88
+ # @option options [Cell, String] top_left_cell Top Left Visible Cell
89
+ # @option options [Integer] x_split Horizontal Split Position
90
+ # @option options [Integer] y_split Vertical Split Position
91
+ def initialize(options={})
92
+ #defaults
93
+ @active_pane = @state = @top_left_cell = nil
94
+ @x_split = @y_split = 0
95
+
96
+ # write options to instance variables
97
+ options.each do |o|
98
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
99
+ end
100
+ end
101
+
102
+
103
+ # @see active_pane
104
+ def active_pane=(v); Axlsx::validate_pane_type(v); @active_pane = v end
105
+
106
+
107
+ # @see state
108
+ def state=(v); Axlsx::validate_split_state_type(v); @state = v end
109
+
110
+
111
+ # @see top_left_cell
112
+ def top_left_cell=(v)
113
+ cell = (v.class == Axlsx::Cell ? v.r_abs : v)
114
+ Axlsx::validate_string(cell)
115
+ @top_left_cell = cell
116
+ end
117
+
118
+
119
+ # @see x_split
120
+ def x_split=(v); Axlsx::validate_unsigned_int(v); @x_split = v end
121
+
122
+
123
+ # @see y_split
124
+ def y_split=(v); Axlsx::validate_unsigned_int(v); @y_split = v end
125
+
126
+
127
+ # Serializes the data validation
128
+ # @param [String] str
129
+ # @return [String]
130
+ def to_xml_string(str = '')
131
+ if @state == :frozen && @top_left_cell.nil?
132
+ row = @y_split || 0
133
+ column = @x_split || 0
134
+
135
+ @top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row+1}"
136
+ end
137
+
138
+ str << '<pane '
139
+ str << instance_values.map { |key, value| '' << key.gsub(/_(.)/){ $1.upcase } <<
140
+ %{="#{[:active_pane, :state].include?(key.to_sym) ? value.to_s.gsub(/_(.)/){ $1.upcase } : value}"} unless value.nil? }.join(' ')
141
+ str << '/>'
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,46 @@
1
+ module Axlsx
2
+ # The Protected Range class represents a set of cells in the worksheet
3
+ # @note the recommended way to manage protected ranges with via Worksheet#protect_range
4
+ # @see Worksheet#protect_range
5
+ class ProtectedRange
6
+
7
+ # The reference for the protected range
8
+ # @return [String]
9
+ attr_reader :sqref
10
+
11
+ # The name of the protected range
12
+ # @return [String]
13
+ attr_reader :name
14
+
15
+ # Initializes a new protected range object
16
+ # @option [String] sqref The cell range reference to protect. This can be an absolute or a relateve range however, it only applies to the current sheet.
17
+ # @option [String] name An optional name for the protected name.
18
+ def initialize(options={})
19
+ options.each do |o|
20
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
21
+ end
22
+ yield self if block_given?
23
+ end
24
+
25
+ # @see sqref
26
+ def sqref=(v)
27
+ Axlsx.validate_string(v)
28
+ @sqref = v
29
+ end
30
+
31
+ # @see name
32
+ def name=(v)
33
+ Axlsx.validate_string(v)
34
+ @name = v
35
+ end
36
+
37
+ # serializes the proteted range
38
+ # @param [String] str if this string object is provided we append
39
+ # our output to that object. Use this - it helps limit the number of
40
+ # objects created during serialization
41
+ def to_xml_string(str="")
42
+ attrs = self.instance_values.reject{ |key, value| value == nil }
43
+ str << '<protectedRange ' << attrs.map { |key, value| '' << key << '="' << value.to_s << '"' }.join(' ') << '/>'
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,34 @@
1
+ module Axlsx
2
+
3
+ # A self serializing collection of ranges that should be protected in
4
+ # the worksheet
5
+ class ProtectedRanges < SimpleTypedList
6
+
7
+ attr_reader :worksheet
8
+
9
+ def initialize(worksheet)
10
+ raise ArgumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet)
11
+ super ProtectedRange
12
+ @worksheet = worksheet
13
+ end
14
+
15
+ # Adds a protected range
16
+ # @param [Array|String] cells A string range reference or array of cells that will be protected
17
+ def add_range(cells)
18
+ sqref = if cells.is_a?(String)
19
+ cells
20
+ elsif cells.is_a?(SimpleTypedList) || cells.is_a?(Array)
21
+ Axlsx::cell_range(cells, false)
22
+ end
23
+ @list << ProtectedRange.new(:sqref => sqref, :name => "Range#{size}")
24
+ last
25
+ end
26
+
27
+ def to_xml_string(str = '')
28
+ return if empty?
29
+ str << '<protectedRanges>'
30
+ each { |range| range.to_xml_string(str) }
31
+ str << '</protectedRanges>'
32
+ end
33
+ end
34
+ end
@@ -134,7 +134,7 @@ module Axlsx
134
134
  # @return [Cell]
135
135
  def add_cell(value="", options={})
136
136
  c = Cell.new(self, value, options)
137
- worksheet.send(:update_column_info, self.cells, [], self.cells.map(&:style))
137
+ worksheet.send(:update_column_info, self.cells, [])
138
138
  c
139
139
  end
140
140
 
@@ -0,0 +1,111 @@
1
+ # encoding: UTF-8
2
+ module Axlsx
3
+ # Selection options for worksheet panes.
4
+ #
5
+ # @note The recommended way to manage the selection pane options is via SheetView#add_selection
6
+ # @see SheetView#add_selection
7
+ class Selection
8
+
9
+ # Active Cell Location
10
+ # Location of the active cell.
11
+ # @see type
12
+ # @return [String]
13
+ # default nil
14
+ attr_reader :active_cell
15
+
16
+
17
+ # Active Cell Index
18
+ # 0-based index of the range reference (in the array of references listed in sqref)
19
+ # containing the active cell. Only used when the selection in sqref is not contiguous.
20
+ # Therefore, this value needs to be aware of the order in which the range references are
21
+ # written in sqref.
22
+ # When this value is out of range then activeCell can be used.
23
+ # @see type
24
+ # @return [Integer]
25
+ # default nil
26
+ attr_reader :active_cell_id
27
+
28
+
29
+ # Pane
30
+ # The pane to which this selection belongs.
31
+ # Options are
32
+ # * bottom_left: Bottom left pane, when both vertical and horizontal
33
+ # splits are applied. This value is also used when only
34
+ # a horizontal split has been applied, dividing the pane
35
+ # into upper and lower regions. In that case, this value
36
+ # specifies the bottom pane.
37
+ # * bottom_right: Bottom right pane, when both vertical and horizontal
38
+ # splits are applied.
39
+ # * top_left: Top left pane, when both vertical and horizontal splits
40
+ # are applied. This value is also used when only a horizontal
41
+ # split has been applied, dividing the pane into upper and lower
42
+ # regions. In that case, this value specifies the top pane.
43
+ # This value is also used when only a vertical split has
44
+ # been applied, dividing the pane into right and left
45
+ # regions. In that case, this value specifies the left pane
46
+ # * top_right: Top right pane, when both vertical and horizontal
47
+ # splits are applied. This value is also used when only
48
+ # a vertical split has been applied, dividing the pane
49
+ # into right and left regions. In that case, this value
50
+ # specifies the right pane.
51
+ # @see type
52
+ # @return [Symbol]
53
+ # default nil
54
+ attr_reader :pane
55
+
56
+
57
+ # Sequence of References
58
+ # Range of the selection. Can be non-contiguous set of ranges.
59
+ # @see type
60
+ # @return [String]
61
+ # default nil
62
+ attr_reader :sqref
63
+
64
+
65
+ # Creates a new {Selection} object
66
+ # @option options [Cell, String] active_cell Active Cell Location
67
+ # @option options [Integer] active_cell_id Active Cell Index
68
+ # @option options [Symbol] pane Pane
69
+ # @option options [String] sqref Sequence of References
70
+ def initialize(options={})
71
+ #defaults
72
+ @active_cell = @active_cell_id = @pane = @sqref = nil
73
+
74
+ # write options to instance variables
75
+ options.each do |o|
76
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
77
+ end
78
+ end
79
+
80
+
81
+ # @see active_cell
82
+ def active_cell=(v)
83
+ cell = (v.class == Axlsx::Cell ? v.r_abs : v)
84
+ Axlsx::validate_string(cell)
85
+ @active_cell = cell
86
+ end
87
+
88
+
89
+ # @see active_cell_id
90
+ def active_cell_id=(v); Axlsx::validate_unsigned_int(v); @active_cell_id = v end
91
+
92
+
93
+ # @see pane
94
+ def pane=(v); Axlsx::validate_pane_type(v); @pane = v end
95
+
96
+
97
+ # @see sqref
98
+ def sqref=(v); Axlsx::validate_string(v); @sqref = v end
99
+
100
+
101
+ # Serializes the data validation
102
+ # @param [String] str
103
+ # @return [String]
104
+ def to_xml_string(str = '')
105
+ str << '<selection '
106
+ str << instance_values.map { |key, value| '' << key.gsub(/_(.)/){ $1.upcase } <<
107
+ %{="#{[:pane].include?(key.to_sym) ? value.to_s.gsub(/_(.)/){ $1.upcase } : value}"} unless value.nil? }.join(' ')
108
+ str << '/>'
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,25 @@
1
+ module Axlsx
2
+
3
+ # This class manages the serialization of rows for worksheets
4
+ class SheetData
5
+
6
+ # Creates a new SheetData object
7
+ # @param [Worksheet] worksheet The worksheet that owns this sheet data.
8
+ def initialize(worksheet)
9
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
10
+ @worksheet = worksheet
11
+ end
12
+
13
+ attr_reader :worksheet
14
+
15
+ # Serialize the sheet data
16
+ # @param [String] str the string this objects serializaton will be concacted to.
17
+ # @return [String]
18
+ def to_xml_string(str = '')
19
+ str << '<sheetData>'
20
+ worksheet.rows.each_with_index{ |row, index| row.to_xml_string(index, str) }
21
+ str << '</sheetData>'
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ module Axlsx
2
+
3
+ # The SheetPr class manages serialization fo a worksheet's sheetPr element.
4
+ # Only fit_to_page is implemented
5
+ class SheetPr
6
+
7
+ # Creates a new SheetPr object
8
+ # @param [Worksheet] worksheet The worksheet that owns this SheetPr object
9
+ def initialize(worksheet)
10
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
11
+ @worksheet = worksheet
12
+ end
13
+
14
+ attr_reader :worksheet
15
+
16
+ # Serialize the object
17
+ # @param [String] str serialized output will be appended to this object if provided.
18
+ # @return [String]
19
+ def to_xml_string(str = '')
20
+ return unless worksheet.fit_to_page?
21
+ str << "<sheetPr><pageSetUpPr fitToPage=\"%s\"></pageSetUpPr></sheetPr>" % worksheet.fit_to_page?
22
+ end
23
+ end
24
+ end