axlsx 1.1.7 → 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 (164) hide show
  1. data/.yardopts +5 -2
  2. data/CHANGELOG.md +39 -0
  3. data/README.md +84 -46
  4. data/Rakefile +3 -2
  5. data/examples/basic_charts.rb +8 -0
  6. data/examples/chart_colors.rb +18 -3
  7. data/examples/example.rb +106 -46
  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/lib/axlsx/content_type/content_type.rb +2 -0
  15. data/lib/axlsx/content_type/default.rb +21 -12
  16. data/lib/axlsx/content_type/override.rb +22 -11
  17. data/lib/axlsx/doc_props/app.rb +36 -32
  18. data/lib/axlsx/doc_props/core.rb +9 -5
  19. data/lib/axlsx/drawing/ax_data_source.rb +7 -6
  20. data/lib/axlsx/drawing/axis.rb +48 -27
  21. data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
  22. data/lib/axlsx/drawing/bar_series.rb +1 -0
  23. data/lib/axlsx/drawing/cat_axis.rb +42 -38
  24. data/lib/axlsx/drawing/chart.rb +63 -52
  25. data/lib/axlsx/drawing/d_lbls.rb +100 -0
  26. data/lib/axlsx/drawing/drawing.rb +7 -4
  27. data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
  28. data/lib/axlsx/drawing/num_data_source.rb +1 -1
  29. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
  30. data/lib/axlsx/drawing/scatter_chart.rb +2 -8
  31. data/lib/axlsx/drawing/two_cell_anchor.rb +41 -9
  32. data/lib/axlsx/drawing/view_3D.rb +41 -31
  33. data/lib/axlsx/drawing/vml_drawing.rb +1 -1
  34. data/lib/axlsx/package.rb +11 -11
  35. data/lib/axlsx/rels/relationship.rb +3 -3
  36. data/lib/axlsx/stylesheet/styles.rb +1 -1
  37. data/lib/axlsx/util/constants.rb +4 -0
  38. data/lib/axlsx/util/simple_typed_list.rb +15 -8
  39. data/lib/axlsx/util/validators.rb +2 -2
  40. data/lib/axlsx/version.rb +2 -7
  41. data/lib/axlsx/workbook/defined_name.rb +174 -0
  42. data/lib/axlsx/workbook/defined_names.rb +21 -0
  43. data/lib/axlsx/workbook/workbook.rb +39 -14
  44. data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
  45. data/lib/axlsx/workbook/worksheet/cell.rb +25 -2
  46. data/lib/axlsx/workbook/worksheet/col.rb +15 -0
  47. data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
  48. data/lib/axlsx/workbook/worksheet/comments.rb +8 -0
  49. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
  50. data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
  51. data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
  52. data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
  53. data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
  54. data/lib/axlsx/workbook/worksheet/page_setup.rb +9 -0
  55. data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
  56. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
  57. data/lib/axlsx/workbook/worksheet/row.rb +1 -1
  58. data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
  59. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
  60. data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
  61. data/lib/axlsx/workbook/worksheet/worksheet.rb +300 -293
  62. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
  63. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
  64. data/lib/axlsx.rb +21 -14
  65. data/test/content_type/tc_content_type.rb +1 -6
  66. data/test/doc_props/tc_core.rb +1 -1
  67. data/test/drawing/tc_axis.rb +8 -0
  68. data/test/drawing/tc_bar_3D_chart.rb +12 -12
  69. data/test/drawing/tc_bar_series.rb +1 -2
  70. data/test/drawing/tc_chart.rb +8 -6
  71. data/test/drawing/tc_d_lbls.rb +47 -0
  72. data/test/drawing/tc_drawing.rb +5 -4
  73. data/test/drawing/tc_line_series.rb +1 -1
  74. data/test/drawing/tc_pie_3D_chart.rb +4 -8
  75. data/test/drawing/tc_pie_series.rb +1 -1
  76. data/test/drawing/tc_scatter_series.rb +1 -1
  77. data/test/drawing/tc_series.rb +1 -1
  78. data/test/drawing/tc_view_3D.rb +18 -18
  79. data/test/tc_package.rb +18 -1
  80. data/test/workbook/tc_defined_name.rb +41 -0
  81. data/test/workbook/tc_workbook.rb +5 -3
  82. data/test/workbook/worksheet/table/tc_table.rb +0 -8
  83. data/test/workbook/worksheet/tc_cell.rb +2 -4
  84. data/test/workbook/worksheet/tc_page_setup.rb +20 -3
  85. data/test/workbook/worksheet/tc_protected_range.rb +17 -0
  86. data/test/workbook/worksheet/tc_row.rb +2 -2
  87. data/test/workbook/worksheet/tc_selection.rb +1 -1
  88. data/test/workbook/worksheet/tc_worksheet.rb +53 -34
  89. metadata +93 -101
  90. data/examples/axis-titles.xlsx +0 -0
  91. data/examples/basic_charts.xlsx +0 -0
  92. data/examples/chart_colors.xlsx +0 -0
  93. data/examples/charts.xlsx +0 -0
  94. data/examples/conditional_formatting/getting_barred.xlsx +0 -0
  95. data/examples/doc/_index.html +0 -84
  96. data/examples/doc/class_list.html +0 -47
  97. data/examples/doc/css/common.css +0 -1
  98. data/examples/doc/css/full_list.css +0 -55
  99. data/examples/doc/css/style.css +0 -322
  100. data/examples/doc/file_list.html +0 -46
  101. data/examples/doc/frames.html +0 -13
  102. data/examples/doc/index.html +0 -84
  103. data/examples/doc/js/app.js +0 -205
  104. data/examples/doc/js/full_list.js +0 -173
  105. data/examples/doc/js/jquery.js +0 -16
  106. data/examples/doc/method_list.html +0 -46
  107. data/examples/doc/top-level-namespace.html +0 -95
  108. data/examples/examples_saved.xlsx +0 -0
  109. data/examples/extractive.xlsx +0 -0
  110. data/examples/fish.xlsx +0 -0
  111. data/examples/pareto.rb +0 -28
  112. data/examples/pareto.xlsx +0 -0
  113. data/examples/pie_chart_excel.xlsx +0 -0
  114. data/examples/pie_chart_saved.xlsx +0 -0
  115. data/examples/sheet_protection.xlsx +0 -0
  116. data/examples/sheet_view.xlsx +0 -0
  117. data/examples/two_cell_anchor_image.xlsx +0 -0
  118. data/examples/~$example.xlsx +0 -0
  119. data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
  120. data/lib/axlsx/drawing/data_source.rb~ +0 -51
  121. data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
  122. data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
  123. data/lib/axlsx/drawing/num_data.rb~ +0 -51
  124. data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
  125. data/lib/axlsx/drawing/num_val.rb~ +0 -40
  126. data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
  127. data/lib/axlsx/drawing/ref.rb~ +0 -41
  128. data/lib/axlsx/drawing/str_data.rb~ +0 -58
  129. data/lib/axlsx/drawing/str_val.rb~ +0 -35
  130. data/lib/axlsx/drawing/vml_drawing.rb~ +0 -6
  131. data/lib/axlsx/drawing/vml_shape.rb~ +0 -61
  132. data/lib/axlsx/util/cbf.rb +0 -333
  133. data/lib/axlsx/util/cfb.rb~ +0 -201
  134. data/lib/axlsx/util/font_tables.rb~ +0 -0
  135. data/lib/axlsx/util/ms_off_crypto.rb +0 -189
  136. data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
  137. data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
  138. data/lib/axlsx/util/parser.rb~ +0 -6
  139. data/lib/axlsx/util/storage.rb~ +0 -0
  140. data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
  141. data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
  142. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  143. data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
  144. data/lib/axlsx/workbook/worksheet/comment.rb~ +0 -91
  145. data/lib/axlsx/workbook/worksheet/comments.rb~ +0 -86
  146. data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
  147. data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
  148. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  149. data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
  150. data/lib/schema/dc.xsd~ +0 -118
  151. data/lib/schema/dcterms.xsd~ +0 -331
  152. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  153. data/test/drawing/tc_data_source.rb~ +0 -30
  154. data/test/drawing/tc_num_data.rb~ +0 -35
  155. data/test/drawing/tc_num_val.rb~ +0 -29
  156. data/test/drawing/tc_str_data.rb~ +0 -30
  157. data/test/drawing/tc_str_val.rb~ +0 -26
  158. data/test/drawing/tc_vml_drawing.rb~ +0 -0
  159. data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
  160. data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
  161. data/test/workbook/worksheet/tc_col.rb~ +0 -10
  162. data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
  163. data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
  164. data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
