caxlsx 3.4.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/README.md +9 -11
  4. data/Rakefile +7 -5
  5. data/examples/generate.rb +3 -1
  6. data/lib/axlsx/content_type/abstract_content_type.rb +12 -4
  7. data/lib/axlsx/content_type/content_type.rb +8 -6
  8. data/lib/axlsx/content_type/default.rb +7 -2
  9. data/lib/axlsx/content_type/override.rb +7 -2
  10. data/lib/axlsx/doc_props/app.rb +95 -26
  11. data/lib/axlsx/doc_props/core.rb +8 -6
  12. data/lib/axlsx/drawing/area_chart.rb +10 -8
  13. data/lib/axlsx/drawing/area_series.rb +20 -12
  14. data/lib/axlsx/drawing/ax_data_source.rb +2 -0
  15. data/lib/axlsx/drawing/axes.rb +6 -4
  16. data/lib/axlsx/drawing/axis.rb +42 -22
  17. data/lib/axlsx/drawing/bar_3D_chart.rb +14 -12
  18. data/lib/axlsx/drawing/bar_chart.rb +13 -11
  19. data/lib/axlsx/drawing/bar_series.rb +20 -9
  20. data/lib/axlsx/drawing/bubble_chart.rb +6 -4
  21. data/lib/axlsx/drawing/bubble_series.rb +8 -6
  22. data/lib/axlsx/drawing/cat_axis.rb +29 -12
  23. data/lib/axlsx/drawing/chart.rb +46 -20
  24. data/lib/axlsx/drawing/d_lbls.rb +10 -8
  25. data/lib/axlsx/drawing/drawing.rb +59 -56
  26. data/lib/axlsx/drawing/graphic_frame.rb +6 -4
  27. data/lib/axlsx/drawing/hyperlink.rb +19 -8
  28. data/lib/axlsx/drawing/line_3D_chart.rb +7 -5
  29. data/lib/axlsx/drawing/line_chart.rb +10 -8
  30. data/lib/axlsx/drawing/line_series.rb +20 -12
  31. data/lib/axlsx/drawing/marker.rb +24 -7
  32. data/lib/axlsx/drawing/num_data.rb +9 -7
  33. data/lib/axlsx/drawing/num_data_source.rb +9 -7
  34. data/lib/axlsx/drawing/num_val.rb +7 -5
  35. data/lib/axlsx/drawing/one_cell_anchor.rb +13 -5
  36. data/lib/axlsx/drawing/pic.rb +26 -15
  37. data/lib/axlsx/drawing/picture_locking.rb +3 -1
  38. data/lib/axlsx/drawing/pie_3D_chart.rb +6 -4
  39. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  40. data/lib/axlsx/drawing/pie_series.rb +23 -9
  41. data/lib/axlsx/drawing/scaling.rb +25 -9
  42. data/lib/axlsx/drawing/scatter_chart.rb +7 -5
  43. data/lib/axlsx/drawing/scatter_series.rb +14 -12
  44. data/lib/axlsx/drawing/ser_axis.rb +13 -5
  45. data/lib/axlsx/drawing/series.rb +13 -5
  46. data/lib/axlsx/drawing/series_title.rb +6 -4
  47. data/lib/axlsx/drawing/str_data.rb +7 -5
  48. data/lib/axlsx/drawing/str_val.rb +6 -4
  49. data/lib/axlsx/drawing/title.rb +13 -14
  50. data/lib/axlsx/drawing/two_cell_anchor.rb +4 -2
  51. data/lib/axlsx/drawing/val_axis.rb +4 -2
  52. data/lib/axlsx/drawing/view_3D.rb +16 -8
  53. data/lib/axlsx/drawing/vml_drawing.rb +18 -16
  54. data/lib/axlsx/drawing/vml_shape.rb +24 -22
  55. data/lib/axlsx/package.rb +73 -67
  56. data/lib/axlsx/rels/relationship.rb +21 -6
  57. data/lib/axlsx/rels/relationships.rb +6 -4
  58. data/lib/axlsx/stylesheet/border.rb +15 -4
  59. data/lib/axlsx/stylesheet/border_pr.rb +19 -6
  60. data/lib/axlsx/stylesheet/cell_alignment.rb +41 -10
  61. data/lib/axlsx/stylesheet/cell_protection.rb +12 -3
  62. data/lib/axlsx/stylesheet/cell_style.rb +33 -8
  63. data/lib/axlsx/stylesheet/color.rb +15 -7
  64. data/lib/axlsx/stylesheet/dxf.rb +34 -9
  65. data/lib/axlsx/stylesheet/fill.rb +7 -2
  66. data/lib/axlsx/stylesheet/font.rb +65 -17
  67. data/lib/axlsx/stylesheet/gradient_fill.rb +12 -4
  68. data/lib/axlsx/stylesheet/gradient_stop.rb +14 -5
  69. data/lib/axlsx/stylesheet/num_fmt.rb +14 -10
  70. data/lib/axlsx/stylesheet/pattern_fill.rb +18 -5
  71. data/lib/axlsx/stylesheet/styles.rb +124 -82
  72. data/lib/axlsx/stylesheet/table_style.rb +19 -6
  73. data/lib/axlsx/stylesheet/table_style_element.rb +15 -4
  74. data/lib/axlsx/stylesheet/table_styles.rb +14 -5
  75. data/lib/axlsx/stylesheet/xf.rb +73 -18
  76. data/lib/axlsx/util/accessors.rb +10 -6
  77. data/lib/axlsx/util/buffered_zip_output_stream.rb +60 -0
  78. data/lib/axlsx/util/constants.rb +117 -104
  79. data/lib/axlsx/util/mime_type_utils.rb +3 -5
  80. data/lib/axlsx/util/options_parser.rb +3 -1
  81. data/lib/axlsx/util/serialized_attributes.rb +42 -17
  82. data/lib/axlsx/util/simple_typed_list.rb +47 -47
  83. data/lib/axlsx/util/storage.rb +11 -10
  84. data/lib/axlsx/util/validators.rb +101 -41
  85. data/lib/axlsx/util/zip_command.rb +10 -10
  86. data/lib/axlsx/version.rb +3 -1
  87. data/lib/axlsx/workbook/defined_name.rb +6 -4
  88. data/lib/axlsx/workbook/defined_names.rb +4 -2
  89. data/lib/axlsx/workbook/shared_strings_table.rb +8 -6
  90. data/lib/axlsx/workbook/workbook.rb +94 -79
  91. data/lib/axlsx/workbook/workbook_view.rb +3 -1
  92. data/lib/axlsx/workbook/workbook_views.rb +4 -2
  93. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +65 -8
  94. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -5
  95. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +11 -7
  96. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
  97. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +56 -0
  98. data/lib/axlsx/workbook/worksheet/border_creator.rb +5 -3
  99. data/lib/axlsx/workbook/worksheet/break.rb +3 -1
  100. data/lib/axlsx/workbook/worksheet/cell.rb +83 -64
  101. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +31 -27
  102. data/lib/axlsx/workbook/worksheet/cfvo.rb +11 -3
  103. data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -1
  104. data/lib/axlsx/workbook/worksheet/col.rb +5 -3
  105. data/lib/axlsx/workbook/worksheet/col_breaks.rb +6 -4
  106. data/lib/axlsx/workbook/worksheet/color_scale.rb +12 -10
  107. data/lib/axlsx/workbook/worksheet/cols.rb +4 -2
  108. data/lib/axlsx/workbook/worksheet/comment.rb +8 -6
  109. data/lib/axlsx/workbook/worksheet/comments.rb +6 -4
  110. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +16 -5
  111. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +73 -16
  112. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +4 -2
  113. data/lib/axlsx/workbook/worksheet/data_bar.rb +14 -13
  114. data/lib/axlsx/workbook/worksheet/data_validation.rb +69 -28
  115. data/lib/axlsx/workbook/worksheet/data_validations.rb +4 -2
  116. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +7 -5
  117. data/lib/axlsx/workbook/worksheet/dimension.rb +4 -2
  118. data/lib/axlsx/workbook/worksheet/header_footer.rb +4 -2
  119. data/lib/axlsx/workbook/worksheet/icon_set.rb +38 -9
  120. data/lib/axlsx/workbook/worksheet/merged_cells.rb +6 -6
  121. data/lib/axlsx/workbook/worksheet/outline_pr.rb +6 -2
  122. data/lib/axlsx/workbook/worksheet/page_margins.rb +39 -11
  123. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +7 -4
  124. data/lib/axlsx/workbook/worksheet/page_setup.rb +34 -9
  125. data/lib/axlsx/workbook/worksheet/pane.rb +17 -9
  126. data/lib/axlsx/workbook/worksheet/pivot_table.rb +20 -19
  127. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -6
  128. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +3 -1
  129. data/lib/axlsx/workbook/worksheet/print_options.rb +3 -1
  130. data/lib/axlsx/workbook/worksheet/protected_range.rb +3 -1
  131. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +6 -4
  132. data/lib/axlsx/workbook/worksheet/rich_text.rb +3 -1
  133. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +46 -24
  134. data/lib/axlsx/workbook/worksheet/row.rb +11 -9
  135. data/lib/axlsx/workbook/worksheet/row_breaks.rb +7 -5
  136. data/lib/axlsx/workbook/worksheet/selection.rb +15 -7
  137. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -2
  138. data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
  139. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +6 -2
  140. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +8 -4
  141. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +11 -9
  142. data/lib/axlsx/workbook/worksheet/sheet_view.rb +38 -15
  143. data/lib/axlsx/workbook/worksheet/table.rb +9 -7
  144. data/lib/axlsx/workbook/worksheet/table_style_info.rb +4 -2
  145. data/lib/axlsx/workbook/worksheet/tables.rb +4 -2
  146. data/lib/axlsx/workbook/worksheet/worksheet.rb +56 -39
  147. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -2
  148. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +8 -2
  149. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +7 -5
  150. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +5 -3
  151. data/lib/axlsx.rb +56 -42
  152. data/lib/caxlsx.rb +3 -1
  153. metadata +39 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bc64f23079fdbb6084190c180942bdf850ef2a0f0e6e75e68b3c9f63bcb6a2b
