axlsx 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/README.md +13 -5
  2. data/examples/colored_links.rb +59 -0
  3. data/examples/example.rb +421 -266
  4. data/examples/example.xlsx +0 -0
  5. data/examples/example_streamed.xlsx +0 -0
  6. data/examples/finance.rb +82 -0
  7. data/examples/finance.xlsx +0 -0
  8. data/examples/financial.xlsx +0 -0
  9. data/examples/no-use_autowidth.xlsx +0 -0
  10. data/examples/shared_strings_example.xlsx +0 -0
  11. data/examples/where_is_my_color.xlsx +0 -0
  12. data/lib/axlsx.rb +11 -4
  13. data/lib/axlsx/content_type/abstract_content_type.rb +32 -0
  14. data/lib/axlsx/content_type/content_type.rb +1 -1
  15. data/lib/axlsx/content_type/default.rb +6 -37
  16. data/lib/axlsx/content_type/override.rb +6 -38
  17. data/lib/axlsx/doc_props/app.rb +7 -4
  18. data/lib/axlsx/drawing/axis.rb +3 -3
  19. data/lib/axlsx/drawing/chart.rb +2 -3
  20. data/lib/axlsx/drawing/d_lbls.rb +21 -31
  21. data/lib/axlsx/drawing/drawing.rb +6 -0
  22. data/lib/axlsx/drawing/hyperlink.rb +40 -32
  23. data/lib/axlsx/drawing/marker.rb +13 -13
  24. data/lib/axlsx/drawing/num_data.rb +6 -6
  25. data/lib/axlsx/drawing/num_data_source.rb +17 -16
  26. data/lib/axlsx/drawing/one_cell_anchor.rb +20 -22
  27. data/lib/axlsx/drawing/pic.rb +25 -27
  28. data/lib/axlsx/drawing/picture_locking.rb +12 -44
  29. data/lib/axlsx/drawing/scaling.rb +13 -13
  30. data/lib/axlsx/drawing/scatter_chart.rb +3 -3
  31. data/lib/axlsx/drawing/series.rb +3 -6
  32. data/lib/axlsx/drawing/str_data.rb +3 -3
  33. data/lib/axlsx/drawing/str_val.rb +7 -8
  34. data/lib/axlsx/drawing/view_3D.rb +51 -37
  35. data/lib/axlsx/drawing/vml_shape.rb +23 -23
  36. data/lib/axlsx/package.rb +14 -16
  37. data/lib/axlsx/stylesheet/border.rb +29 -20
  38. data/lib/axlsx/stylesheet/border_pr.rb +5 -4
  39. data/lib/axlsx/stylesheet/cell_alignment.rb +55 -29
  40. data/lib/axlsx/stylesheet/cell_protection.rb +7 -4
  41. data/lib/axlsx/stylesheet/cell_style.rb +19 -14
  42. data/lib/axlsx/stylesheet/color.rb +19 -16
  43. data/lib/axlsx/stylesheet/dxf.rb +4 -4
  44. data/lib/axlsx/stylesheet/font.rb +22 -22
  45. data/lib/axlsx/stylesheet/gradient_fill.rb +45 -21
  46. data/lib/axlsx/stylesheet/num_fmt.rb +22 -13
  47. data/lib/axlsx/stylesheet/pattern_fill.rb +12 -21
  48. data/lib/axlsx/stylesheet/styles.rb +1 -1
  49. data/lib/axlsx/stylesheet/table_style.rb +17 -16
  50. data/lib/axlsx/stylesheet/table_style_element.rb +15 -11
  51. data/lib/axlsx/stylesheet/table_styles.rb +14 -11
  52. data/lib/axlsx/stylesheet/xf.rb +28 -26
  53. data/lib/axlsx/util/accessors.rb +49 -0
  54. data/lib/axlsx/util/options_parser.rb +15 -0
  55. data/lib/axlsx/util/serialized_attributes.rb +46 -0
  56. data/lib/axlsx/util/simple_typed_list.rb +16 -4
  57. data/lib/axlsx/version.rb +1 -1
  58. data/lib/axlsx/workbook/defined_name.rb +13 -58
  59. data/lib/axlsx/workbook/workbook.rb +27 -1
  60. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -19
  61. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +20 -27
  62. data/lib/axlsx/workbook/worksheet/cell.rb +38 -39
  63. data/lib/axlsx/workbook/worksheet/cfvo.rb +15 -15
  64. data/lib/axlsx/workbook/worksheet/cfvos.rb +18 -0
  65. data/lib/axlsx/workbook/worksheet/col.rb +34 -27
  66. data/lib/axlsx/workbook/worksheet/color_scale.rb +7 -13
  67. data/lib/axlsx/workbook/worksheet/comment.rb +14 -11
  68. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +11 -11
  69. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +27 -25
  70. data/lib/axlsx/workbook/worksheet/data_bar.rb +44 -34
  71. data/lib/axlsx/workbook/worksheet/data_validation.rb +61 -62
  72. data/lib/axlsx/workbook/worksheet/dimension.rb +0 -1
  73. data/lib/axlsx/workbook/worksheet/icon_set.rb +20 -20
  74. data/lib/axlsx/workbook/worksheet/page_margins.rb +21 -19
  75. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -9
  76. data/lib/axlsx/workbook/worksheet/page_setup.rb +20 -19
  77. data/lib/axlsx/workbook/worksheet/pane.rb +48 -51
  78. data/lib/axlsx/workbook/worksheet/print_options.rb +8 -30
  79. data/lib/axlsx/workbook/worksheet/protected_range.rb +16 -13
  80. data/lib/axlsx/workbook/worksheet/selection.rb +30 -38
  81. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -26
  82. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +19 -57
  83. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +51 -155
  84. data/lib/axlsx/workbook/worksheet/sheet_view.rb +68 -234
  85. data/lib/axlsx/workbook/worksheet/table.rb +16 -18
  86. data/lib/axlsx/workbook/worksheet/table_style_info.rb +10 -27
  87. data/lib/axlsx/workbook/worksheet/worksheet.rb +6 -7
  88. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +1 -1
  89. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +11 -33
  90. data/test/content_type/tc_default.rb +0 -11
  91. data/test/content_type/tc_override.rb +0 -13
  92. data/test/drawing/tc_d_lbls.rb +14 -4
  93. data/test/tc_axlsx.rb +20 -2
  94. data/test/workbook/tc_defined_name.rb +2 -2
  95. data/test/workbook/tc_workbook.rb +15 -0
  96. data/test/workbook/worksheet/tc_col.rb +11 -1
  97. data/test/workbook/worksheet/tc_pane.rb +5 -45
  98. data/test/workbook/worksheet/tc_selection.rb +9 -48
  99. metadata +13 -3