@@ -102,6 +102,21 @@ module Axlsx
102
102
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
103
103
  end
104
104
  end
105
+
106
+ # updates the width for this col based on the cells autowidth and
107
+ # an optionally specified fixed width
108
+ # @param [Cell] cell The cell to use in updating this col's width
109
+ # @param [Integer] fixed_width If this is specified the width is set
110
+ # to this value and the cell's attributes are ignored.
111
+ # @param [Boolean] use_autowidth If this is false, the cell's
112
+ # autowidth value will be ignored.
113
+ def update_width(cell, fixed_width=nil, use_autowidth=true)
114
+ if fixed_width.is_a? Numeric
115
+ self.width = fixed_width
116
+ elsif use_autowidth
117
+ self.width = [width || 0, cell.autowidth || 0].max
118
+ end
119
+ end
105
120
 
106
121
  # Serialize this columns data to an xml string
107
122
  # @param [String] str
@@ -0,0 +1,20 @@
1
+ module Axlsx
2
+
3
+ # The cols class manages the col object used to manage column widths.
4
+ # This is where the magic happens with autowidth
5
+ class Cols < SimpleTypedList
6
+
7
+ def initialize(worksheet)
8
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
9
+ super Col
10
+ @worksheet = worksheet
11
+ end
12
+
13
+ def to_xml_string(str = '')
14
+ return if empty?
15
+ str << '<cols>'
16
+ each { |item| item.to_xml_string(str) }
17
+ str << '</cols>'
18
+ end
19
+ end
20
+ end
@@ -53,6 +53,14 @@ module Axlsx
53
53
  @list.map { |comment| comment.author.to_s }.uniq.sort
