caxlsx 3.3.0 → 4.5.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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +87 -11
  3. data/README.md +43 -16
  4. data/Rakefile +5 -11
  5. data/examples/generate.rb +3 -1
  6. data/lib/axlsx/content_type/abstract_content_type.rb +15 -10
  7. data/lib/axlsx/content_type/content_type.rb +8 -10
  8. data/lib/axlsx/content_type/default.rb +7 -6
  9. data/lib/axlsx/content_type/override.rb +6 -5
  10. data/lib/axlsx/doc_props/app.rb +96 -32
  11. data/lib/axlsx/doc_props/core.rb +9 -12
  12. data/lib/axlsx/drawing/area_chart.rb +16 -17
  13. data/lib/axlsx/drawing/area_series.rb +23 -18
  14. data/lib/axlsx/drawing/ax_data_source.rb +4 -7
  15. data/lib/axlsx/drawing/axes.rb +11 -10
  16. data/lib/axlsx/drawing/axis.rb +83 -36
  17. data/lib/axlsx/drawing/bar_3D_chart.rb +30 -21
  18. data/lib/axlsx/drawing/bar_chart.rb +29 -20
  19. data/lib/axlsx/drawing/bar_series.rb +23 -18
  20. data/lib/axlsx/drawing/bubble_chart.rb +9 -10
  21. data/lib/axlsx/drawing/bubble_series.rb +11 -12
  22. data/lib/axlsx/drawing/cat_axis.rb +38 -28
  23. data/lib/axlsx/drawing/chart.rb +52 -30
  24. data/lib/axlsx/drawing/d_lbls.rb +36 -32
  25. data/lib/axlsx/drawing/drawing.rb +61 -62
  26. data/lib/axlsx/drawing/graphic_frame.rb +6 -7
  27. data/lib/axlsx/drawing/hyperlink.rb +22 -14
  28. data/lib/axlsx/drawing/line_3D_chart.rb +15 -17
  29. data/lib/axlsx/drawing/line_chart.rb +16 -17
  30. data/lib/axlsx/drawing/line_series.rb +23 -18
  31. data/lib/axlsx/drawing/marker.rb +29 -16
  32. data/lib/axlsx/drawing/num_data.rb +13 -16
  33. data/lib/axlsx/drawing/num_data_source.rb +11 -13
  34. data/lib/axlsx/drawing/num_val.rb +10 -11
  35. data/lib/axlsx/drawing/one_cell_anchor.rb +16 -10
  36. data/lib/axlsx/drawing/pic.rb +68 -24
  37. data/lib/axlsx/drawing/picture_locking.rb +6 -7
  38. data/lib/axlsx/drawing/pie_3D_chart.rb +9 -12
  39. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  40. data/lib/axlsx/drawing/pie_series.rb +26 -17
  41. data/lib/axlsx/drawing/scaling.rb +26 -13
  42. data/lib/axlsx/drawing/scatter_chart.rb +10 -11
  43. data/lib/axlsx/drawing/scatter_series.rb +17 -18
  44. data/lib/axlsx/drawing/ser_axis.rb +22 -19
  45. data/lib/axlsx/drawing/series.rb +14 -8
  46. data/lib/axlsx/drawing/series_title.rb +6 -6
  47. data/lib/axlsx/drawing/str_data.rb +10 -13
  48. data/lib/axlsx/drawing/str_val.rb +8 -9
  49. data/lib/axlsx/drawing/title.rb +23 -27
  50. data/lib/axlsx/drawing/two_cell_anchor.rb +9 -9
  51. data/lib/axlsx/drawing/val_axis.rb +7 -8
  52. data/lib/axlsx/drawing/view_3D.rb +38 -30
  53. data/lib/axlsx/drawing/vml_drawing.rb +19 -20
  54. data/lib/axlsx/drawing/vml_shape.rb +25 -26
  55. data/lib/axlsx/package.rb +134 -99
  56. data/lib/axlsx/rels/relationship.rb +42 -30
  57. data/lib/axlsx/rels/relationships.rb +9 -10
  58. data/lib/axlsx/stylesheet/border.rb +16 -8
  59. data/lib/axlsx/stylesheet/border_pr.rb +24 -12
  60. data/lib/axlsx/stylesheet/cell_alignment.rb +44 -21
  61. data/lib/axlsx/stylesheet/cell_protection.rb +13 -7
  62. data/lib/axlsx/stylesheet/cell_style.rb +36 -15
  63. data/lib/axlsx/stylesheet/color.rb +23 -14
  64. data/lib/axlsx/stylesheet/dxf.rb +36 -15
  65. data/lib/axlsx/stylesheet/fill.rb +7 -6
  66. data/lib/axlsx/stylesheet/font.rb +71 -22
  67. data/lib/axlsx/stylesheet/gradient_fill.rb +16 -10
  68. data/lib/axlsx/stylesheet/gradient_stop.rb +14 -6
  69. data/lib/axlsx/stylesheet/num_fmt.rb +15 -14
  70. data/lib/axlsx/stylesheet/pattern_fill.rb +20 -8
  71. data/lib/axlsx/stylesheet/styles.rb +167 -118
  72. data/lib/axlsx/stylesheet/table_style.rb +20 -10
  73. data/lib/axlsx/stylesheet/table_style_element.rb +16 -8
  74. data/lib/axlsx/stylesheet/table_styles.rb +16 -11
  75. data/lib/axlsx/stylesheet/theme.rb +163 -0
  76. data/lib/axlsx/stylesheet/xf.rb +78 -25
  77. data/lib/axlsx/util/accessors.rb +13 -11
  78. data/lib/axlsx/util/buffered_zip_output_stream.rb +64 -0
  79. data/lib/axlsx/util/constants.rb +133 -110
  80. data/lib/axlsx/util/mime_type_utils.rb +75 -5
  81. data/lib/axlsx/util/options_parser.rb +4 -3
  82. data/lib/axlsx/util/serialized_attributes.rb +47 -23
  83. data/lib/axlsx/util/simple_typed_list.rb +77 -64
  84. data/lib/axlsx/util/storage.rb +38 -41
  85. data/lib/axlsx/util/uri_utils.rb +70 -0
  86. data/lib/axlsx/util/validators.rb +111 -48
  87. data/lib/axlsx/util/zip_command.rb +10 -12
  88. data/lib/axlsx/version.rb +3 -2
  89. data/lib/axlsx/workbook/defined_name.rb +13 -9
  90. data/lib/axlsx/workbook/defined_names.rb +5 -4
  91. data/lib/axlsx/workbook/shared_strings_table.rb +13 -14
  92. data/lib/axlsx/workbook/workbook.rb +152 -120
  93. data/lib/axlsx/workbook/workbook_view.rb +9 -12
  94. data/lib/axlsx/workbook/workbook_views.rb +5 -5
  95. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +87 -15
  96. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +16 -10
  97. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +28 -25
  98. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
  99. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +54 -0
  100. data/lib/axlsx/workbook/worksheet/border_creator.rb +34 -29
  101. data/lib/axlsx/workbook/worksheet/break.rb +4 -5
  102. data/lib/axlsx/workbook/worksheet/cell.rb +125 -78
  103. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +33 -29
  104. data/lib/axlsx/workbook/worksheet/cfvo.rb +13 -5
  105. data/lib/axlsx/workbook/worksheet/cfvos.rb +5 -5
  106. data/lib/axlsx/workbook/worksheet/col.rb +32 -19
  107. data/lib/axlsx/workbook/worksheet/col_breaks.rb +9 -8
  108. data/lib/axlsx/workbook/worksheet/color_scale.rb +16 -16
  109. data/lib/axlsx/workbook/worksheet/cols.rb +10 -8
  110. data/lib/axlsx/workbook/worksheet/comment.rb +14 -13
  111. data/lib/axlsx/workbook/worksheet/comments.rb +11 -13
  112. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +19 -9
  113. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +75 -22
  114. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +8 -8
  115. data/lib/axlsx/workbook/worksheet/data_bar.rb +29 -30
  116. data/lib/axlsx/workbook/worksheet/data_validation.rb +73 -33
  117. data/lib/axlsx/workbook/worksheet/data_validations.rb +8 -9
  118. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +8 -8
  119. data/lib/axlsx/workbook/worksheet/dimension.rb +10 -7
  120. data/lib/axlsx/workbook/worksheet/header_footer.rb +5 -4
  121. data/lib/axlsx/workbook/worksheet/icon_set.rb +40 -12
  122. data/lib/axlsx/workbook/worksheet/merged_cells.rb +11 -11
  123. data/lib/axlsx/workbook/worksheet/outline_pr.rb +7 -4
  124. data/lib/axlsx/workbook/worksheet/page_margins.rb +41 -13
  125. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +7 -6
  126. data/lib/axlsx/workbook/worksheet/page_setup.rb +153 -131
  127. data/lib/axlsx/workbook/worksheet/pane.rb +34 -26
  128. data/lib/axlsx/workbook/worksheet/pivot_table.rb +78 -29
  129. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +12 -13
  130. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +6 -5
  131. data/lib/axlsx/workbook/worksheet/print_options.rb +4 -2
  132. data/lib/axlsx/workbook/worksheet/protected_range.rb +6 -5
  133. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +13 -11
  134. data/lib/axlsx/workbook/worksheet/rich_text.rb +6 -6
  135. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +66 -28
  136. data/lib/axlsx/workbook/worksheet/row.rb +34 -23
  137. data/lib/axlsx/workbook/worksheet/row_breaks.rb +9 -8
  138. data/lib/axlsx/workbook/worksheet/selection.rb +22 -16
  139. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +11 -7
  140. data/lib/axlsx/workbook/worksheet/sheet_data.rb +7 -7
  141. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +23 -19
  142. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +12 -8
  143. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +22 -21
  144. data/lib/axlsx/workbook/worksheet/sheet_view.rb +71 -55
  145. data/lib/axlsx/workbook/worksheet/table.rb +13 -13
  146. data/lib/axlsx/workbook/worksheet/table_style_info.rb +8 -6
  147. data/lib/axlsx/workbook/worksheet/tables.rb +8 -6
  148. data/lib/axlsx/workbook/worksheet/worksheet.rb +120 -79
  149. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +13 -11
  150. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +11 -4
  151. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +12 -10
  152. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +9 -7
  153. data/lib/axlsx.rb +120 -60
  154. data/lib/caxlsx.rb +3 -2
  155. metadata +42 -75
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # Conditional Format Rule icon sets
3
5
  # Describes an icon set conditional formatting rule.