@@ -1,11 +1,27 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # Pane options for a worksheet.
4
3
  #
5
4
  # @note The recommended way to manage the pane options is via SheetView#pane
6
5
  # @see SheetView#pane
7
6
  class Pane
8
-
7
+
8
+ include Axlsx::OptionsParser
9
+ include Axlsx::SerializedAttributes
10
+ # Creates a new {Pane} object
11
+ # @option options [Symbol] active_pane Active Pane
12
+ # @option options [Symbol] state Split State
13
+ # @option options [Cell, String] top_left_cell Top Left Visible Cell
14
+ # @option options [Integer] x_split Horizontal Split Position
15
+ # @option options [Integer] y_split Vertical Split Position
16
+ def initialize(options={})
17
+ #defaults
18
+ @active_pane = @state = @top_left_cell = nil
19
+ @x_split = @y_split = 0
20
+ parse_options options
21
+ end
22
+
23
+ serializable_attributes :active_pane, :state, :top_left_cell, :x_split, :y_split
24
+
9
25
  # Active Pane
10
26
  # The pane that is active.
11
27
  # Options are
@@ -32,8 +48,8 @@ module Axlsx
32
48
  # @return [Symbol]
33
49
  # default nil
34
50
  attr_reader :active_pane
35
-
36
-
51
+
52
+
37
53
  # Split State
38
54
  # Indicates whether the pane has horizontal / vertical
39
55
  # splits, and whether those splits are frozen.
