caxlsx 3.4.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/README.md +9 -11
  4. data/Rakefile +7 -5
  5. data/lib/axlsx/content_type/abstract_content_type.rb +9 -4
  6. data/lib/axlsx/content_type/content_type.rb +7 -5
  7. data/lib/axlsx/content_type/default.rb +4 -2
  8. data/lib/axlsx/content_type/override.rb +4 -2
  9. data/lib/axlsx/doc_props/app.rb +26 -24
  10. data/lib/axlsx/doc_props/core.rb +8 -6
  11. data/lib/axlsx/drawing/area_chart.rb +10 -8
  12. data/lib/axlsx/drawing/area_series.rb +12 -10
  13. data/lib/axlsx/drawing/ax_data_source.rb +2 -0
  14. data/lib/axlsx/drawing/axes.rb +6 -4
  15. data/lib/axlsx/drawing/axis.rb +21 -19
  16. data/lib/axlsx/drawing/bar_3D_chart.rb +14 -12
  17. data/lib/axlsx/drawing/bar_chart.rb +13 -11
  18. data/lib/axlsx/drawing/bar_series.rb +8 -6
  19. data/lib/axlsx/drawing/bubble_chart.rb +6 -4
  20. data/lib/axlsx/drawing/bubble_series.rb +8 -6
  21. data/lib/axlsx/drawing/cat_axis.rb +12 -10
  22. data/lib/axlsx/drawing/chart.rb +20 -18
  23. data/lib/axlsx/drawing/d_lbls.rb +7 -5
  24. data/lib/axlsx/drawing/drawing.rb +58 -56
  25. data/lib/axlsx/drawing/graphic_frame.rb +6 -4
  26. data/lib/axlsx/drawing/hyperlink.rb +10 -8
  27. data/lib/axlsx/drawing/line_3D_chart.rb +7 -5
  28. data/lib/axlsx/drawing/line_chart.rb +10 -8
  29. data/lib/axlsx/drawing/line_series.rb +12 -10
  30. data/lib/axlsx/drawing/marker.rb +9 -7
  31. data/lib/axlsx/drawing/num_data.rb +9 -7
  32. data/lib/axlsx/drawing/num_data_source.rb +9 -7
  33. data/lib/axlsx/drawing/num_val.rb +7 -5
  34. data/lib/axlsx/drawing/one_cell_anchor.rb +7 -5
  35. data/lib/axlsx/drawing/pic.rb +16 -14
  36. data/lib/axlsx/drawing/picture_locking.rb +3 -1
  37. data/lib/axlsx/drawing/pie_3D_chart.rb +5 -3
  38. data/lib/axlsx/drawing/pie_series.rb +8 -6
  39. data/lib/axlsx/drawing/scaling.rb +8 -6
  40. data/lib/axlsx/drawing/scatter_chart.rb +7 -5
  41. data/lib/axlsx/drawing/scatter_series.rb +14 -12
  42. data/lib/axlsx/drawing/ser_axis.rb +7 -5
  43. data/lib/axlsx/drawing/series.rb +6 -4
  44. data/lib/axlsx/drawing/series_title.rb +6 -4
  45. data/lib/axlsx/drawing/str_data.rb +7 -5
  46. data/lib/axlsx/drawing/str_val.rb +6 -4
  47. data/lib/axlsx/drawing/title.rb +13 -14
  48. data/lib/axlsx/drawing/two_cell_anchor.rb +4 -2
  49. data/lib/axlsx/drawing/val_axis.rb +4 -2
  50. data/lib/axlsx/drawing/view_3D.rb +9 -7
  51. data/lib/axlsx/drawing/vml_drawing.rb +18 -16
  52. data/lib/axlsx/drawing/vml_shape.rb +24 -22
  53. data/lib/axlsx/package.rb +69 -66
  54. data/lib/axlsx/rels/relationship.rb +10 -5
  55. data/lib/axlsx/rels/relationships.rb +5 -3
  56. data/lib/axlsx/stylesheet/border.rb +6 -4
  57. data/lib/axlsx/stylesheet/border_pr.rb +5 -3
  58. data/lib/axlsx/stylesheet/cell_alignment.rb +12 -10
  59. data/lib/axlsx/stylesheet/cell_protection.rb +5 -3
  60. data/lib/axlsx/stylesheet/cell_style.rb +10 -8
  61. data/lib/axlsx/stylesheet/color.rb +9 -7
  62. data/lib/axlsx/stylesheet/dxf.rb +5 -3
  63. data/lib/axlsx/stylesheet/fill.rb +3 -1
  64. data/lib/axlsx/stylesheet/font.rb +18 -16
  65. data/lib/axlsx/stylesheet/gradient_fill.rb +6 -4
  66. data/lib/axlsx/stylesheet/gradient_stop.rb +6 -4
  67. data/lib/axlsx/stylesheet/num_fmt.rb +8 -10
  68. data/lib/axlsx/stylesheet/pattern_fill.rb +5 -3
  69. data/lib/axlsx/stylesheet/styles.rb +69 -71
  70. data/lib/axlsx/stylesheet/table_style.rb +7 -5
  71. data/lib/axlsx/stylesheet/table_style_element.rb +6 -4
  72. data/lib/axlsx/stylesheet/table_styles.rb +6 -4
  73. data/lib/axlsx/stylesheet/xf.rb +18 -16
  74. data/lib/axlsx/util/accessors.rb +4 -2
  75. data/lib/axlsx/util/buffered_zip_output_stream.rb +60 -0
  76. data/lib/axlsx/util/constants.rb +117 -104
  77. data/lib/axlsx/util/mime_type_utils.rb +3 -5
  78. data/lib/axlsx/util/options_parser.rb +3 -1
  79. data/lib/axlsx/util/serialized_attributes.rb +42 -17
  80. data/lib/axlsx/util/simple_typed_list.rb +47 -47
  81. data/lib/axlsx/util/storage.rb +11 -10
  82. data/lib/axlsx/util/validators.rb +101 -41
  83. data/lib/axlsx/util/zip_command.rb +10 -10
  84. data/lib/axlsx/version.rb +3 -1
  85. data/lib/axlsx/workbook/defined_name.rb +6 -4
  86. data/lib/axlsx/workbook/defined_names.rb +3 -1
  87. data/lib/axlsx/workbook/shared_strings_table.rb +8 -6
  88. data/lib/axlsx/workbook/workbook.rb +78 -76
  89. data/lib/axlsx/workbook/workbook_view.rb +3 -1
  90. data/lib/axlsx/workbook/workbook_views.rb +3 -1
  91. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +65 -8
  92. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +7 -3
  93. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +11 -7
  94. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
  95. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +56 -0
  96. data/lib/axlsx/workbook/worksheet/border_creator.rb +5 -3
  97. data/lib/axlsx/workbook/worksheet/break.rb +3 -1
  98. data/lib/axlsx/workbook/worksheet/cell.rb +53 -54
  99. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +31 -27
  100. data/lib/axlsx/workbook/worksheet/cfvo.rb +5 -3
  101. data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -1
  102. data/lib/axlsx/workbook/worksheet/col.rb +5 -3
  103. data/lib/axlsx/workbook/worksheet/col_breaks.rb +5 -3
  104. data/lib/axlsx/workbook/worksheet/color_scale.rb +12 -10
  105. data/lib/axlsx/workbook/worksheet/cols.rb +3 -1
  106. data/lib/axlsx/workbook/worksheet/comment.rb +8 -6
  107. data/lib/axlsx/workbook/worksheet/comments.rb +6 -4
  108. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +9 -4
  109. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +18 -16
  110. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +3 -1
  111. data/lib/axlsx/workbook/worksheet/data_bar.rb +14 -13
  112. data/lib/axlsx/workbook/worksheet/data_validation.rb +30 -28
  113. data/lib/axlsx/workbook/worksheet/data_validations.rb +3 -1
  114. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +7 -5
  115. data/lib/axlsx/workbook/worksheet/dimension.rb +4 -2
  116. data/lib/axlsx/workbook/worksheet/header_footer.rb +4 -2
  117. data/lib/axlsx/workbook/worksheet/icon_set.rb +23 -6
  118. data/lib/axlsx/workbook/worksheet/merged_cells.rb +5 -5
  119. data/lib/axlsx/workbook/worksheet/outline_pr.rb +6 -2
  120. data/lib/axlsx/workbook/worksheet/page_margins.rb +15 -10
  121. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -2
  122. data/lib/axlsx/workbook/worksheet/page_setup.rb +11 -9
  123. data/lib/axlsx/workbook/worksheet/pane.rb +11 -9
  124. data/lib/axlsx/workbook/worksheet/pivot_table.rb +20 -19
  125. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -6
  126. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +2 -0
  127. data/lib/axlsx/workbook/worksheet/print_options.rb +3 -1
  128. data/lib/axlsx/workbook/worksheet/protected_range.rb +3 -1
  129. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +5 -3
  130. data/lib/axlsx/workbook/worksheet/rich_text.rb +3 -1
  131. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +16 -14
  132. data/lib/axlsx/workbook/worksheet/row.rb +6 -7
  133. data/lib/axlsx/workbook/worksheet/row_breaks.rb +6 -4
  134. data/lib/axlsx/workbook/worksheet/selection.rb +9 -7
  135. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -2
  136. data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
  137. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +6 -2
  138. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +8 -4
  139. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +10 -8
  140. data/lib/axlsx/workbook/worksheet/sheet_view.rb +15 -13
  141. data/lib/axlsx/workbook/worksheet/table.rb +9 -7
  142. data/lib/axlsx/workbook/worksheet/table_style_info.rb +4 -2
  143. data/lib/axlsx/workbook/worksheet/tables.rb +3 -1
  144. data/lib/axlsx/workbook/worksheet/worksheet.rb +38 -37
  145. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -2
  146. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +8 -2
  147. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +6 -4
  148. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +4 -2
  149. data/lib/axlsx.rb +56 -42
  150. data/lib/caxlsx.rb +3 -1
  151. metadata +49 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bc64f23079fdbb6084190c180942bdf850ef2a0f0e6e75e68b3c9f63bcb6a2b