@@ -6,7 +8,6 @@ module Axlsx
6
8
  # @see Worksheet#add_conditional_formatting
7
9
  # @see ConditionalFormattingRule#initialize
8
10
  class IconSet
9
-
10
11
  include Axlsx::OptionsParser
11
12
  include Axlsx::SerializedAttributes
12
13
 
@@ -19,8 +20,10 @@ module Axlsx
19
20
  @percent = @showValue = true
20
21
  @reverse = false
21
22
  @iconSet = "3TrafficLights1"
22
- initialize_value_objects
23
+ @interpolationPoints = [0, 33, 67]
24
+
23
25
  parse_options options
26
+
24
27
  yield self if block_given?
25
28
  end
26
29
 
@@ -33,7 +36,7 @@ module Axlsx
33
36
  attr_reader :iconSet
34
37
 
35
38
  # Indicates whether the thresholds indicate percentile values, instead of number values.
36
- # The default falue is true
39
+ # The default value is true
37
40
  # @return [Boolean]
38
41
  attr_reader :percent
39
42
 
@@ -47,22 +50,48 @@ module Axlsx
47
50
  # @return [Boolean]
48
51
  attr_reader :showValue
49
52
 
50
- # @see iconSet
51
- def iconSet=(v); Axlsx::validate_icon_set(v); @iconSet = v end
53
+ # Sets the values of the interpolation points in the scale.
54
+ # The default value is [0, 33, 67]
55
+ # @return [Integer]
56
+ attr_reader :interpolationPoints
57
+
58
+ # @see iconSet
59
+ def iconSet=(v)
60
+ Axlsx.validate_icon_set(v)
61
+ @iconSet = v
62
+ end
63
+
64
+ # @see interpolationPoints
65
+ def interpolationPoints=(v)
66
+ v.each { |point| Axlsx.validate_int(point) }
67
+ @value_objects = nil
68
+ @interpolationPoints = v
69
+ end
52
70
 
