caxlsx 3.3.0 → 4.0.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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/README.md +25 -7
  4. data/Rakefile +7 -6
  5. data/lib/axlsx/content_type/abstract_content_type.rb +11 -9
  6. data/lib/axlsx/content_type/content_type.rb +7 -9
  7. data/lib/axlsx/content_type/default.rb +4 -6
  8. data/lib/axlsx/content_type/override.rb +3 -5
  9. data/lib/axlsx/doc_props/app.rb +27 -30
  10. data/lib/axlsx/doc_props/core.rb +9 -12
  11. data/lib/axlsx/drawing/area_chart.rb +13 -14
  12. data/lib/axlsx/drawing/area_series.rb +13 -14
  13. data/lib/axlsx/drawing/ax_data_source.rb +3 -6
  14. data/lib/axlsx/drawing/axes.rb +10 -9
  15. data/lib/axlsx/drawing/axis.rb +27 -30
  16. data/lib/axlsx/drawing/bar_3D_chart.rb +17 -18
  17. data/lib/axlsx/drawing/bar_chart.rb +16 -17
  18. data/lib/axlsx/drawing/bar_series.rb +9 -13
  19. data/lib/axlsx/drawing/bubble_chart.rb +8 -9
  20. data/lib/axlsx/drawing/bubble_series.rb +9 -10
  21. data/lib/axlsx/drawing/cat_axis.rb +14 -17
  22. data/lib/axlsx/drawing/chart.rb +25 -28
  23. data/lib/axlsx/drawing/d_lbls.rb +29 -26
  24. data/lib/axlsx/drawing/drawing.rb +60 -62
  25. data/lib/axlsx/drawing/graphic_frame.rb +6 -7
  26. data/lib/axlsx/drawing/hyperlink.rb +12 -13
  27. data/lib/axlsx/drawing/line_3D_chart.rb +13 -15
  28. data/lib/axlsx/drawing/line_chart.rb +13 -14
  29. data/lib/axlsx/drawing/line_series.rb +13 -14
  30. data/lib/axlsx/drawing/marker.rb +14 -16
  31. data/lib/axlsx/drawing/num_data.rb +13 -16
  32. data/lib/axlsx/drawing/num_data_source.rb +11 -13
  33. data/lib/axlsx/drawing/num_val.rb +9 -10
  34. data/lib/axlsx/drawing/one_cell_anchor.rb +10 -10
  35. data/lib/axlsx/drawing/pic.rb +57 -22
  36. data/lib/axlsx/drawing/picture_locking.rb +6 -7
  37. data/lib/axlsx/drawing/pie_3D_chart.rb +6 -9
  38. data/lib/axlsx/drawing/pie_series.rb +9 -12
  39. data/lib/axlsx/drawing/scaling.rb +9 -10
  40. data/lib/axlsx/drawing/scatter_chart.rb +9 -10
  41. data/lib/axlsx/drawing/scatter_series.rb +15 -16
  42. data/lib/axlsx/drawing/ser_axis.rb +9 -11
  43. data/lib/axlsx/drawing/series.rb +8 -8
  44. data/lib/axlsx/drawing/series_title.rb +6 -6
  45. data/lib/axlsx/drawing/str_data.rb +10 -13
  46. data/lib/axlsx/drawing/str_val.rb +8 -9
  47. data/lib/axlsx/drawing/title.rb +23 -27
  48. data/lib/axlsx/drawing/two_cell_anchor.rb +8 -8
  49. data/lib/axlsx/drawing/val_axis.rb +5 -6
  50. data/lib/axlsx/drawing/view_3D.rb +32 -30
  51. data/lib/axlsx/drawing/vml_drawing.rb +19 -20
  52. data/lib/axlsx/drawing/vml_shape.rb +25 -26
  53. data/lib/axlsx/package.rb +81 -79
  54. data/lib/axlsx/rels/relationship.rb +30 -28
  55. data/lib/axlsx/rels/relationships.rb +7 -8
  56. data/lib/axlsx/stylesheet/border.rb +7 -8
  57. data/lib/axlsx/stylesheet/border_pr.rb +8 -8
  58. data/lib/axlsx/stylesheet/cell_alignment.rb +14 -20
  59. data/lib/axlsx/stylesheet/cell_protection.rb +6 -7
  60. data/lib/axlsx/stylesheet/cell_style.rb +12 -14
  61. data/lib/axlsx/stylesheet/color.rb +15 -12
  62. data/lib/axlsx/stylesheet/dxf.rb +7 -9
  63. data/lib/axlsx/stylesheet/fill.rb +3 -5
  64. data/lib/axlsx/stylesheet/font.rb +24 -21
  65. data/lib/axlsx/stylesheet/gradient_fill.rb +9 -9
  66. data/lib/axlsx/stylesheet/gradient_stop.rb +7 -6
  67. data/lib/axlsx/stylesheet/num_fmt.rb +9 -14
  68. data/lib/axlsx/stylesheet/pattern_fill.rb +8 -8
  69. data/lib/axlsx/stylesheet/styles.rb +104 -98
  70. data/lib/axlsx/stylesheet/table_style.rb +8 -9
  71. data/lib/axlsx/stylesheet/table_style_element.rb +7 -8
  72. data/lib/axlsx/stylesheet/table_styles.rb +8 -10
  73. data/lib/axlsx/stylesheet/xf.rb +21 -22
  74. data/lib/axlsx/util/accessors.rb +6 -6
  75. data/lib/axlsx/util/buffered_zip_output_stream.rb +60 -0
  76. data/lib/axlsx/util/constants.rb +119 -108
  77. data/lib/axlsx/util/mime_type_utils.rb +11 -0
  78. data/lib/axlsx/util/options_parser.rb +4 -3
  79. data/lib/axlsx/util/serialized_attributes.rb +45 -21
  80. data/lib/axlsx/util/simple_typed_list.rb +58 -57
  81. data/lib/axlsx/util/storage.rb +38 -41
  82. data/lib/axlsx/util/validators.rb +107 -44
  83. data/lib/axlsx/util/zip_command.rb +10 -12
  84. data/lib/axlsx/version.rb +3 -2
  85. data/lib/axlsx/workbook/defined_name.rb +11 -8
  86. data/lib/axlsx/workbook/defined_names.rb +4 -3
  87. data/lib/axlsx/workbook/shared_strings_table.rb +10 -11
  88. data/lib/axlsx/workbook/workbook.rb +121 -114
  89. data/lib/axlsx/workbook/workbook_view.rb +8 -11
  90. data/lib/axlsx/workbook/workbook_views.rb +4 -4
  91. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +72 -14
  92. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -7
  93. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +24 -21
  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 +30 -25
  97. data/lib/axlsx/workbook/worksheet/break.rb +4 -5
  98. data/lib/axlsx/workbook/worksheet/cell.rb +92 -65
  99. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +32 -28
  100. data/lib/axlsx/workbook/worksheet/cfvo.rb +7 -5
  101. data/lib/axlsx/workbook/worksheet/cfvos.rb +5 -5
  102. data/lib/axlsx/workbook/worksheet/col.rb +9 -10
  103. data/lib/axlsx/workbook/worksheet/col_breaks.rb +8 -7
  104. data/lib/axlsx/workbook/worksheet/color_scale.rb +16 -16
  105. data/lib/axlsx/workbook/worksheet/cols.rb +9 -7
  106. data/lib/axlsx/workbook/worksheet/comment.rb +12 -11
  107. data/lib/axlsx/workbook/worksheet/comments.rb +10 -12
  108. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +12 -8
  109. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +19 -21
  110. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +5 -5
  111. data/lib/axlsx/workbook/worksheet/data_bar.rb +29 -30
  112. data/lib/axlsx/workbook/worksheet/data_validation.rb +34 -33
  113. data/lib/axlsx/workbook/worksheet/data_validations.rb +5 -6
  114. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +8 -8
  115. data/lib/axlsx/workbook/worksheet/dimension.rb +9 -6
  116. data/lib/axlsx/workbook/worksheet/header_footer.rb +4 -3
  117. data/lib/axlsx/workbook/worksheet/icon_set.rb +24 -8
  118. data/lib/axlsx/workbook/worksheet/merged_cells.rb +10 -10
  119. data/lib/axlsx/workbook/worksheet/outline_pr.rb +6 -3
  120. data/lib/axlsx/workbook/worksheet/page_margins.rb +17 -12
  121. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -4
  122. data/lib/axlsx/workbook/worksheet/page_setup.rb +128 -129
  123. data/lib/axlsx/workbook/worksheet/pane.rb +27 -26
  124. data/lib/axlsx/workbook/worksheet/pivot_table.rb +23 -25
  125. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +12 -13
  126. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +5 -4
  127. data/lib/axlsx/workbook/worksheet/print_options.rb +3 -2
  128. data/lib/axlsx/workbook/worksheet/protected_range.rb +6 -5
  129. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +12 -10
  130. data/lib/axlsx/workbook/worksheet/rich_text.rb +6 -6
  131. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +35 -17
  132. data/lib/axlsx/workbook/worksheet/row.rb +30 -22
  133. data/lib/axlsx/workbook/worksheet/row_breaks.rb +8 -7
  134. data/lib/axlsx/workbook/worksheet/selection.rb +16 -16
  135. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +10 -7
  136. data/lib/axlsx/workbook/worksheet/sheet_data.rb +7 -7
  137. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +23 -19
  138. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +11 -7
  139. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +21 -20
  140. data/lib/axlsx/workbook/worksheet/sheet_view.rb +48 -53
  141. data/lib/axlsx/workbook/worksheet/table.rb +13 -13
  142. data/lib/axlsx/workbook/worksheet/table_style_info.rb +6 -5
  143. data/lib/axlsx/workbook/worksheet/tables.rb +7 -5
  144. data/lib/axlsx/workbook/worksheet/worksheet.rb +92 -63
  145. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +10 -8
  146. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +11 -4
  147. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +9 -8
  148. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +7 -5
  149. data/lib/axlsx.rb +75 -47
  150. data/lib/caxlsx.rb +3 -2
  151. metadata +50 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f5803740b82493118fd7fe6787c90dd0eb8e2f7908736597026d03c4255597b