4
- data.tar.gz: 389bd6a8434de5942a54d47c2fafd4b407fead102ef0186d6f180879689c9a96
3
+ metadata.gz: fcc3d364dba9ddb0058e9e64e7fbb537915dee8fc8adfc308e263d210c643488
4
+ data.tar.gz: e5582a8e8f2cecdcc7fcebea3c1193d8c6f7351a2882ffa2a51f25ca05b9874c
5
5
  SHA512:
6
- metadata.gz: 4f0de7a6035a2179287b06eef2d942b53e4c5ba18f8d26dd5df7cb48ae32ecb320bce6fa8f778683f57de10a8f7a3b4e1c2123c8f25c3406360573bebf54ee25
7
- data.tar.gz: 5c85f6027cf1e286b53885d9d2cd0226eaff9079d1bc6933a0bb7659a85965c0f791e0d3ccf22ca745d44b4927b981c4abffe8734aa43043c98ffa5363c4698c
6
+ metadata.gz: bcb83efcf758bbdd201d877c1f34a2f30fcf5e676359aaecdaf47be68cc9c7481caf0b19786b605ce7c600d855d40d84e2b27b4987e0498e60507a157e6a6e53
7
+ data.tar.gz: 9caa406e7f059088f8adbd88e3429ccd920bb4a25b9ac6933395f2e072f561591f3b935f1eb08263c80486818941fef186a7d660e050c08973fb687d008eb29e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  CHANGELOG
2
2
  ---------