53
71
  # @see showValue
54
- def showValue=(v); Axlsx.validate_boolean(v); @showValue = v end
72
+ def showValue=(v)
73
+ Axlsx.validate_boolean(v)
74
+ @showValue = v
75
+ end
55
76
 
56
77
  # @see percent
57
- def percent=(v); Axlsx.validate_boolean(v); @percent = v end
78
+ def percent=(v)
79
+ Axlsx.validate_boolean(v)
80
+ @percent = v
81
+ end
58
82
 
59
83
  # @see reverse
60
- def reverse=(v); Axlsx.validate_boolean(v); @reverse = v end
84
+ def reverse=(v)
85
+ Axlsx.validate_boolean(v)
86
+ @reverse = v
87
+ end
61
88
 
62
89
  # Serialize this object to an xml string
63
90
  # @param [String] str
64
91
  # @return [String]
65
- def to_xml_string(str="")
92
+ def to_xml_string(str = +'')
93
+ initialize_value_objects if @value_objects.nil?
94
+
66
95
  serialized_tag('iconSet', str) do
67
96
  @value_objects.each { |cfvo| cfvo.to_xml_string(str) }
68
97
  end
@@ -70,11 +99,10 @@ module Axlsx
70
99
 
71
100
  private
72
101
 
73
- # Initalize the simple typed list of value objects
74
- # I am keeping this private for now as I am not sure what impact changes to the required two cfvo objects will do.
102
+ # Initialize the simple typed list of value objects
75
103
  def initialize_value_objects
76
104
  @value_objects = SimpleTypedList.new Cfvo
77
- @value_objects.concat [Cfvo.new(:type => :percent, :val => 0), Cfvo.new(:type => :percent, :val => 33), Cfvo.new(:type => :percent, :val => 67)]
105
+ @interpolationPoints.each { |point| @value_objects << Cfvo.new(type: :percent, val: point) }
78
106
  @value_objects.lock
79
107
  end
80
108
  end
@@ -1,34 +1,34 @@
1
- module Axlsx
1
+ # frozen_string_literal: true
2
2
 
3
+ module Axlsx
3
4
  # A simple list of merged cells
4
5
  class MergedCells < SimpleTypedList
5
-
6
6
  # creates a new MergedCells object
7
7
  # @param [Worksheet] worksheet
8
8
  def initialize(worksheet)
9
9
  raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
10
- super String
10
+
11
+ super(String)
11
12
  end
12
13
 
13
14
  # adds cells to the merged cells collection
14
- # @param [Array||String] cells The cells to add to the merged cells
15
+ # @param [Array|String] cells The cells to add to the merged cells
15
16
  # collection. This can be an array of actual cells or a string style
16
17
  # range like 'A1:C1'
17
18
  def add(cells)
18
19
  self << if cells.is_a?(String)
19
- cells
20
- elsif cells.is_a?(Array)
21
- Axlsx::cell_range(cells, false)
22
- elsif cells.is_a?(Row)
23
- Axlsx::cell_range(cells, false)
24
- end
20
+ cells
21
+ elsif cells.is_a?(Array)
22
+ Axlsx.cell_range(cells, false)
23
+ end
25
24
  end
26
25
 
27
26
  # serialize the object
28
27
  # @param [String] str
29
28
  # @return [String]
30
- def to_xml_string(str = '')
29
+ def to_xml_string(str = +'')
31
30
  return if empty?
31
+
32
32
  str << "<mergeCells count='#{size}'>"
33
33
  each { |merged_cell| str << "<mergeCell ref='#{merged_cell}'></mergeCell>" }
34
34
  str << '</mergeCells>'
@@ -1,5 +1,6 @@
1
- module Axlsx
1
+ # frozen_string_literal: true
2
2
 
3
+ module Axlsx
3
4
  # The OutlinePr class manages serialization of a worksheet's outlinePr element, which provides various
4
5
  # options to control outlining.
5
6
  class OutlinePr
@@ -12,7 +13,7 @@ module Axlsx
12
13
  :apply_styles
13
14
 
14
15
  # These attributes are all boolean so I'm doing a bit of a hand
15
- # waving magic show to set up the attriubte accessors
16
+ # waving magic show to set up the attribute accessors
16
17
  boolean_attr_accessor :summary_below,
17
18
  :summary_right,
18
19
  :apply_styles
@@ -26,8 +27,10 @@ module Axlsx
26
27
  # Serialize the object