@@ -51,8 +67,7 @@ module Axlsx
51
67
  # @return [Symbol]
52
68
  # default nil
53
69
  attr_reader :state
54
-
55
-
70
+
56
71
  # Top Left Visible Cell
57
72
  # Location of the top left visible cell in the bottom
58
73
  # right pane (when in Left-To-Right mode).
@@ -60,8 +75,7 @@ module Axlsx
60
75
  # @return [String]
61
76
  # default nil
62
77
  attr_reader :top_left_cell
63
-
64
-
78
+
65
79
  # Horizontal Split Position
66
80
  # Horizontal position of the split, in 1/20th of a point; 0 (zero)
67
81
  # if none. If the pane is frozen, this value indicates the number
@@ -70,8 +84,7 @@ module Axlsx
70
84
  # @return [Integer]
71
85
  # default 0
72
86
  attr_reader :x_split
73
-
74
-
87
+
75
88
  # Vertical Split Position
76
89
  # Vertical position of the split, in 1/20th of a point; 0 (zero)
77
90
  # if none. If the pane is frozen, this value indicates the number
@@ -80,65 +93,49 @@ module Axlsx
80
93
  # @return [Integer]
81
94
  # default 0
82
95
  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
-
96
+
103
97
  # @see active_pane
104
- def active_pane=(v); Axlsx::validate_pane_type(v); @active_pane = v end
105
-
106
-
98
+ def active_pane=(v)
99
+ Axlsx::validate_pane_type(v)
100
+ @active_pane = Axlsx::camel(v.to_s, false)
101
+ end
102
+
107
103
  # @see state
108
- def state=(v); Axlsx::validate_split_state_type(v); @state = v end
109
-
110
-
104
+ def state=(v)
105
+ Axlsx::validate_split_state_type(v)
106
+ @state = Axlsx::camel(v.to_s, false)
107
+ end
108
+
111
109
  # @see top_left_cell
112
110
  def top_left_cell=(v)
113
111
  cell = (v.class == Axlsx::Cell ? v.r_abs : v)
114
- Axlsx::validate_string(cell)
115
- @top_left_cell = cell
112
+ Axlsx::validate_string(cell)
113
+ @top_left_cell = cell
116
114
  end
117
-
118
-
115
+
119
116
  # @see x_split
120
117
  def x_split=(v); Axlsx::validate_unsigned_int(v); @x_split = v end
121
-
122
-
118
+
123
119
  # @see y_split
124
120
  def y_split=(v); Axlsx::validate_unsigned_int(v); @y_split = v end
125
-
126
-
121
+
127
122
  # Serializes the data validation
128
123
  # @param [String] str
129
124
  # @return [String]
130
125
  def to_xml_string(str = '')
131
- if @state == :frozen && @top_left_cell.nil?
126
+ finalize
127
+ str << '<pane '
128
+ serialized_attributes str
129
+ str << '/>'
130
+ end
131
+ private
132
+
133
+ def finalize
134
+ if @state == 'frozen' && @top_left_cell.nil?
132
135
  row = @y_split || 0
133
136
  column = @x_split || 0
134
-
135
137
  @top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row+1}"
136
138
  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
139
  end
143
140
  end
144
141
  end
@@ -6,22 +6,9 @@ module Axlsx
6
6
  # @see Worksheet#initialize
7
7
  class PrintOptions
8
8
 
9
- # Whether grid lines should be printed.
10
- # @return [Boolean]
11
- attr_reader :grid_lines
12
-
13
- # Whether row and column headings should be printed.
14
- # @return [Boolean]
15
- attr_reader :headings
16
-
17
- # Whether the content should be centered horizontally on the page.
18
- # @return [Boolean]
19
- attr_reader :horizontal_centered
20
-
21
- # Whether the content should be centered vertically on the page.
22
- # @return [Boolean]
23
- attr_reader :vertical_centered
24
-
9
+ include Axlsx::OptionsParser
10
+ include Axlsx::SerializedAttributes
11
+ include Axlsx::Accessors
25
12
  # Creates a new PrintOptions object
26
13
  # @option options [Boolean] grid_lines Whether grid lines should be printed