4
- data.tar.gz: 3bf010de6171b2862cd27ea12df265162071801b0cac7172cee4d1629e856835
3
+ metadata.gz: fcc3d364dba9ddb0058e9e64e7fbb537915dee8fc8adfc308e263d210c643488
4
+ data.tar.gz: e5582a8e8f2cecdcc7fcebea3c1193d8c6f7351a2882ffa2a51f25ca05b9874c
5
5
  SHA512:
6
- metadata.gz: 40af150a59e4aacb3f1d385117d0c21b1b2d8ca3c36e12592f23464b35270ac07af826c2494c9922510603e96933de82dafb4819b8ac31b892c7ce842eb190cc
7
- data.tar.gz: bd16de0493f11a225fd7e376cdce5b10433f253431e2d00f9ecfeca464f96336499d35806781de77ad5c1dad62a63bb2545deb7e00cfef6fc0a4a1f0657103e1
6
+ metadata.gz: bcb83efcf758bbdd201d877c1f34a2f30fcf5e676359aaecdaf47be68cc9c7481caf0b19786b605ce7c600d855d40d84e2b27b4987e0498e60507a157e6a6e53
7
+ data.tar.gz: 9caa406e7f059088f8adbd88e3429ccd920bb4a25b9ac6933395f2e072f561591f3b935f1eb08263c80486818941fef186a7d660e050c08973fb687d008eb29e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@ CHANGELOG
2
2
  ---------