27
28
  # @param [String] str serialized output will be appended to this object if provided.
28
29
  # @return [String]
29
- def to_xml_string(str = '')
30
- str << "<outlinePr #{serialized_attributes} />"
30
+ def to_xml_string(str = +'')
31
+ str << '<outlinePr '
32
+ serialized_attributes(str)
33
+ str << '/>'
31
34
  end
32
35
  end
33
36
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # PageMargins specify the margins when printing a worksheet.
3
5
  #
@@ -9,7 +11,6 @@ module Axlsx
9
11
  # @see Worksheet#page_margins
10
12
  # @see Worksheet#initialize
11
13
  class PageMargins
12
-
13
14
  include Axlsx::OptionsParser
14
15
  include Axlsx::SerializedAttributes
15
16
 
@@ -20,7 +21,7 @@ module Axlsx
20
21
  # @option options [Numeric] top The top margin in inches
21
22
  # @option options [Numeric] header The header margin in inches
22
23
  # @option options [Numeric] footer The footer margin in inches
23
- def initialize(options={})
24
+ def initialize(options = {})
24
25
  # Default values taken from MS Excel for Mac 2011
25
26
  @left = @right = DEFAULT_LEFT_RIGHT
26
27
  @top = @bottom = DEFAULT_TOP_BOTTOM
@@ -28,7 +29,10 @@ module Axlsx
28
29
  parse_options options
29
30
  end
30
31
 
31
- serializable_attributes :left, :right, :bottom, :top, :header, :footer
32
+ # Possible margins to set
33
+ MARGIN_KEYS = [:left, :right, :top, :bottom, :header, :footer].freeze
34
+
35
+ serializable_attributes(*MARGIN_KEYS)
32
36
 
33
37
  # Default left and right margin (in inches)
34
38
  DEFAULT_LEFT_RIGHT = 0.75
@@ -64,33 +68,57 @@ module Axlsx
64
68
  attr_reader :footer
65
69
 
66
70
  # Set some or all margins at once.
67
- # @param [Hash] margins the margins to set (possible keys are :left, :right, :top, :bottom, :header and :footer).
71
+ # @param [Hash] margins the margins to set. See {MARGIN_KEYS} for a list of possible keys.
68
72
  def set(margins)
69
73
  margins.select do |k, v|
70
- next unless [:left, :right, :top, :bottom, :header, :footer].include? k
71
- send("#{k}=", v)
74
+ next unless MARGIN_KEYS.include? k
75
+
76
+ send(:"#{k}=", v)
72
77
  end
73
78
  end
74
79
 
75
80
  # @see left
76
- def left=(v); Axlsx::validate_unsigned_numeric(v); @left = v end
81
+ def left=(v)
82
+ Axlsx.validate_unsigned_numeric(v)
83
+ @left = v
84
+ end
85
+
77
86
  # @see right
78
- def right=(v); Axlsx::validate_unsigned_numeric(v); @right = v end
87
+ def right=(v)
88
+ Axlsx.validate_unsigned_numeric(v)
89
+ @right = v
90
+ end
91
+
79
92
  # @see top
80
- def top=(v); Axlsx::validate_unsigned_numeric(v); @top = v end
93
+ def top=(v)
94
+ Axlsx.validate_unsigned_numeric(v)
95
+ @top = v
96
+ end
97
+
81
98
  # @see bottom
82
- def bottom=(v); Axlsx::validate_unsigned_numeric(v); @bottom = v end
99
+ def bottom=(v)
100
+ Axlsx.validate_unsigned_numeric(v)
101
+ @bottom = v
102
+ end
103
+
83
104
  # @see header
84
- def header=(v); Axlsx::validate_unsigned_numeric(v); @header = v end
105
+ def header=(v)
106
+ Axlsx.validate_unsigned_numeric(v)
107
+ @header = v
108
+ end
109
+
85
110
  # @see footer
86
- def footer=(v); Axlsx::validate_unsigned_numeric(v); @footer = v end
111
+ def footer=(v)
112
+ Axlsx.validate_unsigned_numeric(v)
113
+ @footer = v
114
+ end
87
115
 
88
116
  # Serializes the page margins element
89
117
  # @param [String] str
90
118
  # @return [String]
91
119
  # @note For compatibility, this is a noop unless custom margins have been specified.
92
120
  # @see #custom_margins_specified?
93
- def to_xml_string(str = '')
121
+ def to_xml_string(str = +'')
94
122
  serialized_tag('pageMargins', str)
95
123
  end
96
124
  end
@@ -1,9 +1,9 @@
1
- module Axlsx
1
+ # frozen_string_literal: true
2
2
 
3
+ module Axlsx
3
4
  # Page setup properties of the worksheet
4
5
  # This class name is not a typo, its spec.
5
6
  class PageSetUpPr
6
-
7
7
  include Axlsx::OptionsParser
8
8
  include Axlsx::SerializedAttributes
9
9
 
@@ -17,8 +17,7 @@ module Axlsx
17
17
 
18
18
  serializable_attributes :auto_page_breaks, :fit_to_page
19
19
 
20
- attr_reader :auto_page_breaks
21
- attr_reader :fit_to_page
20
+ attr_reader :auto_page_breaks, :fit_to_page
22
21
 
23
22
  # Flag indicating whether the Fit to Page print option is enabled.
24
23
  # @param [Boolean] value
@@ -37,8 +36,10 @@ module Axlsx
37
36
  end
38
37
 
39
38
  # serialize to xml
40
- def to_xml_string(str='')
41
- str << ('<pageSetUpPr ' << serialized_attributes << '/>')
39
+ def to_xml_string(str = +'')
40
+ str << '<pageSetUpPr '
41
+ serialized_attributes(str)
42
+ str << '/>'
42
43
  end