27
14
  # @option options [Boolean] headings Whether row and column headings should be printed
@@ -32,31 +19,22 @@ module Axlsx
32
19
  set(options)
33
20
  end
34
21
 
22
+ serializable_attributes :grid_lines, :headings, :horizontal_centered, :vertical_centered
23
+ boolean_attr_accessor :grid_lines, :headings, :horizontal_centered, :vertical_centered
24
+
35
25
  # Set some or all options at once.
36
26
  # @param [Hash] options The options to set (possible keys are :grid_lines, :headings, :horizontal_centered, and :vertical_centered).
37
27
  def set(options)
38
- options.each do |k, v|
39
- send("#{k}=", v) if respond_to? "#{k}="
40
- end
28
+ parse_options options
41
29
  end
42
30
 
43
- # @see grid_lines
44
- def grid_lines=(v); Axlsx::validate_boolean(v); @grid_lines = v; end
45
- # @see headings
46
- def headings=(v); Axlsx::validate_boolean(v); @headings = v; end
47
- # @see horizontal_centered
48
- def horizontal_centered=(v); Axlsx::validate_boolean(v); @horizontal_centered = v; end
49
- # @see vertical_centered
50
- def vertical_centered=(v); Axlsx::validate_boolean(v); @vertical_centered = v; end
51
-
52
31
  # Serializes the page options element.
53
32
  # @note As all attributes default to "false" according to the xml schema definition, the generated xml includes only those attributes that are set to true.
54
33
  # @param [String] str
55
34
  # @return [String]
56
35
  def to_xml_string(str = '')
57
36
  str << '<printOptions '
58
- #
59
- str << instance_values.select{ |k,v| v == true }.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v}"} }.join(' ')
37
+ serialized_attributes str
60
38
  str << '/>'
61
39
  end
62
40
  end
@@ -4,6 +4,18 @@ module Axlsx
4
4
  # @see Worksheet#protect_range
5
5
  class ProtectedRange
6
6
 
7
+ include Axlsx::OptionsParser
8
+ include Axlsx::SerializedAttributes
9
+
10
+ # Initializes a new protected range object
11
+ # @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.
12
+ # @option [String] name An optional name for the protected name.
13
+ def initialize(options={})
14
+ parse_options options
15
+ yield self if block_given?
16
+ end
17
+
18
+ serializable_attributes :sqref, :name
7
19
  # The reference for the protected range
8
20
  # @return [String]
9
21
  attr_reader :sqref
@@ -12,16 +24,6 @@ module Axlsx
12
24
  # @return [String]
13
25
  attr_reader :name
14
26
 
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
27
  # @see sqref
26
28
  def sqref=(v)
27
29
  Axlsx.validate_string(v)
@@ -33,14 +35,15 @@ module Axlsx
33
35
  Axlsx.validate_string(v)
34
36
  @name = v
35
37
  end
36
-
38
+
37
39
  # serializes the proteted range
38
40
  # @param [String] str if this string object is provided we append
39
41
  # our output to that object. Use this - it helps limit the number of
40
42
  # objects created during serialization
41
43
  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
+ str << '<protectedRange '
45
+ serialized_attributes str
46
+ str << '/>'
44
47
  end
45
48
  end
46
49
  end
@@ -5,15 +5,28 @@ module Axlsx
5
5
  # @note The recommended way to manage the selection pane options is via SheetView#add_selection
6
6
  # @see SheetView#add_selection
7
7
  class Selection
8
-
8
+
9
+ include Axlsx::OptionsParser
10
+ include Axlsx::SerializedAttributes
11
+
12
+ # Creates a new {Selection} object
13
+ # @option options [Cell, String] active_cell Active Cell Location
14
+ # @option options [Integer] active_cell_id Active Cell Index
15
+ # @option options [Symbol] pane Pane
16
+ # @option options [String] sqref Sequence of References
17
+ def initialize(options={})
18
+ @active_cell = @active_cell_id = @pane = @sqref = nil
19
+ parse_options options
20
+ end
21
+
22
+ serializable_attributes :active_cell, :active_cell_id, :pane, :sqref
9
23
  # Active Cell Location