54
54
  end
55
55
 
56
+ # The relationships required by this object
57
+ # @return [Array]
58
+ def relationships
59
+ [Relationship.new(VML_DRAWING_R, "../#{vml_drawing.pn}"),
60
+ Relationship.new(COMMENT_R, "../#{pn}"),
61
+ Relationship.new(COMMENT_R_NULL, "NULL")]
62
+ end
63
+
56
64
  # serialize the object
57
65
  # @param [String] str
58
66
  # @return [String]
@@ -0,0 +1,25 @@
1
+ module Axlsx
2
+
3
+ # A simple, self serializing class for storing conditional formattings
4
+ class ConditionalFormattings < SimpleTypedList
5
+
6
+ # creates a new Tables object
7
+ def initialize(worksheet)
8
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
9
+ super ConditionalFormatting
10
+ @worksheet = worksheet
11
+ end
12
+
13
+ # The worksheet that owns this collection of tables
14
+ # @return [Worksheet]
15
+ attr_reader :worksheet
16
+
17
+ # serialize the conditional formattings
18
+ def to_xml_string(str = "")
19
+ return if empty?
20
+ each { |item| item.to_xml_string(str) }
21
+ end
22
+ end
23
+
24
+ end
25
+
@@ -65,7 +65,7 @@ module Axlsx
65
65
  def showValue=(v); Axlsx.validate_boolean(v); @showValue = v end
66
66
 
67
67
  # Sets the color for the data bars.
68
- # @param [Color|String] The color object, or rgb string value to apply
68
+ # @param [Color|String] v The color object, or rgb string value to apply
69
69
  def color=(v)
70
70
  @color = v if v.is_a? Color
71
71
  self.color.rgb = v if v.is_a? String