4
- data.tar.gz: 389bd6a8434de5942a54d47c2fafd4b407fead102ef0186d6f180879689c9a96
3
+ metadata.gz: 85f2cf4381c18d95630e069c270ec13a6f6e447efd10e20a8b7938c2cc453d51
4
+ data.tar.gz: 547ce4f04e33bcccd8ce2728a110b1caab8e49e0cd7a1f5ea06467a74b027ca0
5
5
  SHA512:
6
- metadata.gz: 4f0de7a6035a2179287b06eef2d942b53e4c5ba18f8d26dd5df7cb48ae32ecb320bce6fa8f778683f57de10a8f7a3b4e1c2123c8f25c3406360573bebf54ee25
7
- data.tar.gz: 5c85f6027cf1e286b53885d9d2cd0226eaff9079d1bc6933a0bb7659a85965c0f791e0d3ccf22ca745d44b4927b981c4abffe8734aa43043c98ffa5363c4698c
6
+ metadata.gz: 24b6d6be362e2dceb0a74ff3f891b21e2100af09eeae253a6bff1e86edf6d49a80fac9fa7747dadaf639f97bae121ecafecd3a1c5ac0022208efdb7fa08a056b
7
+ data.tar.gz: d1f7335c8199ae611bf4fdf49bd85aeae3936e6afc596193037dd6a7aeb7dbcbf72c9fb38b4f59bb6b6c2d868bb253e3e98b33a9fbd48bda75940bc5f65bf8ba
data/CHANGELOG.md CHANGED
@@ -1,6 +1,29 @@
1
1
  CHANGELOG