10
24
  # Location of the active cell.
11
25
  # @see type
12
26
  # @return [String]
13
27
  # default nil
14
28
  attr_reader :active_cell
15
-
16
-
29
+
17
30
  # Active Cell Index
18
31
  # 0-based index of the range reference (in the array of references listed in sqref)
19
32
  # containing the active cell. Only used when the selection in sqref is not contiguous.
@@ -24,8 +37,7 @@ module Axlsx
24
37
  # @return [Integer]
25
38
  # default nil
26
39
  attr_reader :active_cell_id
27
-
28
-
40
+
29
41
  # Pane
30
42
  # The pane to which this selection belongs.
31
43
  # Options are
@@ -52,59 +64,39 @@ module Axlsx
52
64
  # @return [Symbol]
53
65
  # default nil
54
66
  attr_reader :pane
55
-
56
-
67
+
57
68
  # Sequence of References
58
69
  # Range of the selection. Can be non-contiguous set of ranges.
59
70
  # @see type
60
71
  # @return [String]
61
72
  # default nil
62
73
  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
-
74
+
81
75
  # @see active_cell
82
76
  def active_cell=(v)
83
77
  cell = (v.class == Axlsx::Cell ? v.r_abs : v)
84
- Axlsx::validate_string(cell)
85
- @active_cell = cell
78
+ Axlsx::validate_string(cell)
79
+ @active_cell = cell
86
80
  end
87
-
88
-
81
+
89
82
  # @see active_cell_id
90
83
  def active_cell_id=(v); Axlsx::validate_unsigned_int(v); @active_cell_id = v end
91
-
92
-
84
+
93
85
  # @see pane
94
- def pane=(v); Axlsx::validate_pane_type(v); @pane = v end
95
-
96
-
86
+ def pane=(v)
87
+ Axlsx::validate_pane_type(v)
88
+ @pane = Axlsx::camel(v, false)
89
+ end
90
+
97
91
  # @see sqref
98
92
  def sqref=(v); Axlsx::validate_string(v); @sqref = v end
99
-
100
-
93
+
101
94
  # Serializes the data validation
102
95
  # @param [String] str
103
96
  # @return [String]
104
97
  def to_xml_string(str = '')
105
98
  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(' ')
99
+ serialized_attributes str
108
100
  str << '/>'
109
101
  end
110
102
  end
@@ -3,33 +3,20 @@ module Axlsx
3
3
  # the SheetCalcPr object for the worksheet
4
4
  # This object contains calculation properties for the worksheet.
5
5
  class SheetCalcPr
6
-
6
+ include Axlsx::OptionsParser
7
+ include Axlsx::SerializedAttributes
8
+ include Axlsx::Accessors
7
9
  # creates a new SheetCalcPr
8
10
  # @param [Hash] options Options for this object
9
11
  # @option [Boolean] full_calc_on_load @see full_calc_on_load
10
12
  def initialize(options={})
11
13
  @full_calc_on_load = true
12
- options.each do |key, value|
13
- self.send("#{key}=", value) if self.respond_to?("#{key}=")
14
- end
14
+ parse_options options
15
15
  end
16
16
 
17
- # Indicates whether the application should do a full calculate on
18
- # load due to contents on this sheet. After load and successful cal,c
19
- # the application shall set this value to false. Set this to true
20
- # when the application should calculate the workbook on load.
21
- # @return [Boolean]
22
- def full_calc_on_load
23
- @full_calc_on_load
24
- end
17
+ boolean_attr_accessor :full_calc_on_load
25
18
 
26
- # specify the full_calc_on_load value
27
- # @param [Boolean] value
28
- # @see full_calc_on_load
29
- def full_calc_on_load=(value)
30
- Axlsx.validate_boolean(value)
31
- @full_calc_on_load = value
32
- end
19
+ serializable_attributes :full_calc_on_load
33
20
 
34
21
  # Serialize the object
35
22
  # @param [String] str the string to append this objects serialized
@@ -38,12 +25,5 @@ module Axlsx
38
25
  def to_xml_string(str='')
39
26
  str << "<sheetCalcPr #{serialized_attributes}/>"