43
44
  end
44
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # Page setup settings for printing a worksheet. All settings are optional.
3
5
  #
@@ -5,7 +7,6 @@ module Axlsx
5
7
  # @see Worksheet#print_options
6
8
  # @see Worksheet#initialize
7
9
  class PageSetup
8
-
9
10
  include Axlsx::OptionsParser
10
11
  include Axlsx::SerializedAttributes
11
12
 
@@ -18,7 +19,7 @@ module Axlsx
18
19
  # @option options [Integer] scale Print scaling (percent value, integer ranging from 10 to 400)
19
20
  # @option options [Integer] paper_size - the size of paper to use
20
21
  def initialize(options = {})
21
- parse_options options
22
+ parse_options options
22
23
  end
23
24
 
24
25
  serializable_attributes :fit_to_height, :fit_to_width, :orientation, :paper_height, :paper_width, :scale, :paper_size
@@ -37,13 +38,13 @@ module Axlsx
37
38
  # * verticalDpi
38
39
 
39
40
  # Number of vertical pages to fit on.
40
- # @note PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of fit_to_width/fit_to_height will result in the counterpart
41
+ # @note PageSetup#fit_to is the recommended way to manage page fitting as only specifying one of fit_to_width/fit_to_height will result in the counterpart
41
42
  # being set to 1.
42
43
  # @return [Integer]
43
44
  attr_reader :fit_to_height
44
45
 
45
46
  # Number of horizontal pages to fit on.
46
- # @note PageSetup#fit_to is the recomended way to manage page fitting as only specifying one of width/height will result in the counterpart
47
+ # @note PageSetup#fit_to is the recommended way to manage page fitting as only specifying one of width/height will result in the counterpart
47
48
  # being set to 1.
48
49
  # @return [Integer]
49
50
  attr_reader :fit_to_width
@@ -65,124 +66,123 @@ module Axlsx
65
66
  attr_reader :scale
66
67
 
67
68
  # The paper size to use in printing