2
2
  ---------
3
- - **Unreleased**: 3.4.1
3
+ - **Unreleased**
4
+
5
+ - **February.26.24**: 4.1.0
6
+ - [PR #316](https://github.com/caxlsx/caxlsx/pull/316) Prevent camelization of hyperlink locations
7
+ - [PR #312](https://github.com/caxlsx/caxlsx/pull/312) Added 2D/flat PieChart drawing
8
+ - [PR #317](https://github.com/caxlsx/caxlsx/pull/317) Apply style for columns without defining cells
9
+ - [PR #345](https://github.com/caxlsx/caxlsx/pull/345) Show outline symbols by default to match original behavior
10
+ - [PR #334](https://github.com/caxlsx/caxlsx/pull/334) Add pattern fill options to add_style
11
+ - [PR #342](https://github.com/caxlsx/caxlsx/pull/342) Fix show button for filter columns
12
+ - [PR #349](https://github.com/caxlsx/caxlsx/pull/349) Convert test suite to Minitest
13
+
14
+ - **October.30.23**: 4.0.0
15
+ - [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.
16
+ - [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
17
+ - [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
18
+ - Drop support for Ruby versions < 2.6
19
+ - [PR #219](https://github.com/caxlsx/caxlsx/pull/219) Added frozen string literals
20
+ - [PR #223](https://github.com/caxlsx/caxlsx/pull/223) Fix `SimpleTypedList#to_a` and `SimpleTypedList#to_ary` returning the internal list instance
21
+ - [PR #239](https://github.com/caxlsx/caxlsx/pull/239) Fix `Workbook#sheet_by_name` not returning sheets with encoded characters in the name
22
+ - [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.
23
+ - [PR #269](https://github.com/caxlsx/caxlsx/pull/269) Add optional interpolation points to icon sets
24
+ - [PR #304](https://github.com/caxlsx/caxlsx/pull/304) Fix data validations for none type validations
25
+
26
+ - **April.23.23**: 3.4.1
4
27
  - [PR #209](https://github.com/caxlsx/caxlsx/pull/209) - Revert characters other than `=` being considered as formulas.
5
28
 
6
29
  - **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
data/examples/generate.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
+
3
5
  files = if !ARGV.empty?
4
6
  ARGV.select { |file| File.exist?(file) }
5
7
  else
@@ -10,6 +12,6 @@ files.each do |file|
10
12
  puts "Executing #{file.split('.')[0].tr('_', ' ')}"
11
13
  code = File.read(file).match(/```ruby(?<code>.+)```/m)[:code]
12
14
  unless code.nil?
13
- eval(['$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"', code].join("\n"))
15
+ eval(code)
14
16
  end
15
17
  end
@@ -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,19 @@ 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)
22
+ Axlsx.validate_content_type v
23
+ @content_type = v
24
+ end
20
25
  alias :ContentType= :content_type=
21
26
 
22
27
  # 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(' ')
28
+ def to_xml_string(node_name = '', str = +'')
29
+ str << '<' << node_name << ' '
30
+ Axlsx.instance_values_for(self).each_with_index do |key_value, index|
31
+ str << ' ' unless index.zero?
32
+ str << Axlsx.camel(key_value.first) << '="' << key_value.last.to_s << '"'
33
+ end
26
34
  str << '/>'
27
35
  end
28
36
  end
@@ -1,20 +1,22 @@
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
8
10
  def initialize
9
- super [Override, Default]
11
+ super([Override, Default])
10
12
  end
11
13
 
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,14 @@ 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)
16
+ Axlsx.validate_string v
17
+ @extension = v
18
+ end
14
19
  alias :Extension= :extension=
15
20
 
16
21
  # Serializes this object to xml
17
- def to_xml_string(str = '')
22
+ def to_xml_string(str = +'')
18
23
  super(NODE_NAME, str)
19
24
  end
20
25
  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,14 @@ 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)
16
+ Axlsx.validate_string v
17
+ @part_name = v
18
+ end
14
19
  alias :PartName= :part_name=
15
20
 
16
21
  # Serializes this object to xml
17
- def to_xml_string(str = '')
22
+ def to_xml_string(str = +'')
18
23
  super(NODE_NAME, str)
19
24
  end
20
25
  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
@@ -73,7 +75,7 @@ module Axlsx
73
75
  attr_reader :paragraphs
74
76
  alias :Paragraphs :paragraphs
75
77
 
76
- # @return [Intger] The number of slides in the document.
78
+ # @return [Integer] The number of slides in the document.
77
79
  attr_reader :slides
78
80
  alias :Slides :slides
79
81
 
@@ -119,7 +121,7 @@ module Axlsx
119
121
 
120
122
  # @return [String] The name of the application
121
123
  attr_reader :application
122
- alias :Applicatoin :application
124
+ alias :Application :application
123
125
 
124
126
  # @return [String] The version of the application.
125
127
  attr_reader :app_version
@@ -130,96 +132,163 @@ 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)
136
+ Axlsx.validate_string v
137
+ @template = v
138
+ end
134
139
  alias :Template= :template=
135
140
 
136
141
  # Sets the manager property of your app.xml file
137
- def manager=(v) Axlsx::validate_string v; @manager = v; end
142
+ def manager=(v)
143
+ Axlsx.validate_string v
144
+ @manager = v
145
+ end
138
146
  alias :Manager= :manager=
139
147
 
140
148
  # Sets the company property of your app.xml file
141
- def company=(v) Axlsx::validate_string v; @company = v; end
149
+ def company=(v)
150
+ Axlsx.validate_string v
151
+ @company = v
152
+ end
142
153
  alias :Company= :company=
154
+
143
155
  # Sets the pages property of your app.xml file
144
- def pages=(v) Axlsx::validate_int v; @pages = v; end
156
+ def pages=(v)
157
+ Axlsx.validate_int v
158
+ @pages = v
159
+ end
145
160
 
146
161
  # Sets the words property of your app.xml file
147
- def words=(v) Axlsx::validate_int v; @words = v; end
162
+ def words=(v)
163
+ Axlsx.validate_int v
164
+ @words = v
165
+ end
148
166
  alias :Words= :words=
149
167
 
150
168
  # Sets the characters property of your app.xml file
151
- def characters=(v) Axlsx::validate_int v; @characters = v; end
169
+ def characters=(v)
170
+ Axlsx.validate_int v
171
+ @characters = v
172
+ end
152
173
  alias :Characters= :characters=
153
174
 
154
175
  # Sets the presentation_format property of your app.xml file
155
- def presentation_format=(v) Axlsx::validate_string v; @presentation_format = v; end
176
+ def presentation_format=(v)
177
+ Axlsx.validate_string v
178
+ @presentation_format = v
179
+ end
156
180
  alias :PresentationFormat= :presentation_format=
157
181
 
158
182
  # Sets the lines property of your app.xml file
159
- def lines=(v) Axlsx::validate_int v; @lines = v; end
183
+ def lines=(v)
184
+ Axlsx.validate_int v
185
+ @lines = v
186
+ end
160
187
  alias :Lines= :lines=
161
188
 
162
189
  # Sets the paragraphs property of your app.xml file
163
- def paragraphs=(v) Axlsx::validate_int v; @paragraphs = v; end
190
+ def paragraphs=(v)
191
+ Axlsx.validate_int v
192
+ @paragraphs = v
193
+ end
164
194
  alias :Paragraphs= :paragraphs=
165
195
 
166
196
  # sets the slides property of your app.xml file
167
- def slides=(v) Axlsx::validate_int v; @slides = v; end
197
+ def slides=(v)
198
+ Axlsx.validate_int v
199
+ @slides = v
200
+ end
168
201
  alias :Slides= :slides=
169
202
 
170
203
  # sets the notes property of your app.xml file
171
- def notes=(v) Axlsx::validate_int v; @notes = v; end
204
+ def notes=(v)
205
+ Axlsx.validate_int v
206
+ @notes = v
207
+ end
172
208
  alias :Notes= :notes=
173
209
 
174
210
  # Sets the total_time property of your app.xml file
175
- def total_time=(v) Axlsx::validate_int v; @total_time = v; end
211
+ def total_time=(v)
212
+ Axlsx.validate_int v
213
+ @total_time = v
214
+ end
176
215
  alias :TotalTime= :total_time=
177
216
 
178
217
  # Sets the hidden_slides property of your app.xml file
179
- def hidden_slides=(v) Axlsx::validate_int v; @hidden_slides = v; end
218
+ def hidden_slides=(v)
219
+ Axlsx.validate_int v
220
+ @hidden_slides = v
221
+ end
180
222
  alias :HiddenSlides= :hidden_slides=
181
223
 
182
224
  # 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
225
+ def m_m_clips=(v)
226
+ Axlsx.validate_int v
227
+ @m_m_clips = v
228
+ end
184
229
  alias :MMClips= :m_m_clips=
185
230
 
186
231
  # Sets the scale_crop property of your app.xml file
187
- def scale_crop=(v) Axlsx::validate_boolean v; @scale_crop = v; end
232
+ def scale_crop=(v)
233
+ Axlsx.validate_boolean v
234
+ @scale_crop = v
235
+ end
188
236
  alias :ScaleCrop= :scale_crop=
189
237
 
190
238
  # 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
239
+ def links_up_to_date=(v)
240
+ Axlsx.validate_boolean v
241
+ @links_up_to_date = v
242
+ end
192
243
  alias :LinksUpToDate= :links_up_to_date=
193
244
 
194
245
  # 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
246
+ def characters_with_spaces=(v)
247
+ Axlsx.validate_int v
248
+ @characters_with_spaces = v
249
+ end
196
250
  alias :CharactersWithSpaces= :characters_with_spaces=
197
251
 
198
252
  # Sets the share_doc property of your app.xml file
199
- def shared_doc=(v) Axlsx::validate_boolean v; @shared_doc = v; end
253
+ def shared_doc=(v)
254
+ Axlsx.validate_boolean v
255
+ @shared_doc = v
256
+ end
200
257
  alias :SharedDoc= :shared_doc=
201
258
 
202
259
  # Sets the hyperlink_base property of your app.xml file
203
- def hyperlink_base=(v) Axlsx::validate_string v; @hyperlink_base = v; end
260
+ def hyperlink_base=(v)
261
+ Axlsx.validate_string v
262
+ @hyperlink_base = v
263
+ end
204
264
  alias :HyperlinkBase= :hyperlink_base=
205
265
 
206
266
  # Sets the HyperLinksChanged property of your app.xml file
207
- def hyperlinks_changed=(v) Axlsx::validate_boolean v; @hyperlinks_changed = v; end
267
+ def hyperlinks_changed=(v)
268
+ Axlsx.validate_boolean v
269
+ @hyperlinks_changed = v
270
+ end
208
271
  alias :HyperLinksChanged= :hyperlinks_changed=
209
272
 
210
273
  # Sets the app_version property of your app.xml file
211
- def app_version=(v) Axlsx::validate_string v; @app_version = v; end
274
+ def app_version=(v)
275
+ Axlsx.validate_string v
276
+ @app_version = v
277
+ end
212
278
  alias :AppVersion= :app_version=
213
279
 
214
280
  # Sets the doc_security property of your app.xml file
215
- def doc_security=(v) Axlsx::validate_int v; @doc_security = v; end
281
+ def doc_security=(v)
282
+ Axlsx.validate_int v
283
+ @doc_security = v
284
+ end
216
285
  alias :DocSecurity= :doc_security=
217
286
 
218
287
  # Serialize the app.xml document
219
288
  # @return [String]
220
- def to_xml_string(str = '')
289
+ def to_xml_string(str = +'')
221
290
  str << '<?xml version="1.0" encoding="UTF-8"?>'
222
- str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">')
291
+ str << '<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">'
223
292
  Axlsx.instance_values_for(self).each do |key, value|
224
293
  node_name = Axlsx.camel(key)
225
294
  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,21 +89,27 @@ 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
 
99
101
  private
100
102
 
101
103
  # assigns the data for this series
102
- def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
104
+ def data=(v)
105
+ DataTypeValidator.validate "Series.data", [NumDataSource], v
106
+ @data = v
107
+ end
103
108
 
104
109
  # assigns the labels for this series
105
- def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
110
+ def labels=(v)
111
+ DataTypeValidator.validate "Series.labels", [AxDataSource], v
112
+ @labels = v
113
+ end
106
114
  end
107
115
  end
@@ -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