40
27
  end
41
-
42
- private
43
-
44
- def serialized_attributes
45
- instance_values.map { |key, value| "#{Axlsx.camel(key, false)}='#{value}'" }.join(' ')
46
- end
47
-
48
28
  end
49
29
  end
@@ -2,73 +2,44 @@ module Axlsx
2
2
 
3
3
  # The SheetPr class manages serialization fo a worksheet's sheetPr element.
4
4
  class SheetPr
5
-
5
+ include Axlsx::OptionsParser
6
+ include Axlsx::Accessors
7
+ include Axlsx::SerializedAttributes
8
+
9
+ serializable_attributes :sync_horizontal,
10
+ :sync_vertical,
11
+ :transtion_evaluation,
12
+ :transition_entry,
13
+ :published,
14
+ :filter_mode,
15
+ :enable_format_conditions_calculation,
16
+ :code_name,
17
+ :sync_ref
6
18
 
7
19
  # These attributes are all boolean so I'm doing a bit of a hand
8
20
  # waving magic show to set up the attriubte accessors
9
- BOOLEAN_ATTRIBUTES = [:sync_horizontal,
10
- :sync_vertical,
11
- :transtion_evaluation,
21
+ boolean_attr_accessor :sync_horizontal,
22
+ :sync_vertical,
23
+ :transtion_evaluation,
12
24
  :transition_entry,
13
25
  :published,
14
26
  :filter_mode,
15
- :enable_format_conditions_calculation]
27
+ :enable_format_conditions_calculation
16
28
 
29
+ string_attr_accessor :code_name, :sync_ref
17
30
 
18
31
  # Creates a new SheetPr object
19
32
  # @param [Worksheet] worksheet The worksheet that owns this SheetPr object
20
33
  def initialize(worksheet, options={})
21
34
  raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
22
35
  @worksheet = worksheet
23
- options.each do |key, value|
24
- attr = "#{key}="
25
- self.send(attr, value) if self.respond_to?(attr)
26
- end
36
+ parse_options options
27
37
  end
28
38
 
29
- # Dynamically create accessors for boolean attriubtes
30
- BOOLEAN_ATTRIBUTES.each do |attr|
31
- class_eval %{
32
- # The #{attr} attribute reader
33
- # @return [Boolean]
34
- attr_reader :#{attr}
35
-
36
- # The #{attr} writer
37
- # @param [Boolean] value The value to assign to #{attr}
38
- # @return [Boolean]
39
- def #{attr}=(value)
40
- Axlsx::validate_boolean(value)
41
- @#{attr} = value
42
- end
43
- }
44
- end
45
-
46
- # Anchor point for worksheet's window.
47
- # @return [String]
48
- attr_reader :code_name
49
-
50
- # Specifies a stable name of the sheet, which should not change over time,
51
- # and does not change from user input. This name should be used by code
52
- # to reference a particular sheet.
53
- # @return [String]
54
- attr_reader :sync_ref
55
-
56
39
  # The worksheet these properties apply to!
57
40
  # @return [Worksheet]
58
41
  attr_reader :worksheet
59
42
 
60
- # @see code_name
61
- # @param [String] name
62
- def code_name=(name)
63
- @code_name = name
64
- end
65
-
66
- # @see sync_ref
67
- # @param [String] ref A cell reference (e.g. "A1")
68
- def sync_ref=(ref)
69
- @sync_ref = ref
70
- end
71
-
72
43
  # Serialize the object
73
44
  # @param [String] str serialized output will be appended to this object if provided.
74
45
  # @return [String]
@@ -87,15 +58,6 @@ module Axlsx
87
58
 
88
59
  private
89
60
 
90
- def serialized_attributes(str = '')
91
- instance_values.each do |key, value|
92
- unless %(worksheet page_setup_pr).include? key
93
- str << "#{Axlsx.camel(key, false)}='#{value}' "
94
- end
95
- end
96
- str
97
- end
98
-
99
61
  def update_properties
100
62
  page_setup_pr.fit_to_page = worksheet.fit_to_page?
101
63
  if worksheet.auto_filter.columns.size > 0