@@ -0,0 +1,28 @@
1
+ module Axlsx
2
+
3
+ # A simple, self serializing class for storing conditional formattings
4
+ class DataValidations < SimpleTypedList
5
+
6
+ # creates a new Tables object
7
+ def initialize(worksheet)
8
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
9
+ super DataValidation
10
+ @worksheet = worksheet
11
+ end
12
+
13
+ # The worksheet that owns this collection of tables
14
+ # @return [Worksheet]
15
+ attr_reader :worksheet
16
+
17
+ # serialize the conditional formattings
18
+ def to_xml_string(str = "")
19
+ return if empty?
20
+ str << "<dataValidations count='#{size}'>"
21
+ each { |item| item.to_xml_string(str) }
22
+ str << '</dataValidations>'
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+
@@ -0,0 +1,65 @@
1
+ module Axlsx
2
+
3
+ # This class manages the dimensions for a worksheet.
4
+ # While this node is optional in the specification some readers like
5
+ # LibraOffice require this node to render the sheet
6
+ class Dimension
7
+
8
+ # the default value for the first cell in the dimension
9
+ # @return [String]
10
+ def self.default_first
11
+ @@default_first ||= 'A1'
12
+ end
13
+
14
+ # the default value for the last cell in the dimension
15
+ # @return [String]
16
+ def self.default_last
17
+ @@default_last ||= 'AA200'
18
+ end
19
+
20
+
21
+ # Creates a new dimension object
22
+ # @param[Worksheet] worksheet - the worksheet this dimension applies
23
+ # to.
24
+ def initialize(worksheet)
25
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
26
+ @worksheet = worksheet
27
+ end
28
+
29
+ attr_reader :worksheet
30
+
31
+ # the full refernece for this dimension
32
+ # @return [String]
33
+ def sqref
34
+ "#{first_cell_reference}:#{last_cell_reference}"
35
+ end
36
+
37
+ # serialize the object
38
+ # @return [String]
39
+ def to_xml_string(str = '')
40
+ return if worksheet.rows.empty?
41
+ str << "<dimension ref=\"%s\"></dimension>" % sqref
42
+ end
43
+
44
+ # The first cell in the dimension
45
+ # @return [String]
46
+ def first_cell_reference
47
+ dimension_reference(worksheet.rows.first.cells.first, Dimension.default_first)
48
+ end
49
+
50
+ # the last cell in the dimension
51
+ # @return [String]
52
+ def last_cell_reference
53
+ dimension_reference(worksheet.rows.last.cells.last, Dimension.default_last)
54
+ end
55
+
56
+ private
57
+
58
+ # Returns the reference of a cell or the default specified
59
+ # @return [String]
60
+ def dimension_reference(cell, default)
61
+ return default unless cell.respond_to?(:r)
62
+ cell.r
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,35 @@
1
+ module Axlsx
2
+
3
+ # A simple list of merged cells
4
+ class MergedCells < SimpleTypedList
5
+
6
+ # creates a new MergedCells object
7
+ # @param [Worksheet] worksheet
8
+ def initialize(worksheet)
9
+ raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet)
10
+ super String
11
+ end
12
+
13
+ # adds cells to the merged cells collection
14
+ # @param [Array||String] cells The cells to add to the merged cells
15
+ # collection. This can be an array of actual cells or a string style
16
+ # range like 'A1:C1'
17
+ def add(cells)
18
+ @list << if cells.is_a?(String)
19
+ cells
20
+ elsif cells.is_a?(Array)
21
+ Axlsx::cell_range(cells, false)
22
+ end
23
+ end
24
+
25
+ # serialize the object
26
+ # @param [String] str
27
+ # @return [String]
28
+ def to_xml_string(str = '')
29
+ return if @list.empty?
30
+ str << "<mergeCells count='#{size}'>"
31
+ each { |merged_cell| str << "<mergeCell ref='#{merged_cell}'></mergeCell>" }
32
+ str << '</mergeCells>'
33
+ end
34
+ end
35
+ end
@@ -92,6 +92,15 @@ module Axlsx
92
92
  [@fit_to_width, @fit_to_height]
93
93
  end
94
94
 
95
+
96
+ # helper method for worksheet to determine if the page setup is configured for fit to page printing
97
+ # We treat any page set up that has a value set for fit_to_width or fit_to_height value as fit_to_page.
98
+ # @return [Boolean]
99
+ def fit_to_page?
100
+ # is there some better what to express this?
101
+ (fit_to_width != nil || fit_to_height != nil)
102
+ end
103
+
95
104
  # Serializes the page settings element.
96
105
  # @param [String] str
97
106
  # @return [String]
@@ -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,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
@@ -0,0 +1,31 @@
1
+ module Axlsx
2
+
3
+ # A simple, self serializing class for storing tables
4
+ class Tables < SimpleTypedList
5
+
6
+ # creates a new Tables object
7
+ def initialize(worksheet)
8
+ raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
9
+ super Table
10
+ @worksheet = worksheet
11
+ end
12
+
13
+ # The worksheet that owns this collection of tables
14
+ # @return [Worksheet]
15
+ attr_reader :worksheet
16
+
17
+ # returns the relationships required by this collection
18
+ def relationships
19
+ return [] if empty?
20
+ map{ |table| Relationship.new(TABLE_R, "../#{table.pn}") }
21
+ end
22
+
23
+ def to_xml_string(str = "")
24
+ return if empty?
25
+ str << "<tableParts count='#{size}'>"
26
+ @list.each { |table| str << "<tablePart r:id='#{table.rId}'/>" }
27
+ str << '</tableParts>'
28
+ end
29
+ end
30
+
31
+ end