68
- #1 = Letter paper (8.5 in. by 11 in.)
69
- #2 = Letter small paper (8.5 in. by 11 in.)
70
- #3 = Tabloid paper (11 in. by 17 in.)
71
- #4 = Ledger paper (17 in. by 11 in.)
72
- #5 = Legal paper (8.5 in. by 14 in.)
73
- #6 = Statement paper (5.5 in. by 8.5 in.)
74
- #7 = Executive paper (7.25 in. by 10.5 in.)
75
- #8 = A3 paper (297 mm by 420 mm)
76
- #9 = A4 paper (210 mm by 297 mm)
77
- #10 = A4 small paper (210 mm by 297 mm)
78
- #11 = A5 paper (148 mm by 210 mm)
79
- #12 = B4 paper (250 mm by 353 mm)
80
- #13 = B5 paper (176 mm by 250 mm)
81
- #14 = Folio paper (8.5 in. by 13 in.)
82
- #15 = Quarto paper (215 mm by 275 mm)
83
- #16 = Standard paper (10 in. by 14 in.)
84
- #17 = Standard paper (11 in. by 17 in.)
85
- #18 = Note paper (8.5 in. by 11 in.)
86
- #19 = #9 envelope (3.875 in. by 8.875 in.)
87
- #20 = #10 envelope (4.125 in. by 9.5 in.)
88
- #21 = #11 envelope (4.5 in. by 10.375 in.)
89
- #22 = #12 envelope (4.75 in. by 11 in.)
90
- #23 = #14 envelope (5 in. by 11.5 in.) 24 = C paper (17 in. by 22 in.)
91
- #25 = D paper (22 in. by 34 in.)
92
- #26 = E paper (34 in. by 44 in.)
93
- #27 = DL envelope (110 mm by 220 mm)
94
- #28 = C5 envelope (162 mm by 229 mm)
95
- #29 = C3 envelope (324 mm by 458 mm)
96
- #30 = C4 envelope (229 mm by 324 mm)
97
- #31 = C6 envelope (114 mm by 162 mm)
98
- #32 = C65 envelope (114 mm by 229 mm)
99
- #33 = B4 envelope (250 mm by 353 mm)
100
- #34 = B5 envelope (176 mm by 250 mm)
101
- #35 = B6 envelope (176 mm by 125 mm)
102
- #36 = Italy envelope (110 mm by 230 mm)
103
- #37 = Monarch envelope (3.875 in. by 7.5 in.). 38 = 6 3/4 envelope (3.625 in. by 6.5 in.)
104
- #39 = US standard fanfold (14.875 in. by 11 in.)
105
- #40 = German standard fanfold (8.5 in. by 12 in.)
106
- #41 = German legal fanfold (8.5 in. by 13 in.)
107
- #42 = ISO B4 (250 mm by 353 mm)
108
- #43 = Japanese double postcard (200 mm by 148 mm)
109
- #44 = Standard paper (9 in. by 11 in.)
110
- #45 = Standard paper (10 in. by 11 in.)
111
- #46 = Standard paper (15 in. by 11 in.)
112
- #47 = Invite envelope (220 mm by 220 mm)
113
- #50 = Letter extra paper (9.275 in. by 12 in.)
114
- #51 = Legal extra paper (9.275 in. by 15 in.)
115
- #52 = Tabloid extra paper (11.69 in. by 18 in.)
116
- #53 = A4 extra paper (236 mm by 322 mm)
117
- #54 = Letter transverse paper (8.275 in. by 11 in.)
118
- #55 = A4 transverse paper (210 mm by 297 mm)
119
- #56 = Letter extra transverse paper (9.275 in. by 12 in.)
120
- #57 = SuperA/SuperA/A4 paper (227 mm by 356 mm)
121
- #58 = SuperB/SuperB/A3 paper (305 mm by 487 mm)
122
- #59 = Letter plus paper (8.5 in. by 12.69 in.)
123
- #60 = A4 plus paper (210 mm by 330 mm)
124
- #61 = A5 transverse paper (148 mm by 210 mm)
125
- #62 = JIS B5 transverse paper (182 mm by 257 mm)
126
- #63 = A3 extra paper (322 mm by 445 mm)
127
- #64 = A5 extra paper (174 mm by 235 mm)
128
- #65 = ISO B5 extra paper (201 mm by 276 mm)
129
- #66 = A2 paper (420 mm by 594 mm)
130
- #67 = A3 transverse paper (297 mm by 420 mm)
131
- #68 = A3 extra transverse paper (322 mm by 445 mm)
132
- #69 = Japanese Double Postcard (200 mm x 148 mm)
133
- #70 = A6 (105 mm x 148 mm
134
- #71 = Japanese Envelope Kaku #2
135
- #72 = Japanese Envelope Kaku #3
136
- #73 = Japanese Envelope Chou #3
137
- #74 = Japanese Envelope Chou #4
138
- #75 = Letter Rotated (11in x 8 1/2 11 in)
139
- #76 = A3 Rotated (420 mm x 297 mm)
140
- #77 = A4 Rotated (297 mm x 210 mm)
141
- #78 = A5 Rotated (210 mm x 148 mm)
142
- #79 = B4 (JIS) Rotated (364 mm x 257 mm)
143
- #80 = B5 (JIS) Rotated (257 mm x 182 mm)
144
- #81 = Japanese Postcard Rotated (148 mm x 100 mm)
145
- #82 = Double Japanese Postcard Rotated (148 mm x 200 mm)
146
- #83 = A6 Rotated (148 mm x 105 mm)
147
- #84 = Japanese Envelope Kaku #2 Rotated
148
- #85 = Japanese Envelope Kaku #3 Rotated
149
- #86 = Japanese Envelope Chou #3 Rotated
150
- #87 = Japanese Envelope Chou #4 Rotated
151
- #88 = B6 (JIS) (128 mm x 182 mm)
152
- #89 = B6 (JIS) Rotated (182 mm x 128 mm)
153
- #90 = (12 in x 11 in)
154
- #91 = Japanese Envelope You #4
155
- #92 = Japanese Envelope You #4 Rotated
156
- #93 = PRC 16K (146 mm x 215 mm)
157
- #94 = PRC 32K (97 mm x 151 mm)
158
- #95 = PRC 32K(Big) (97 mm x 151 mm)
159
- #96 = PRC Envelope #1 (102 mm x 165 mm)
160
- #97 = PRC Envelope #2 (102 mm x 176 mm)
161
- #98 = PRC Envelope #3 (125 mm x 176 mm)
162
- #99 = PRC Envelope #4 (110 mm x 208 mm)
163
- #100 = PRC Envelope #5 (110 mm x 220 mm)
164
- #101 = PRC Envelope #6 (120 mm x 230 mm)
165
- #102 = PRC Envelope #7 (160 mm x 230 mm)
166
- #103 = PRC Envelope #8 (120 mm x 309 mm)
167
- #104 = PRC Envelope #9 (229 mm x 324 mm)
168
- #105 = PRC Envelope #10 (324 mm x 458 mm)
169
- #106 = PRC 16K Rotated
170
- #107 = PRC 32K Rotated
171
- #108 = PRC 32K(Big) Rotated
172
- #109 = PRC Envelope #1 Rotated (165 mm x 102 mm)
173
- #110 = PRC Envelope #2 Rotated (176 mm x 102 mm)
174
- #111 = PRC Envelope #3 Rotated (176 mm x 125 mm)
175
- #112 = PRC Envelope #4 Rotated (208 mm x 110 mm)
176
- #113 = PRC Envelope #5 Rotated (220 mm x 110 mm)
177
- #114 = PRC Envelope #6 Rotated (230 mm x 120 mm)
178
- #115 = PRC Envelope #7 Rotated (230 mm x 160 mm)
179
- #116 = PRC Envelope #8 Rotated (309 mm x 120 mm)
180
- #117 = PRC Envelope #9 Rotated (324 mm x 229 mm)
181
- #118 = PRC Envelope #10 Rotated (458 mm x 324 mm)
69
+ # 1 = Letter paper (8.5 in. by 11 in.)
70
+ # 2 = Letter small paper (8.5 in. by 11 in.)
71
+ # 3 = Tabloid paper (11 in. by 17 in.)
72
+ # 4 = Ledger paper (17 in. by 11 in.)
73
+ # 5 = Legal paper (8.5 in. by 14 in.)
74
+ # 6 = Statement paper (5.5 in. by 8.5 in.)
75
+ # 7 = Executive paper (7.25 in. by 10.5 in.)
76
+ # 8 = A3 paper (297 mm by 420 mm)
77
+ # 9 = A4 paper (210 mm by 297 mm)
78
+ # 10 = A4 small paper (210 mm by 297 mm)
79
+ # 11 = A5 paper (148 mm by 210 mm)
80
+ # 12 = B4 paper (250 mm by 353 mm)
81
+ # 13 = B5 paper (176 mm by 250 mm)
82
+ # 14 = Folio paper (8.5 in. by 13 in.)
83
+ # 15 = Quarto paper (215 mm by 275 mm)
84
+ # 16 = Standard paper (10 in. by 14 in.)
85
+ # 17 = Standard paper (11 in. by 17 in.)
86
+ # 18 = Note paper (8.5 in. by 11 in.)
87
+ # 19 = #9 envelope (3.875 in. by 8.875 in.)
88
+ # 20 = #10 envelope (4.125 in. by 9.5 in.)
89
+ # 21 = #11 envelope (4.5 in. by 10.375 in.)
90
+ # 22 = #12 envelope (4.75 in. by 11 in.)
91
+ # 23 = #14 envelope (5 in. by 11.5 in.) 24 = C paper (17 in. by 22 in.)
92
+ # 25 = D paper (22 in. by 34 in.)
93
+ # 26 = E paper (34 in. by 44 in.)
94
+ # 27 = DL envelope (110 mm by 220 mm)
95
+ # 28 = C5 envelope (162 mm by 229 mm)
96
+ # 29 = C3 envelope (324 mm by 458 mm)
97
+ # 30 = C4 envelope (229 mm by 324 mm)
98
+ # 31 = C6 envelope (114 mm by 162 mm)
99
+ # 32 = C65 envelope (114 mm by 229 mm)
100
+ # 33 = B4 envelope (250 mm by 353 mm)
101
+ # 34 = B5 envelope (176 mm by 250 mm)
102
+ # 35 = B6 envelope (176 mm by 125 mm)
103
+ # 36 = Italy envelope (110 mm by 230 mm)
104
+ # 37 = Monarch envelope (3.875 in. by 7.5 in.). 38 = 6 3/4 envelope (3.625 in. by 6.5 in.)
105
+ # 39 = US standard fanfold (14.875 in. by 11 in.)
106
+ # 40 = German standard fanfold (8.5 in. by 12 in.)
107
+ # 41 = German legal fanfold (8.5 in. by 13 in.)
108
+ # 42 = ISO B4 (250 mm by 353 mm)
109
+ # 43 = Japanese double postcard (200 mm by 148 mm)
110
+ # 44 = Standard paper (9 in. by 11 in.)
111
+ # 45 = Standard paper (10 in. by 11 in.)
112
+ # 46 = Standard paper (15 in. by 11 in.)
113
+ # 47 = Invite envelope (220 mm by 220 mm)
114
+ # 50 = Letter extra paper (9.275 in. by 12 in.)
115
+ # 51 = Legal extra paper (9.275 in. by 15 in.)
116
+ # 52 = Tabloid extra paper (11.69 in. by 18 in.)
117
+ # 53 = A4 extra paper (236 mm by 322 mm)
118
+ # 54 = Letter transverse paper (8.275 in. by 11 in.)
119
+ # 55 = A4 transverse paper (210 mm by 297 mm)
120
+ # 56 = Letter extra transverse paper (9.275 in. by 12 in.)
121
+ # 57 = SuperA/SuperA/A4 paper (227 mm by 356 mm)
122
+ # 58 = SuperB/SuperB/A3 paper (305 mm by 487 mm)
123
+ # 59 = Letter plus paper (8.5 in. by 12.69 in.)
124
+ # 60 = A4 plus paper (210 mm by 330 mm)
125
+ # 61 = A5 transverse paper (148 mm by 210 mm)
126
+ # 62 = JIS B5 transverse paper (182 mm by 257 mm)
127
+ # 63 = A3 extra paper (322 mm by 445 mm)
128
+ # 64 = A5 extra paper (174 mm by 235 mm)
129
+ # 65 = ISO B5 extra paper (201 mm by 276 mm)
130
+ # 66 = A2 paper (420 mm by 594 mm)
131
+ # 67 = A3 transverse paper (297 mm by 420 mm)
132
+ # 68 = A3 extra transverse paper (322 mm by 445 mm)
133
+ # 69 = Japanese Double Postcard (200 mm x 148 mm)
134
+ # 70 = A6 (105 mm x 148 mm
135
+ # 71 = Japanese Envelope Kaku #2
136
+ # 72 = Japanese Envelope Kaku #3
137
+ # 73 = Japanese Envelope Chou #3
138
+ # 74 = Japanese Envelope Chou #4
139
+ # 75 = Letter Rotated (11in x 8 1/2 11 in)
140
+ # 76 = A3 Rotated (420 mm x 297 mm)
141
+ # 77 = A4 Rotated (297 mm x 210 mm)
142
+ # 78 = A5 Rotated (210 mm x 148 mm)
143
+ # 79 = B4 (JIS) Rotated (364 mm x 257 mm)
144
+ # 80 = B5 (JIS) Rotated (257 mm x 182 mm)
145
+ # 81 = Japanese Postcard Rotated (148 mm x 100 mm)
146
+ # 82 = Double Japanese Postcard Rotated (148 mm x 200 mm)
147
+ # 83 = A6 Rotated (148 mm x 105 mm)
148
+ # 84 = Japanese Envelope Kaku #2 Rotated
149
+ # 85 = Japanese Envelope Kaku #3 Rotated
150
+ # 86 = Japanese Envelope Chou #3 Rotated
151
+ # 87 = Japanese Envelope Chou #4 Rotated
152
+ # 88 = B6 (JIS) (128 mm x 182 mm)
153
+ # 89 = B6 (JIS) Rotated (182 mm x 128 mm)
154
+ # 90 = (12 in x 11 in)
155
+ # 91 = Japanese Envelope You #4
156
+ # 92 = Japanese Envelope You #4 Rotated
157
+ # 93 = PRC 16K (146 mm x 215 mm)
158
+ # 94 = PRC 32K (97 mm x 151 mm)
159
+ # 95 = PRC 32K(Big) (97 mm x 151 mm)
160
+ # 96 = PRC Envelope #1 (102 mm x 165 mm)
161
+ # 97 = PRC Envelope #2 (102 mm x 176 mm)
162
+ # 98 = PRC Envelope #3 (125 mm x 176 mm)
163
+ # 99 = PRC Envelope #4 (110 mm x 208 mm)
164
+ # 100 = PRC Envelope #5 (110 mm x 220 mm)
165
+ # 101 = PRC Envelope #6 (120 mm x 230 mm)
166
+ # 102 = PRC Envelope #7 (160 mm x 230 mm)
167
+ # 103 = PRC Envelope #8 (120 mm x 309 mm)
168
+ # 104 = PRC Envelope #9 (229 mm x 324 mm)
169
+ # 105 = PRC Envelope #10 (324 mm x 458 mm)
170
+ # 106 = PRC 16K Rotated
171
+ # 107 = PRC 32K Rotated
172
+ # 108 = PRC 32K(Big) Rotated
173
+ # 109 = PRC Envelope #1 Rotated (165 mm x 102 mm)
174
+ # 110 = PRC Envelope #2 Rotated (176 mm x 102 mm)
175
+ # 111 = PRC Envelope #3 Rotated (176 mm x 125 mm)
176
+ # 112 = PRC Envelope #4 Rotated (208 mm x 110 mm)
177
+ # 113 = PRC Envelope #5 Rotated (220 mm x 110 mm)
178
+ # 114 = PRC Envelope #6 Rotated (230 mm x 120 mm)
179
+ # 115 = PRC Envelope #7 Rotated (230 mm x 160 mm)
180
+ # 116 = PRC Envelope #8 Rotated (309 mm x 120 mm)
181
+ # 117 = PRC Envelope #9 Rotated (324 mm x 229 mm)
182
+ # 118 = PRC Envelope #10 Rotated (458 mm x 324 mm)
182
183
  # @return [Integer]