3
3
  - **Unreleased**
4
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
19
+ - [PR #209](https://github.com/caxlsx/caxlsx/pull/209) - Revert characters other than `=` being considered as formulas.
20
+
21
+ - **April.12.23**: 3.4.0
22
+ - [PR #186](https://github.com/caxlsx/caxlsx/pull/186) - Add `escape_formulas` to global, workbook, worksheet, row and cell levels, and standardize behavior.
23
+ - [PR #186](https://github.com/caxlsx/caxlsx/pull/186) - `escape_formulas` should handle all [OWASP-designated formula prefixes](https://owasp.org/www-community/attacks/CSV_Injection).
24
+ - Fix bug when calling `worksheet.add_border("A1:B2", nil)`
25
+ - Change `BorderCreator#initialize` arguments handling
26
+ - Fix `add_border` to work with singluar cell refs
27
+ - [PR #196](https://github.com/caxlsx/caxlsx/pull/196) - Fix tab color reassignment
28
+ - Add support for remote image source in `Pic` using External Relationship (supported in Excel documents)
29
+
5
30
  - **October.21.22**: 3.3.0
6
31
  - [PR #168](https://github.com/caxlsx/caxlsx/pull/168) - Merge in the gem [`axlsx_styler`](https://github.com/axlsx-styler-gem/axlsx_styler)
7
32
  - Add ability to both apply or append to existing styles after rows have been created using `worksheet.add_style`
data/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # Caxlsx (Community Continued Version)
2
- [![Build Status](https://github.com/caxlsx/caxlsx/workflows/Test/badge.svg)](https://github.com/caxlsx/caxlsx/actions)
3
- [![Gem Version](https://badge.fury.io/rb/caxlsx.svg)](http://badge.fury.io/rb/caxlsx)
4
- ![Total downloads](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx?type=total)
5
- ![Downloads for 3.3.0 (latest)](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx/3.3.0?label=downloads%203.3.0)
2
+ [![Test](https://github.com/caxlsx/caxlsx/actions/workflows/test.yml/badge.svg)](https://github.com/caxlsx/caxlsx/actions/workflows/test.yml)
3
+ [![RuboCop](https://github.com/caxlsx/caxlsx/actions/workflows/rubocop.yml/badge.svg)](https://github.com/caxlsx/caxlsx/actions/workflows/rubocop.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/caxlsx.svg)](https://badge.fury.io/rb/caxlsx)
5
+ ![downloads](https://img.shields.io/gem/dt/caxlsx?label=downloads)
6
6
 
7
7
  ## Notice: Community Axlsx Organization
8
8
 
9
9
  To better maintain the Axlsx ecosystem, all related gems have been forked or moved to the following community organization:
10
10
 
11
- http://github.com/caxlsx
11
+ https://github.com/caxlsx
12
12
 
13
13
  [Join the Caxlsx Slack channel](https://join.slack.com/t/caxlsx/shared_invite/enQtOTI5OTM0MzI1Njk5LTBlMDQzNDk2YzkwODMxMmVkODMyYzJiZGU5NTQ3YTg5NTBlN2IwZTlmNTRjNzhiY2E0MDY2OTEyYmFlODI5NjA)
14
14
 
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.
@@ -120,6 +122,22 @@ Currently the following additional gems are available:
120
122
  - [activeadmin-caxlsx](https://github.com/caxlsx/activeadmin-caxlsx)
121
123
  * An Active Admin plugin that includes DSL to create downloadable reports.
122
124
 
125
+ ## Security
126
+
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:
128
+
129
+ ```ruby
130
+ cell.escape_formulas = false
131
+ ```
132
+
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:
136
+
137
+ ```ruby
138
+ Axlsx.escape_formulas = false
139
+ ```
140
+
123
141
  ## Known Software Interoperability Issues
124
142
 
125
143
  As axslx implements the Office Open XML (ECMA-376 spec) much of the
@@ -160,6 +178,6 @@ See [CONTRIBUTING.md](https://github.com/caxlsx/caxlsx/blob/master/CONTRIBUTING.
160
178
 
161
179
  Originally created by Randy Morgan - @randym
162
180
 
163
- Forked in 2019, to enable the community to maintain the Axlsx ecosystem - http://github.com/caxlsx
181
+ Forked in 2019, to enable the community to maintain the Axlsx ecosystem - https://github.com/caxlsx
164
182
 
165
183
  Open source software is a community effort. None of this could have been done without the help of [our Contributors](https://github.com/caxlsx/caxlsx/graphs/contributors).
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
@@ -13,7 +15,6 @@ task :gendoc do
13
15
  system "yard stats --list-undoc"
14
16
  end
15
17
 
16
-
17
18
  require 'rake/testtask'
18
19
  Rake::TestTask.new do |t|
19
20
  t.libs << 'test'
@@ -22,8 +23,8 @@ Rake::TestTask.new do |t|
22
23
  t.warning = true
23
24
  end
24
25
 
25
- task :release => :build do
26
+ task release: :build do
26
27
  system "gem push caxlsx-#{Axlsx::VERSION}.gem"
27
28
  end
28
29
 
29
- task :default => :test
30
+ task default: :test
@@ -1,14 +1,14 @@
1
- module Axlsx
1
+ # frozen_string_literal: true
2
2
 
3
+ module Axlsx
3
4
  # This class extracts the common parts from Default and Override
4
5
  class AbstractContentType
5
-
6
6
  include Axlsx::OptionsParser
7
7
 
8
8
  # Initializes an abstract content type
9
9
  # @see Default, Override
10
- def initialize(options={})
11
- parse_options options
10
+ def initialize(options = {})
11
+ parse_options options
12
12
  end
13
13
 
14
14
  # The type of content.
@@ -18,15 +18,17 @@ module Axlsx
18
18
 
19
19
  # The content type.
20
20
  # @see Axlsx#validate_content_type
21
- 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
22
22
  alias :ContentType= :content_type=
23
23
 
24
24
  # Serialize the contenty type to xml
25
- def to_xml_string(node_name = '', str = '')
26
- str << "<#{node_name} "
27
- 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
28
31
  str << '/>'
29
32
  end
30
-
31
33
  end
32
34
  end
@@ -1,12 +1,12 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
- require 'axlsx/content_type/abstract_content_type.rb'
4
- require 'axlsx/content_type/default.rb'
5
- 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'
6
7
 
7
8
  # ContentTypes used in the package. This is automatically managed by the package package.
8
9
  class ContentType < SimpleTypedList
9
-
10
10
  def initialize
11
11
  super [Override, Default]
12
12
  end
@@ -14,13 +14,11 @@ module Axlsx
14
14
  # Serializes the object
15
15
  # @param [String] str
16
16
  # @return [String]
17
- def to_xml_string(str = '')
17
+ def to_xml_string(str = +'')
18
18
  str << '<?xml version="1.0" encoding="UTF-8"?>'
19
- str << ('<Types xmlns="' << XML_NS_T << '">')
19
+ str << '<Types xmlns="' << XML_NS_T << '">'
20
20
  each { |type| type.to_xml_string(str) }
21
21
  str << '</Types>'
22
22
  end
23
-
24
23
  end
25
-
26
24
  end
@@ -1,9 +1,8 @@
1
- # encoding: UTF-8
2
- module Axlsx
1
+ # frozen_string_literal: true
3
2
 
3
+ module Axlsx
4
4
  # An default content part. These parts are automatically created by for you based on the content of your package.
5
5
  class Default < AbstractContentType
6
-
7
6
  # The serialization node name for this class
8
7
  NODE_NAME = 'Default'
9
8
 
@@ -13,13 +12,12 @@ module Axlsx
13
12
  alias :Extension :extension
14
13
 
15
14
  # Sets the file extension for this content type.
16
- def extension=(v) Axlsx::validate_string v; @extension = v end
15
+ def extension=(v) Axlsx.validate_string v; @extension = v end
17
16
  alias :Extension= :extension=
18
17
 
19
18
  # Serializes this object to xml
20
- def to_xml_string(str ='')
19
+ def to_xml_string(str = +'')
21
20
  super(NODE_NAME, str)
22
21
  end
23
22
  end
24
-
25
23
  end
@@ -1,10 +1,8 @@
1
+ # frozen_string_literal: true
1
2
 
2
- # encoding: UTF-8
3
3
  module Axlsx
4
-
5
4
  # An override content part. These parts are automatically created by for you based on the content of your package.
6
5
  class Override < AbstractContentType
7
-
8
6
  # Serialization node name for this object
9
7
  NODE_NAME = 'Override'
10
8
 
@@ -14,11 +12,11 @@ module Axlsx
14
12
  alias :PartName :part_name
15
13
 
16
14
  # The name and location of the part.
17
- 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
18
16
  alias :PartName= :part_name=
19
17
 
20
18
  # Serializes this object to xml
21
- def to_xml_string(str = '')
19
+ def to_xml_string(str = +'')
22
20
  super(NODE_NAME, str)
23
21
  end
24
22
  end
@@ -1,6 +1,6 @@
1
- # encoding: UTF-8
2
- module Axlsx
1
+ # frozen_string_literal: true
3
2
 
3
+ module Axlsx
4
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.
5
5
  # @see shared-documentPropertiesExtended.xsd
6
6
  # @note Support is not implemented for the following complex types:
@@ -10,7 +10,6 @@ module Axlsx
10
10
  # HLinks (VectorVariant),
11
11
  # DigSig (DigSigBlob)
12
12
  class App
13
-
14
13
  include Axlsx::OptionsParser
15
14
 
16
15
  # Creates an App object
@@ -36,7 +35,7 @@ module Axlsx
36
35
  # @option options [String] application
37
36
  # @option options [String] app_version
38
37
  # @option options [Integer] doc_security
39
- def initialize(options={})
38
+ def initialize(options = {})
40
39
  parse_options options
41
40
  end
42
41
 
@@ -133,103 +132,101 @@ module Axlsx
133
132
  alias :DocSecurity :doc_security
134
133
 
135
134
  # Sets the template property of your app.xml file
136
- def template=(v) Axlsx::validate_string v; @template = v; end
135
+ def template=(v) Axlsx.validate_string v; @template = v; end
137
136
  alias :Template= :template=
138
137
 
139
138
  # Sets the manager property of your app.xml file
140
- def manager=(v) Axlsx::validate_string v; @manager = v; end
139
+ def manager=(v) Axlsx.validate_string v; @manager = v; end
141
140
  alias :Manager= :manager=
142
141
 
143
142
  # Sets the company property of your app.xml file
144
- def company=(v) Axlsx::validate_string v; @company = v; end
143
+ def company=(v) Axlsx.validate_string v; @company = v; end
145
144
  alias :Company= :company=
146
145
  # Sets the pages property of your app.xml file
147
- def pages=(v) Axlsx::validate_int v; @pages = v; end
146
+ def pages=(v) Axlsx.validate_int v; @pages = v; end
148
147
 
149
148
  # Sets the words property of your app.xml file
150
- def words=(v) Axlsx::validate_int v; @words = v; end
149
+ def words=(v) Axlsx.validate_int v; @words = v; end
151
150
  alias :Words= :words=
152
151
 
153
152
  # Sets the characters property of your app.xml file
154
- def characters=(v) Axlsx::validate_int v; @characters = v; end
153
+ def characters=(v) Axlsx.validate_int v; @characters = v; end
155
154
  alias :Characters= :characters=
156
155
 
157
156
  # Sets the presentation_format property of your app.xml file
158
- 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
159
158
  alias :PresentationFormat= :presentation_format=
160
159
 
161
160
  # Sets the lines property of your app.xml file
162
- def lines=(v) Axlsx::validate_int v; @lines = v; end
161
+ def lines=(v) Axlsx.validate_int v; @lines = v; end
163
162
  alias :Lines= :lines=
164
163
 
165
164
  # Sets the paragraphs property of your app.xml file
166
- def paragraphs=(v) Axlsx::validate_int v; @paragraphs = v; end
165
+ def paragraphs=(v) Axlsx.validate_int v; @paragraphs = v; end
167
166
  alias :Paragraphs= :paragraphs=
168
167
 
169
168
  # sets the slides property of your app.xml file
170
- def slides=(v) Axlsx::validate_int v; @slides = v; end
169
+ def slides=(v) Axlsx.validate_int v; @slides = v; end
171
170
  alias :Slides= :slides=
172
171
 
173
172
  # sets the notes property of your app.xml file
174
- def notes=(v) Axlsx::validate_int v; @notes = v; end
173
+ def notes=(v) Axlsx.validate_int v; @notes = v; end
175
174
  alias :Notes= :notes=
176
175
 
177
176
  # Sets the total_time property of your app.xml file
178
- 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
179
178
  alias :TotalTime= :total_time=
180
179
 
181
180
  # Sets the hidden_slides property of your app.xml file
182
- 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
183
182
  alias :HiddenSlides= :hidden_slides=
184
183
 
185
184
  # Sets the m_m_clips property of your app.xml file
186
- 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
187
186
  alias :MMClips= :m_m_clips=
188
187
 
189
188
  # Sets the scale_crop property of your app.xml file
190
- 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
191
190
  alias :ScaleCrop= :scale_crop=
192
191
 
193
192
  # Sets the links_up_to_date property of your app.xml file
194
- 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
195
194
  alias :LinksUpToDate= :links_up_to_date=
196
195
 
197
196
  # Sets the characters_with_spaces property of your app.xml file
198
- 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
199
198
  alias :CharactersWithSpaces= :characters_with_spaces=
200
199
 
201
200
  # Sets the share_doc property of your app.xml file
202
- 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
203
202
  alias :SharedDoc= :shared_doc=
204
203
 
205
204
  # Sets the hyperlink_base property of your app.xml file
206
- 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
207
206
  alias :HyperlinkBase= :hyperlink_base=
208
207
 
209
208
  # Sets the HyperLinksChanged property of your app.xml file
210
- 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
211
210
  alias :HyperLinksChanged= :hyperlinks_changed=
212
211
 
213
212
  # Sets the app_version property of your app.xml file
214
- 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
215
214
  alias :AppVersion= :app_version=
216
215
 
217
216
  # Sets the doc_security property of your app.xml file
218
- 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
219
218
  alias :DocSecurity= :doc_security=
220
219
 
221
220
  # Serialize the app.xml document
222
221
  # @return [String]
223
- def to_xml_string(str = '')
222
+ def to_xml_string(str = +'')
224
223
  str << '<?xml version="1.0" encoding="UTF-8"?>'
225
- str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">')
224
+ str << '<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">'
226
225
  Axlsx.instance_values_for(self).each do |key, value|
227
226
  node_name = Axlsx.camel(key)
228
227
  str << "<#{node_name}>#{value}</#{node_name}>"
229
228
  end
230
229
  str << '</Properties>'
231
230
  end
232
-
233
231
  end
234
-
235
232
  end
@@ -1,15 +1,14 @@
1
- # encoding: UTF-8
2
- module Axlsx
1
+ # frozen_string_literal: true
3
2
 
3
+ module Axlsx
4
4
  # The core object for the package.
5
5
  # @note Packages manage their own core object.
6
6
  # @see Package#core
7
7
  class Core
8
-
9
8
  # Creates a new Core object.
10
9
  # @option options [String] creator
11
10
  # @option options [Time] created
12
- def initialize(options={})
11
+ def initialize(options = {})
13
12
  @creator = options[:creator] || 'axlsx'
14
13
  @created = options[:created]
15
14
  end
@@ -23,17 +22,15 @@ module Axlsx
23
22
 
24
23
  # serializes the core.xml document
25
24
  # @return [String]
26
- def to_xml_string(str = '')
25
+ def to_xml_string(str = +'')
27
26
  str << '<?xml version="1.0" encoding="UTF-8"?>'
28
- str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ')
29
- str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ')
30
- str << ('xmlns:xsi="' << CORE_NS_XSI << '">')
31
- str << ('<dc:creator>' << self.creator << '</dc:creator>')
32
- 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>'
33
32
  str << '<cp:revision>0</cp:revision>'
34
33
  str << '</cp:coreProperties>'
35
34
  end
36
-
37
35
  end
38
-
39
36
  end
@@ -1,6 +1,6 @@
1
- # encoding: UTF-8
2
- module Axlsx
1
+ # frozen_string_literal: true
3
2
 
3
+ module Axlsx
4
4
  # The AreaChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
5
5
  # @example Creating a chart
6
6
  # # This example creates a line in a single sheet.
@@ -20,7 +20,6 @@ module Axlsx
20
20
  # @see Series
21
21
  # @see Package#serialize
22
22
  class AreaChart < Chart
23
-
24
23
  # the category axis
25
24
  # @return [CatAxis]
26
25
  def cat_axis
@@ -35,7 +34,7 @@ module Axlsx
35
34
  end
36
35
  alias :valAxis :val_axis
37
36
 
38
- # must be one of [:percentStacked, :clustered, :standard, :stacked]
37
+ # must be one of [:percentStacked, :clustered, :standard, :stacked]
39
38
  # @return [Symbol]
40
39
  attr_reader :grouping
41
40
 
@@ -45,7 +44,7 @@ module Axlsx
45
44
  # @option options [Boolean] show_legend
46
45
  # @option options [Symbol] grouping
47
46
  # @see Chart
48
- def initialize(frame, options={})
47
+ def initialize(frame, options = {})
49
48
  @vary_colors = false
50
49
  @grouping = :standard
51
50
  super(frame, options)
@@ -64,9 +63,9 @@ module Axlsx
64
63
  # chart based on the actual class type and not a fixed node name.
65
64
  # @return [String]
66
65
  def node_name
67
- path = self.class.to_s
66
+ path = self.class.name
68
67
  if i = path.rindex('::')
69
- path = path[(i+2)..-1]
68
+ path = path[(i + 2)..-1]
70
69
  end
71
70
  path[0] = path[0].chr.downcase
72
71
  path
@@ -75,16 +74,16 @@ module Axlsx
75
74
  # Serializes the object
76
75
  # @param [String] str
77
76
  # @return [String]
78
- def to_xml_string(str = '')
77
+ def to_xml_string(str = +'')
79
78
  super(str) do
80
- str << ("<c:" << node_name << ">")
81
- str << ('<c:grouping val="' << grouping.to_s << '"/>')
82
- 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 << '"/>'
83
82
  @series.each { |ser| ser.to_xml_string(str) }
84
83
  @d_lbls.to_xml_string(str) if @d_lbls
85
84
  yield if block_given?
86
- axes.to_xml_string(str, :ids => true)
87
- str << ("</c:" << node_name << ">")
85
+ axes.to_xml_string(str, ids: true)
86
+ str << "</c:" << node_name << ">"
88
87
  axes.to_xml_string(str)
89
88
  end
90
89
  end
@@ -93,7 +92,7 @@ module Axlsx
93
92
  # axis.
94
93
  # @return [Axes]
95
94
  def axes
96
- @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)
95
+ @axes ||= Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
97
96
  end
98
97
  end
99
98
  end
@@ -1,11 +1,11 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  module Axlsx
3
4
  # A AreaSeries defines the title, data and labels for line charts
4
5
  # @note The recommended way to manage series is to use Chart#add_series
5
6
  # @see Worksheet#add_chart
6
7
  # @see Chart#add_series
7
8
  class AreaSeries < Series
8
-
9
9
  # The data for this series.
10
10
  # @return [ValAxisData]
11
11
  attr_reader :data
@@ -35,13 +35,13 @@ module Axlsx
35
35
  # @option options [Array, SimpleTypedList] data
36
36
  # @option options [Array, SimpleTypedList] labels
37
37
  # @param [Chart] chart
38
- def initialize(chart, options={})
38
+ def initialize(chart, options = {})
39
39
  @show_marker = false
40
- @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
40
+ @marker_symbol = options[:marker_symbol] || :default
41
41
  @smooth = false
42
42
  @labels, @data = nil, nil
43
43
  super(chart, options)
44
- @labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
44
+ @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
45
45
  @data = NumDataSource.new(options) unless options[:data].nil?
46
46
  end
47
47
 
@@ -52,34 +52,34 @@ module Axlsx
52
52
 
53
53
  # @see show_marker
54
54
  def show_marker=(v)
55
- Axlsx::validate_boolean(v)
55
+ Axlsx.validate_boolean(v)
56
56
  @show_marker = v
57
57
  end
58
58
 
59
59
  # @see marker_symbol
60
60
  def marker_symbol=(v)
61
- Axlsx::validate_marker_symbol(v)
61
+ Axlsx.validate_marker_symbol(v)
62
62
  @marker_symbol = v
63
63
  end
64
64
 
65
65
  # @see smooth
66
66
  def smooth=(v)
67
- Axlsx::validate_boolean(v)
67
+ Axlsx.validate_boolean(v)
68
68
  @smooth = v
69
69
  end
70
70
 
71
71
  # Serializes the object
72
72
  # @param [String] str
73
73
  # @return [String]
74
- def to_xml_string(str = '')
74
+ def to_xml_string(str = +'')
75
75
  super(str) do
76
76
  if color
77
77
  str << '<c:spPr><a:solidFill>'
78
- str << ('<a:srgbClr val="' << color << '"/>')
78
+ str << '<a:srgbClr val="' << color << '"/>'
79
79
  str << '</a:solidFill>'
80
80
  str << '<a:ln w="28800">'
81
81
  str << '<a:solidFill>'
82
- str << ('<a:srgbClr val="' << color << '"/>')
82
+ str << '<a:srgbClr val="' << color << '"/>'
83
83
  str << '</a:solidFill>'
84
84
  str << '</a:ln>'
85
85
  str << '<a:round/>'
@@ -89,12 +89,12 @@ module Axlsx
89
89
  if !@show_marker
90
90
  str << '<c:marker><c:symbol val="none"/></c:marker>'
91
91
  elsif @marker_symbol != :default
92
- 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>'
93
93
  end
94
94
 
95
95
  @labels.to_xml_string(str) unless @labels.nil?
96
96
  @data.to_xml_string(str) unless @data.nil?
97
- str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
97
+ str << '<c:smooth val="' << (smooth ? '1' : '0') << '"/>'
98
98
  end
99
99
  end
100
100
 
@@ -105,6 +105,5 @@ module Axlsx
105
105
 
106
106
  # assigns the labels for this series
107
107
  def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
108
-
109
108
  end
110
109
  end