3
- - **Unreleased**: 3.4.1
3
+ - **Unreleased**
4
+
5
+
6
+ - **October.30.23**: 4.0.0
7
+ - [PR #189](https://github.com/caxlsx/caxlsx/pull/189) **breaking** Make `Axlsx::escape_formulas` true by default to mitigate [Formula Injection](https://www.owasp.org/index.php/CSV_Injection) vulnerabilities.
8
+ - [PR #212](https://github.com/caxlsx/caxlsx/pull/212) **breaking** Raise exception if `axlsx_styler` gem is present as its code was merged directly into `caxlsx` in v3.3.0
9
+ - [PR #225](https://github.com/caxlsx/caxlsx/pull/225) **breaking** Remove ability to set `u=` to true in favor of using :single or one of the other underline options
10
+ - Drop support for Ruby versions < 2.6
11
+ - [PR #219](https://github.com/caxlsx/caxlsx/pull/219) Added frozen string literals
12
+ - [PR #223](https://github.com/caxlsx/caxlsx/pull/223) Fix `SimpleTypedList#to_a` and `SimpleTypedList#to_ary` returning the internal list instance
13
+ - [PR #239](https://github.com/caxlsx/caxlsx/pull/239) Fix `Workbook#sheet_by_name` not returning sheets with encoded characters in the name
14
+ - [PR #286](https://github.com/caxlsx/caxlsx/pull/286) Add 'SortState' and 'SortCondition' classes to the 'AutoFilter' class to add sorting to the generated file.
15
+ - [PR #269](https://github.com/caxlsx/caxlsx/pull/269) Add optional interpolation points to icon sets
16
+ - [PR #304](https://github.com/caxlsx/caxlsx/pull/304) Fix data validations for none type validations
17
+
18
+ - **April.23.23**: 3.4.1
4
19
  - [PR #209](https://github.com/caxlsx/caxlsx/pull/209) - Revert characters other than `=` being considered as formulas.
5
20
 
6
21
  - **April.12.23**: 3.4.0
data/README.md CHANGED
@@ -15,7 +15,7 @@ https://github.com/caxlsx
15
15
  ## Synopsis
16
16
 
17
17
  Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
18
- With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, tables, conditional formatting, print options, comments, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification.
18
+ With Axlsx you can create Excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, tables, conditional formatting, print options, comments, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification.
19
19
 
20
20
  ![Screen 1](https://github.com/caxlsx/caxlsx/raw/master/examples/sample.png)
21
21
 
@@ -73,6 +73,8 @@ and Numbers
73
73
  gem 'caxlsx'
74
74
  ```
75
75
 
76
+ **Supported Ruby versions:** Caxlsx supports Ruby 2.6 and newer.
77
+
76
78
  ## Usage
77
79
 
78
80
  Here's a teaser that kicks about 2% of what the gem can do.
@@ -122,24 +124,20 @@ Currently the following additional gems are available:
122
124
 
123
125
  ## Security
124
126
 
125
- To prevent [Formula Injection](https://www.owasp.org/index.php/CSV_Injection) vulnerabilities, set the following in an initializer:
127
+ To prevent [Formula Injection](https://www.owasp.org/index.php/CSV_Injection) vulnerabilities, as of version 4.0, axlsx escapes all formulas by default. To permit formulas on a specific cell, please use:
126
128
 
127
129
  ```ruby
128
- Axlsx.escape_formulas = true
130
+ cell.escape_formulas = false
129
131
  ```
130
132
 
131
- Then, set the following on each cell you'd like to add a formula:
133
+ You may set `escape_formulas` on the workbook, worksheet, row and/or cell level. Refer to examples/escape_formula.md for details.
134
+
135
+ To allow formulas globally by default (which was the behavior in axlsx 3.x and prior), you may set the following in an initializer:
132
136
 
133
137
  ```ruby
134
- cell.escape_formulas = false
138
+ Axlsx.escape_formulas = false
135
139
  ```
136
140
 
137
- Refer to examples/escape_formula.md for how to set `escape_formulas` on the workbook, worksheet, row and/or cell level.
138
-
139
- **Important:** The global setting `Axlsx.escape_formulas = true` will become the default in the next major release (Axlsx 4.0).
140
- If you do not wish to set `Axlsx.escape_formulas = true` now, at a minimum, please set `Axlsx.escape_formulas = false` to
141
- ensure continuity when upgrading.
142
-
143
141
  ## Known Software Interoperability Issues
144
142
 
145
143
  As axslx implements the Office Open XML (ECMA-376 spec) much of the
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/lib/axlsx/version.rb')
1
+ # frozen_string_literal: true
2
2
 
3
- task :build => :gendoc do
3
+ require File.expand_path("#{File.dirname(__FILE__)}/lib/axlsx/version.rb")
4
+
5
+ task build: :gendoc do
4
6
  system "gem build axlsx.gemspec"
5
7
  end
6
8
 
7
9
  task :benchmark do
8
- require File.expand_path(File.dirname(__FILE__) + '/test/benchmark.rb')
10
+ require File.expand_path("#{File.dirname(__FILE__)}/test/benchmark.rb")
9
11
  end
10
12
 
11
13
  task :gendoc do
@@ -21,8 +23,8 @@ Rake::TestTask.new do |t|
21
23
  t.warning = true
22
24
  end
23
25
 
24
- task :release => :build do
26
+ task release: :build do
25
27
  system "gem push caxlsx-#{Axlsx::VERSION}.gem"
26
28
  end
27
29
 
28
- task :default => :test
30
+ task default: :test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # This class extracts the common parts from Default and Override
3
5
  class AbstractContentType
@@ -16,13 +18,16 @@ module Axlsx
16
18
 
17
19
  # The content type.
18
20
  # @see Axlsx#validate_content_type
19
- def content_type=(v) Axlsx::validate_content_type v; @content_type = v end
21
+ def content_type=(v) Axlsx.validate_content_type v; @content_type = v end
20
22
  alias :ContentType= :content_type=
21
23
 
22
24
  # Serialize the contenty type to xml
23
- def to_xml_string(node_name = '', str = '')
24
- str << "<#{node_name} "
25
- str << Axlsx.instance_values_for(self).map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ')
25
+ def to_xml_string(node_name = '', str = +'')
26
+ str << '<' << node_name << ' '
27
+ Axlsx.instance_values_for(self).each_with_index do |key_value, index|
28
+ str << ' ' unless index.zero?
29
+ str << Axlsx.camel(key_value.first) << '="' << key_value.last.to_s << '"'
30
+ end
26
31
  str << '/>'
27
32
  end
28
33
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
- require 'axlsx/content_type/abstract_content_type.rb'
3
- require 'axlsx/content_type/default.rb'
4
- require 'axlsx/content_type/override.rb'
4
+ require 'axlsx/content_type/abstract_content_type'
5
+ require 'axlsx/content_type/default'
6
+ require 'axlsx/content_type/override'
5
7
 
6
8
  # ContentTypes used in the package. This is automatically managed by the package package.
7
9
  class ContentType < SimpleTypedList
@@ -12,9 +14,9 @@ module Axlsx
12
14
  # Serializes the object
13
15
  # @param [String] str
14
16
  # @return [String]
15
- def to_xml_string(str = '')
17
+ def to_xml_string(str = +'')
16
18
  str << '<?xml version="1.0" encoding="UTF-8"?>'
17
- str << ('<Types xmlns="' << XML_NS_T << '">')
19
+ str << '<Types xmlns="' << XML_NS_T << '">'
18
20
  each { |type| type.to_xml_string(str) }
19
21
  str << '</Types>'
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # An default content part. These parts are automatically created by for you based on the content of your package.
3
5
  class Default < AbstractContentType
@@ -10,11 +12,11 @@ module Axlsx
10
12
  alias :Extension :extension
11
13
 
12
14
  # Sets the file extension for this content type.
13
- def extension=(v) Axlsx::validate_string v; @extension = v end
15
+ def extension=(v) Axlsx.validate_string v; @extension = v end
14
16
  alias :Extension= :extension=
15
17
 
16
18
  # Serializes this object to xml
17
- def to_xml_string(str = '')
19
+ def to_xml_string(str = +'')
18
20
  super(NODE_NAME, str)
19
21
  end
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # An override content part. These parts are automatically created by for you based on the content of your package.
3
5
  class Override < AbstractContentType
@@ -10,11 +12,11 @@ module Axlsx
10
12
  alias :PartName :part_name
11
13
 
12
14
  # The name and location of the part.
13
- def part_name=(v) Axlsx::validate_string v; @part_name = v end
15
+ def part_name=(v) Axlsx.validate_string v; @part_name = v end
14
16
  alias :PartName= :part_name=
15
17
 
16
18
  # Serializes this object to xml
17
- def to_xml_string(str = '')
19
+ def to_xml_string(str = +'')
18
20
  super(NODE_NAME, str)
19
21
  end
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # App represents the app.xml document. The attributes for this object are primarily managed by the application the end user uses to edit the document. None of the attributes are required to serialize a valid xlsx object.
3
5
  # @see shared-documentPropertiesExtended.xsd
@@ -130,96 +132,96 @@ module Axlsx
130
132
  alias :DocSecurity :doc_security
131
133
 
132
134
  # Sets the template property of your app.xml file
133
- def template=(v) Axlsx::validate_string v; @template = v; end
135
+ def template=(v) Axlsx.validate_string v; @template = v; end
134
136
  alias :Template= :template=
135
137
 
136
138
  # Sets the manager property of your app.xml file
137
- def manager=(v) Axlsx::validate_string v; @manager = v; end
139
+ def manager=(v) Axlsx.validate_string v; @manager = v; end
138
140
  alias :Manager= :manager=
139
141
 
140
142
  # Sets the company property of your app.xml file
141
- def company=(v) Axlsx::validate_string v; @company = v; end
143
+ def company=(v) Axlsx.validate_string v; @company = v; end
142
144
  alias :Company= :company=
143
145
  # Sets the pages property of your app.xml file
144
- def pages=(v) Axlsx::validate_int v; @pages = v; end
146
+ def pages=(v) Axlsx.validate_int v; @pages = v; end
145
147
 
146
148
  # Sets the words property of your app.xml file
147
- def words=(v) Axlsx::validate_int v; @words = v; end
149
+ def words=(v) Axlsx.validate_int v; @words = v; end
148
150
  alias :Words= :words=
149
151
 
150
152
  # Sets the characters property of your app.xml file
151
- def characters=(v) Axlsx::validate_int v; @characters = v; end
153
+ def characters=(v) Axlsx.validate_int v; @characters = v; end
152
154
  alias :Characters= :characters=
153
155
 
154
156
  # Sets the presentation_format property of your app.xml file
155
- def presentation_format=(v) Axlsx::validate_string v; @presentation_format = v; end
157
+ def presentation_format=(v) Axlsx.validate_string v; @presentation_format = v; end
156
158
  alias :PresentationFormat= :presentation_format=
157
159
 
158
160
  # Sets the lines property of your app.xml file
159
- def lines=(v) Axlsx::validate_int v; @lines = v; end
161
+ def lines=(v) Axlsx.validate_int v; @lines = v; end
160
162
  alias :Lines= :lines=
161
163
 
162
164
  # Sets the paragraphs property of your app.xml file
163
- def paragraphs=(v) Axlsx::validate_int v; @paragraphs = v; end
165
+ def paragraphs=(v) Axlsx.validate_int v; @paragraphs = v; end
164
166
  alias :Paragraphs= :paragraphs=
165
167
 
166
168
  # sets the slides property of your app.xml file
167
- def slides=(v) Axlsx::validate_int v; @slides = v; end
169
+ def slides=(v) Axlsx.validate_int v; @slides = v; end
168
170
  alias :Slides= :slides=
169
171
 
170
172
  # sets the notes property of your app.xml file
171
- def notes=(v) Axlsx::validate_int v; @notes = v; end
173
+ def notes=(v) Axlsx.validate_int v; @notes = v; end
172
174
  alias :Notes= :notes=
173
175
 
174
176
  # Sets the total_time property of your app.xml file
175
- def total_time=(v) Axlsx::validate_int v; @total_time = v; end
177
+ def total_time=(v) Axlsx.validate_int v; @total_time = v; end
176
178
  alias :TotalTime= :total_time=
177
179
 
178
180
  # Sets the hidden_slides property of your app.xml file
179
- def hidden_slides=(v) Axlsx::validate_int v; @hidden_slides = v; end
181
+ def hidden_slides=(v) Axlsx.validate_int v; @hidden_slides = v; end
180
182
  alias :HiddenSlides= :hidden_slides=
181
183
 
182
184
  # Sets the m_m_clips property of your app.xml file
183
- def m_m_clips=(v) Axlsx::validate_int v; @m_m_clips = v; end
185
+ def m_m_clips=(v) Axlsx.validate_int v; @m_m_clips = v; end
184
186
  alias :MMClips= :m_m_clips=
185
187
 
186
188
  # Sets the scale_crop property of your app.xml file
187
- def scale_crop=(v) Axlsx::validate_boolean v; @scale_crop = v; end
189
+ def scale_crop=(v) Axlsx.validate_boolean v; @scale_crop = v; end
188
190
  alias :ScaleCrop= :scale_crop=
189
191
 
190
192
  # Sets the links_up_to_date property of your app.xml file
191
- def links_up_to_date=(v) Axlsx::validate_boolean v; @links_up_to_date = v; end
193
+ def links_up_to_date=(v) Axlsx.validate_boolean v; @links_up_to_date = v; end
192
194
  alias :LinksUpToDate= :links_up_to_date=
193
195
 
194
196
  # Sets the characters_with_spaces property of your app.xml file
195
- def characters_with_spaces=(v) Axlsx::validate_int v; @characters_with_spaces = v; end
197
+ def characters_with_spaces=(v) Axlsx.validate_int v; @characters_with_spaces = v; end
196
198
  alias :CharactersWithSpaces= :characters_with_spaces=
197
199
 
198
200
  # Sets the share_doc property of your app.xml file
199
- def shared_doc=(v) Axlsx::validate_boolean v; @shared_doc = v; end
201
+ def shared_doc=(v) Axlsx.validate_boolean v; @shared_doc = v; end
200
202
  alias :SharedDoc= :shared_doc=
201
203
 
202
204
  # Sets the hyperlink_base property of your app.xml file
203
- def hyperlink_base=(v) Axlsx::validate_string v; @hyperlink_base = v; end
205
+ def hyperlink_base=(v) Axlsx.validate_string v; @hyperlink_base = v; end
204
206
  alias :HyperlinkBase= :hyperlink_base=
205
207
 
206
208
  # Sets the HyperLinksChanged property of your app.xml file
207
- def hyperlinks_changed=(v) Axlsx::validate_boolean v; @hyperlinks_changed = v; end
209
+ def hyperlinks_changed=(v) Axlsx.validate_boolean v; @hyperlinks_changed = v; end
208
210
  alias :HyperLinksChanged= :hyperlinks_changed=
209
211
 
210
212
  # Sets the app_version property of your app.xml file
211
- def app_version=(v) Axlsx::validate_string v; @app_version = v; end
213
+ def app_version=(v) Axlsx.validate_string v; @app_version = v; end
212
214
  alias :AppVersion= :app_version=
213
215
 
214
216
  # Sets the doc_security property of your app.xml file
215
- def doc_security=(v) Axlsx::validate_int v; @doc_security = v; end
217
+ def doc_security=(v) Axlsx.validate_int v; @doc_security = v; end
216
218
  alias :DocSecurity= :doc_security=
217
219
 
218
220
  # Serialize the app.xml document
219
221
  # @return [String]
220
- def to_xml_string(str = '')
222
+ def to_xml_string(str = +'')
221
223
  str << '<?xml version="1.0" encoding="UTF-8"?>'
222
- str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">')
224
+ str << '<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">'
223
225
  Axlsx.instance_values_for(self).each do |key, value|
224
226
  node_name = Axlsx.camel(key)
225
227
  str << "<#{node_name}>#{value}</#{node_name}>"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The core object for the package.
3
5
  # @note Packages manage their own core object.
@@ -20,13 +22,13 @@ module Axlsx
20
22
 
21
23
  # serializes the core.xml document
22
24
  # @return [String]
23
- def to_xml_string(str = '')
25
+ def to_xml_string(str = +'')
24
26
  str << '<?xml version="1.0" encoding="UTF-8"?>'
25
- str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ')
26
- str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ')
27
- str << ('xmlns:xsi="' << CORE_NS_XSI << '">')
28
- str << ('<dc:creator>' << self.creator << '</dc:creator>')
29
- str << ('<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>')
27
+ str << '<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" '
28
+ str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
29
+ str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
30
+ str << '<dc:creator>' << creator << '</dc:creator>'
31
+ str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
30
32
  str << '<cp:revision>0</cp:revision>'
31
33
  str << '</cp:coreProperties>'
32
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The AreaChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
3
5
  # @example Creating a chart
@@ -61,7 +63,7 @@ module Axlsx
61
63
  # chart based on the actual class type and not a fixed node name.
62
64
  # @return [String]
63
65
  def node_name
64
- path = self.class.to_s
66
+ path = self.class.name
65
67
  if i = path.rindex('::')
66
68
  path = path[(i + 2)..-1]
67
69
  end
@@ -72,16 +74,16 @@ module Axlsx
72
74
  # Serializes the object
73
75
  # @param [String] str
74
76
  # @return [String]
75
- def to_xml_string(str = '')
77
+ def to_xml_string(str = +'')
76
78
  super(str) do
77
- str << ("<c:" << node_name << ">")
78
- str << ('<c:grouping val="' << grouping.to_s << '"/>')
79
- str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
79
+ str << "<c:" << node_name << ">"
80
+ str << '<c:grouping val="' << grouping.to_s << '"/>'
81
+ str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
80
82
  @series.each { |ser| ser.to_xml_string(str) }
81
83
  @d_lbls.to_xml_string(str) if @d_lbls
82
84
  yield if block_given?
83
- axes.to_xml_string(str, :ids => true)
84
- str << ("</c:" << node_name << ">")
85
+ axes.to_xml_string(str, ids: true)
86
+ str << "</c:" << node_name << ">"
85
87
  axes.to_xml_string(str)
86
88
  end
87
89
  end
@@ -90,7 +92,7 @@ module Axlsx
90
92
  # axis.
91
93
  # @return [Axes]
92
94
  def axes
93
- @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)
95
+ @axes ||= Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
94
96
  end
95
97
  end
96
98
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # A AreaSeries defines the title, data and labels for line charts
3
5
  # @note The recommended way to manage series is to use Chart#add_series
@@ -35,11 +37,11 @@ module Axlsx
35
37
  # @param [Chart] chart
36
38
  def initialize(chart, options = {})
37
39
  @show_marker = false
38
- @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
40
+ @marker_symbol = options[:marker_symbol] || :default
39
41
  @smooth = false
40
42
  @labels, @data = nil, nil
41
43
  super(chart, options)
42
- @labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
44
+ @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
43
45
  @data = NumDataSource.new(options) unless options[:data].nil?
44
46
  end
45
47
 
@@ -50,34 +52,34 @@ module Axlsx
50
52
 
51
53
  # @see show_marker
52
54
  def show_marker=(v)
53
- Axlsx::validate_boolean(v)
55
+ Axlsx.validate_boolean(v)
54
56
  @show_marker = v
55
57
  end
56
58
 
57
59
  # @see marker_symbol
58
60
  def marker_symbol=(v)
59
- Axlsx::validate_marker_symbol(v)
61
+ Axlsx.validate_marker_symbol(v)
60
62
  @marker_symbol = v
61
63
  end
62
64
 
63
65
  # @see smooth
64
66
  def smooth=(v)
65
- Axlsx::validate_boolean(v)
67
+ Axlsx.validate_boolean(v)
66
68
  @smooth = v
67
69
  end
68
70
 
69
71
  # Serializes the object
70
72
  # @param [String] str
71
73
  # @return [String]
72
- def to_xml_string(str = '')
74
+ def to_xml_string(str = +'')
73
75
  super(str) do
74
76
  if color
75
77
  str << '<c:spPr><a:solidFill>'
76
- str << ('<a:srgbClr val="' << color << '"/>')
78
+ str << '<a:srgbClr val="' << color << '"/>'
77
79
  str << '</a:solidFill>'
78
80
  str << '<a:ln w="28800">'
79
81
  str << '<a:solidFill>'
80
- str << ('<a:srgbClr val="' << color << '"/>')
82
+ str << '<a:srgbClr val="' << color << '"/>'
81
83
  str << '</a:solidFill>'
82
84
  str << '</a:ln>'
83
85
  str << '<a:round/>'
@@ -87,12 +89,12 @@ module Axlsx
87
89
  if !@show_marker
88
90
  str << '<c:marker><c:symbol val="none"/></c:marker>'
89
91
  elsif @marker_symbol != :default
90
- str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
92
+ str << '<c:marker><c:symbol val="' << @marker_symbol.to_s << '"/></c:marker>'
91
93
  end
92
94
 
93
95
  @labels.to_xml_string(str) unless @labels.nil?
94
96
  @data.to_xml_string(str) unless @data.nil?
95
- str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
97
+ str << '<c:smooth val="' << (smooth ? '1' : '0') << '"/>'
96
98
  end
97
99
  end
98
100
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # An axis data source that can contain referenced or literal strings or numbers
3
5
  # @note only string data types are supported - mainly because we have not implemented a chart type that requires a numerical axis value
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # The Axes class creates and manages axis information and
3
5
  # serialization for charts.
@@ -7,7 +9,7 @@ module Axlsx
7
9
  # class of the axis type to construct. The :cat_axis, if there is one,
8
10
  # must come first (we assume a Ruby 1.9+ Hash or an OrderedHash).
9
11
  def initialize(options = {})
10
- raise(ArgumentError, "CatAxis must come first") if options.keys.include?(:cat_axis) && options.keys.first != :cat_axis
12
+ raise(ArgumentError, "CatAxis must come first") if options.key?(:cat_axis) && options.keys.first != :cat_axis
11
13
 
12
14
  options.each do |name, axis_class|
13
15
  add_axis(name, axis_class)
@@ -27,11 +29,11 @@ module Axlsx
27
29
  # @option options ids
28
30
  # If the ids option is specified only the axis identifier is
29
31
  # serialized. Otherwise, each axis is serialized in full.
30
- def to_xml_string(str = '', options = {})
32
+ def to_xml_string(str = +'', options = {})
31
33
  if options[:ids]
32
34
  # CatAxis must come first in the XML (for Microsoft Excel at least)
33
- sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 }
34
- sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') }
35
+ sorted = axes.sort_by { |_name, axis| axis.is_a?(CatAxis) ? 0 : 1 }
36
+ sorted.each { |axis| str << '<c:axId val="' << axis[1].id.to_s << '"/>' }
35
37
  else
36
38
  axes.each { |axis| axis[1].to_xml_string(str) }
37
39
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Axlsx
2
4
  # the access class defines common properties and values for a chart axis.
3
5
  class Axis
@@ -13,7 +15,7 @@ module Axlsx
13
15
  @id = rand(8**8)
14
16
  @format_code = "General"
15
17
  @delete = @label_rotation = 0
16
- @scaling = Scaling.new(:orientation => :minMax)
18
+ @scaling = Scaling.new(orientation: :minMax)
17
19
  @title = @color = nil
18
20
  self.ax_pos = :b
19
21
  self.tick_lbl_pos = :nextTo
@@ -107,15 +109,15 @@ module Axlsx
107
109
 
108
110
  # The number format format code for this axis
109
111
  # default :General
110
- def format_code=(v) Axlsx::validate_string(v); @format_code = v; end
112
+ def format_code=(v) Axlsx.validate_string(v); @format_code = v; end
111
113
 
112
114
  # Specify if gridlines should be shown for this axis
113
115
  # default true
114
- def gridlines=(v) Axlsx::validate_boolean(v); @gridlines = v; end
116
+ def gridlines=(v) Axlsx.validate_boolean(v); @gridlines = v; end
115
117
 
116
118
  # Specify if axis should be removed from the chart
117
119
  # default false
118
- def delete=(v) Axlsx::validate_boolean(v); @delete = v; end
120
+ def delete=(v) Axlsx.validate_boolean(v); @delete = v; end
119
121
 
120
122
  # specifies how the perpendicular axis is crossed
121
123
  # must be one of [:autoZero, :min, :max]
@@ -124,9 +126,9 @@ module Axlsx
124
126
  # Specify the degree of label rotation to apply to labels
125
127
  # default true
126
128
  def label_rotation=(v)
127
- Axlsx::validate_int(v)
129
+ Axlsx.validate_int(v)
128
130
  adjusted = v.to_i * 60000
129
- Axlsx::validate_angle(adjusted)
131
+ Axlsx.validate_angle(adjusted)
130
132
  @label_rotation = adjusted
131
133
  end
132
134
 
@@ -146,13 +148,13 @@ module Axlsx
146
148
  # Serializes the object
147
149
  # @param [String] str
148
150
  # @return [String]
149
- def to_xml_string(str = '')
150
- str << ('<c:axId val="' << @id.to_s << '"/>')
151
+ def to_xml_string(str = +'')
152
+ str << '<c:axId val="' << @id.to_s << '"/>'
151
153
  @scaling.to_xml_string str
152
- str << ('<c:delete val="' << @delete.to_s << '"/>')
153
- str << ('<c:axPos val="' << @ax_pos.to_s << '"/>')
154
+ str << '<c:delete val="' << @delete.to_s << '"/>'
155
+ str << '<c:axPos val="' << @ax_pos.to_s << '"/>'
154
156
  str << '<c:majorGridlines>'
155
- # TODO shape properties need to be extracted into a class
157
+ # TODO: shape properties need to be extracted into a class
156
158
  if gridlines == false
157
159
  str << '<c:spPr>'
158
160
  str << '<a:ln>'
@@ -161,25 +163,25 @@ module Axlsx
161
163
  str << '</c:spPr>'
162
164
  end
163
165
  str << '</c:majorGridlines>'
164
- @title.to_xml_string(str) unless @title == nil
166
+ @title.to_xml_string(str) unless @title.nil?
165
167
  # Need to set sourceLinked to 0 if we're setting a format code on this row
166
168
  # otherwise it will never take, as it will always prefer the 'General' formatting
167
169
  # of the cells themselves
168
- str << ('<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>')
170
+ str << '<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>'
169
171
  str << '<c:majorTickMark val="none"/>'
170
172
  str << '<c:minorTickMark val="none"/>'
171
- str << ('<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>')
172
- # TODO - this is also being used for series colors
173
+ str << '<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>'
174
+ # TODO: this is also being used for series colors
173
175
  # time to extract this into a class spPr - Shape Properties
174
176
  if @color
175
177
  str << '<c:spPr><a:ln><a:solidFill>'
176
- str << ('<a:srgbClr val="' << @color << '"/>')
178
+ str << '<a:srgbClr val="' << @color << '"/>'
177
179
  str << '</a:solidFill></a:ln></c:spPr>'
178
180
  end
179
181
  # some potential value in implementing this in full. Very detailed!
180
- str << ('<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>')
181
- str << ('<c:crossAx val="' << @cross_axis.id.to_s << '"/>')
182
- str << ('<c:crosses val="' << @crosses.to_s << '"/>')
182
+ str << '<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>'
183
+ str << '<c:crossAx val="' << @cross_axis.id.to_s << '"/>'
184
+ str << '<c:crosses val="' << @crosses.to_s << '"/>'
183
185
  end
184
186
  end
185
187
  end