183
184
  attr_reader :paper_size
184
185
 
185
-
186
186
  # Sets the paper size for printing.
187
187
  # @see PageSetup#paper_size
188
188
  # @return integer
@@ -191,49 +191,71 @@ module Axlsx
191
191
  @paper_size = size
192
192
  end
193
193
 
194
- # Set some or all page settings at once.
194
+ # Set some or all page settings at once.
195
195
  # @param [Hash] options The page settings to set (possible keys are :fit_to_height, :fit_to_width, :orientation, :paper_height, :paper_width, and :scale).
196
196
  def set(options)
197
197
  parse_options options
198
198
  end
199
199
 
200
200
  # @see fit_to_height
201
- def fit_to_height=(v); Axlsx::validate_unsigned_int(v); @fit_to_height = v; end
201
+ def fit_to_height=(v)
202
+ Axlsx.validate_unsigned_int(v)
203
+ @fit_to_height = v
204
+ end
205
+
202
206
  # @see fit_to_width
203
- def fit_to_width=(v); Axlsx::validate_unsigned_int(v); @fit_to_width = v; end
207
+ def fit_to_width=(v)
208
+ Axlsx.validate_unsigned_int(v)
209
+ @fit_to_width = v
210
+ end
211
+
204
212
  # @see orientation
205
- def orientation=(v); Axlsx::validate_page_orientation(v); @orientation = v; end
213
+ def orientation=(v)
214
+ Axlsx.validate_page_orientation(v)
215
+ @orientation = v
216
+ end
217
+
206
218
  # @see paper_height
207
- def paper_height=(v); Axlsx::validate_number_with_unit(v); @paper_height = v; end
219
+ def paper_height=(v)
220
+ Axlsx.validate_number_with_unit(v)
221
+ @paper_height = v
222
+ end
223
+
208
224
  # @see paper_width
209
- def paper_width=(v); Axlsx::validate_number_with_unit(v); @paper_width = v; end
225
+ def paper_width=(v)
226
+ Axlsx.validate_number_with_unit(v)
227
+ @paper_width = v
228
+ end
229
+
210
230
  # @see scale
211
- def scale=(v); Axlsx::validate_scale_10_400(v); @scale = v; end
231
+ def scale=(v)
232
+ Axlsx.validate_scale_10_400(v)
233
+ @scale = v
234
+ end
212
235
 
213
236
  # convenience method to achieve sanity when setting fit_to_width and fit_to_height
214
237
  # as they both default to 1 if only their counterpart is specified.
215
238
  # @note This method will overwrite any value you explicitly set via the fit_to_height or fit_to_width methods.
216
239
  # @option options [Integer] width The number of pages to fit this worksheet on horizontally. Default 999
217
240
  # @option options [Integer] height The number of pages to fit this worksheet on vertically. Default 999
218
- def fit_to(options={})
241
+ def fit_to(options = {})
219
242
  self.fit_to_width = options[:width] || 999
220
243
  self.fit_to_height = options[:height] || 999
221
244
  [@fit_to_width, @fit_to_height]
222
245
  end
223
246
 
224
-
225
247
  # helper method for worksheet to determine if the page setup is configured for fit to page printing
226
248
  # We treat any page set up that has a value set for fit_to_width or fit_to_height value as fit_to_page.
227
249
  # @return [Boolean]
228
250
  def fit_to_page?
229
- # is there some better what to express this?
230
- (fit_to_width != nil || fit_to_height != nil)
251
+ # is there some better way to express this?
252
+ !fit_to_width.nil? || !fit_to_height.nil?
231
253
  end
232
254
 
233
255
  # Serializes the page settings element.
234
256
  # @param [String] str
235
257
  # @return [String]
236
- def to_xml_string(str = '')
258
+ def to_xml_string(str = +'')
237
259
  serialized_tag('pageSetup', str)
238
260
  end
239
261
  end