caxlsx 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -12
  3. data/README.md +1 -1
  4. data/lib/axlsx/content_type/abstract_content_type.rb +2 -2
  5. data/lib/axlsx/content_type/content_type.rb +3 -3
  6. data/lib/axlsx/drawing/area_chart.rb +3 -3
  7. data/lib/axlsx/drawing/area_series.rb +2 -2
  8. data/lib/axlsx/drawing/ax_data_source.rb +1 -1
  9. data/lib/axlsx/drawing/axes.rb +1 -1
  10. data/lib/axlsx/drawing/axis.rb +1 -1
  11. data/lib/axlsx/drawing/bar_3D_chart.rb +3 -3
  12. data/lib/axlsx/drawing/bar_chart.rb +3 -3
  13. data/lib/axlsx/drawing/bar_series.rb +2 -2
  14. data/lib/axlsx/drawing/bubble_chart.rb +2 -2
  15. data/lib/axlsx/drawing/bubble_series.rb +2 -2
  16. data/lib/axlsx/drawing/cat_axis.rb +3 -3
  17. data/lib/axlsx/drawing/d_lbls.rb +4 -4
  18. data/lib/axlsx/drawing/drawing.rb +50 -50
  19. data/lib/axlsx/drawing/hyperlink.rb +1 -1
  20. data/lib/axlsx/drawing/line_3D_chart.rb +3 -3
  21. data/lib/axlsx/drawing/line_chart.rb +3 -3
  22. data/lib/axlsx/drawing/line_series.rb +2 -2
  23. data/lib/axlsx/drawing/num_val.rb +1 -1
  24. data/lib/axlsx/drawing/pic.rb +4 -4
  25. data/lib/axlsx/drawing/pie_3D_chart.rb +2 -2
  26. data/lib/axlsx/drawing/pie_chart.rb +2 -2
  27. data/lib/axlsx/drawing/pie_series.rb +2 -2
  28. data/lib/axlsx/drawing/scatter_chart.rb +2 -2
  29. data/lib/axlsx/drawing/scatter_series.rb +2 -2
  30. data/lib/axlsx/drawing/ser_axis.rb +3 -3
  31. data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
  32. data/lib/axlsx/drawing/val_axis.rb +2 -2
  33. data/lib/axlsx/package.rb +7 -10
  34. data/lib/axlsx/rels/relationship.rb +2 -2
  35. data/lib/axlsx/rels/relationships.rb +2 -2
  36. data/lib/axlsx/stylesheet/border_pr.rb +1 -1
  37. data/lib/axlsx/stylesheet/cell_alignment.rb +1 -1
  38. data/lib/axlsx/stylesheet/cell_style.rb +1 -1
  39. data/lib/axlsx/stylesheet/color.rb +2 -2
  40. data/lib/axlsx/stylesheet/font.rb +1 -1
  41. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  42. data/lib/axlsx/stylesheet/styles.rb +27 -31
  43. data/lib/axlsx/stylesheet/xf.rb +1 -1
  44. data/lib/axlsx/util/accessors.rb +1 -1
  45. data/lib/axlsx/util/constants.rb +2 -2
  46. data/lib/axlsx/util/serialized_attributes.rb +2 -2
  47. data/lib/axlsx/util/simple_typed_list.rb +25 -12
  48. data/lib/axlsx/util/storage.rb +3 -3
  49. data/lib/axlsx/util/validators.rb +1 -1
  50. data/lib/axlsx/version.rb +1 -1
  51. data/lib/axlsx/workbook/defined_name.rb +1 -1
  52. data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
  53. data/lib/axlsx/workbook/workbook.rb +61 -61
  54. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
  55. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +1 -1
  56. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +3 -3
  57. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +1 -1
  58. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +2 -2
  59. data/lib/axlsx/workbook/worksheet/border_creator.rb +4 -4
  60. data/lib/axlsx/workbook/worksheet/cell.rb +7 -7
  61. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
  62. data/lib/axlsx/workbook/worksheet/col.rb +22 -9
  63. data/lib/axlsx/workbook/worksheet/comment.rb +2 -2
  64. data/lib/axlsx/workbook/worksheet/comments.rb +1 -1
  65. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
  66. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
  67. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -2
  68. data/lib/axlsx/workbook/worksheet/data_validation.rb +1 -1
  69. data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -2
  70. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +2 -2
  71. data/lib/axlsx/workbook/worksheet/dimension.rb +1 -1
  72. data/lib/axlsx/workbook/worksheet/icon_set.rb +1 -1
  73. data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
  74. data/lib/axlsx/workbook/worksheet/page_setup.rb +2 -2
  75. data/lib/axlsx/workbook/worksheet/pivot_table.rb +29 -5
  76. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +1 -1
  77. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
  78. data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -1
  79. data/lib/axlsx/workbook/worksheet/worksheet.rb +10 -12
  80. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +3 -3
  81. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +1 -1
  82. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +1 -1
  83. data/lib/axlsx.rb +44 -30
  84. data/lib/caxlsx.rb +1 -1
  85. metadata +6 -6
@@ -18,7 +18,7 @@ module Axlsx
18
18
  :sync_ref
19
19
 
20
20
  # These attributes are all boolean so I'm doing a bit of a hand
21
- # waving magic show to set up the attriubte accessors
21
+ # waving magic show to set up the attribute accessors
22
22
  boolean_attr_accessor :sync_horizontal,
23
23
  :sync_vertical,
24
24
  :transition_evaluation,
@@ -41,7 +41,7 @@ module Axlsx
41
41
  # The name of the table style.
42
42
  attr_accessor :name
43
43
 
44
- # seralizes this object to an xml string
44
+ # serializes this object to an xml string
45
45
  # @param [String] str the string to contact this objects serialization to.
46
46
  def to_xml_string(str = +'')
47
47
  serialized_tag('tableStyleInfo', str)
@@ -31,7 +31,7 @@ module Axlsx
31
31
 
32
32
  serializable_attributes :sheet_id, :state
33
33
 
34
- # Initalizes page margin, setup and print options
34
+ # Initializes page margin, setup and print options
35
35
  # @param [Hash] options Options passed in from the initializer
36
36
  def initialize_page_options(options)
37
37
  @page_margins = PageMargins.new options[:page_margins] if options[:page_margins]
@@ -181,7 +181,7 @@ module Axlsx
181
181
  @auto_filter ||= AutoFilter.new self
182
182
  end
183
183
 
184
- # Indicates if the worksheet will be fit by witdh or height to a specific number of pages.
184
+ # Indicates if the worksheet will be fit by width or height to a specific number of pages.
185
185
  # To alter the width or height for page fitting, please use page_setup.fit_to_widht or page_setup.fit_to_height.
186
186
  # If you want the worksheet to fit on more pages (e.g. 2x2), set {PageSetup#fit_to_width} and {PageSetup#fit_to_height} accordingly.
187
187
  # @return Boolean
@@ -421,7 +421,7 @@ module Axlsx
421
421
  # @option options [Array] values
422
422
  # @option options [Array, Symbol] types
423
423
  # @option options [Array, Integer] style
424
- # @option options [Array] widths each member of the widths array will affect how auto_fit behavies.
424
+ # @option options [Array] widths each member of the widths array will affect how auto_fit behaves.
425
425
  # @option options [Float] height the row's height (in points)
426
426
  # @option options [Integer] offset - add empty columns before values
427
427
  # @option options [Array, Boolean] escape_formulas - Whether to treat a value starting with an equal
@@ -666,12 +666,11 @@ module Axlsx
666
666
  # @return [Relationships]
667
667
  def relationships
668
668
  r = Relationships.new
669
- r + [tables.relationships,
670
- worksheet_comments.relationships,
671
- hyperlinks.relationships,
672
- worksheet_drawing.relationship,
673
- pivot_tables.relationships].flatten.compact || []
674
- r
669
+ r.concat [tables.relationships,
670
+ worksheet_comments.relationships,
671
+ hyperlinks.relationships,
672
+ worksheet_drawing.relationship,
673
+ pivot_tables.relationships].flatten.compact
675
674
  end
676
675
 
677
676
  # Returns the cell or cells defined using Excel style A1:B3 references.
@@ -728,7 +727,7 @@ module Axlsx
728
727
  end
729
728
 
730
729
  # shortcut level to specify the outline level for a series of rows
731
- # Oulining is what lets you add collapse and expand to a data set.
730
+ # Outlining is what lets you add collapse and expand to a data set.
732
731
  # @param [Integer] start_index The zero based index of the first row of outlining.
733
732
  # @param [Integer] end_index The zero based index of the last row to be outlined
734
733
  # @param [integer] level The level of outline to apply
@@ -738,7 +737,7 @@ module Axlsx
738
737
  end
739
738
 
740
739
  # shortcut level to specify the outline level for a series of columns
741
- # Oulining is what lets you add collapse and expand to a data set.
740
+ # Outlining is what lets you add collapse and expand to a data set.
742
741
  # @param [Integer] start_index The zero based index of the first column of outlining.
743
742
  # @param [Integer] end_index The zero based index of the last column to be outlined
744
743
  # @param [integer] level The level of outline to apply
@@ -855,7 +854,6 @@ module Axlsx
855
854
  cells.each_with_index do |cell, index|
856
855
  width = widths ? widths[index] : nil
857
856
  col = find_or_create_column_info(index)
858
- next if width == :ignore
859
857
 
860
858
  col.update_width(cell, width, workbook.use_autowidth)
861
859
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # A wraper class for comments that defines its on worksheet
5
- # serailization
4
+ # A wrapper class for comments that defines its on worksheet
5
+ # serialization
6
6
  class WorksheetComments
7
7
  # Creates a new WorksheetComments object
8
- # param [Worksheet] worksheet The worksheet comments in thes object belong to
8
+ # param [Worksheet] worksheet The worksheet to which the comments belong
9
9
  def initialize(worksheet)
10
10
  raise ArugumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet)
11
11
 
@@ -55,7 +55,7 @@ module Axlsx
55
55
  Relationship.new(self, HYPERLINK_R, location, target_mode: :External)
56
56
  end
57
57
 
58
- # Seralize the object
58
+ # Serialize the object
59
59
  # @param [String] str
60
60
  # @return [String]
61
61
  def to_xml_string(str = +'')
@@ -27,7 +27,7 @@ module Axlsx
27
27
  map(&:relationship)
28
28
  end
29
29
 
30
- # seralize the collection of hyperlinks
30
+ # serialize the collection of hyperlinks
31
31
  # @return [String]
32
32
  def to_xml_string(str = +'')
33
33
  return if empty?
data/lib/axlsx.rb CHANGED
@@ -1,38 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'axlsx/version'
4
+
5
+ # gemspec dependencies
3
6
  require 'htmlentities'
4
- require 'axlsx/version'
5
7
  require 'marcel'
6
-
7
- require 'axlsx/util/simple_typed_list'
8
- require 'axlsx/util/constants'
9
- require 'axlsx/util/validators'
10
- require 'axlsx/util/accessors'
11
- require 'axlsx/util/serialized_attributes'
12
- require 'axlsx/util/options_parser'
13
- require 'axlsx/util/mime_type_utils'
14
- require 'axlsx/util/buffered_zip_output_stream'
15
- require 'axlsx/util/zip_command'
16
-
17
- require 'axlsx/stylesheet/styles'
18
-
19
- require 'axlsx/doc_props/app'
20
- require 'axlsx/doc_props/core'
21
- require 'axlsx/content_type/content_type'
22
- require 'axlsx/rels/relationships'
23
-
24
- require 'axlsx/drawing/drawing'
25
- require 'axlsx/workbook/workbook'
26
- require 'axlsx/package'
27
- # required gems
28
8
  require 'nokogiri'
29
9
  require 'zip'
30
10
 
31
- # core dependencies
32
- require 'bigdecimal'
11
+ # Ruby core dependencies
33
12
  require 'cgi'
34
13
  require 'set'
35
14
  require 'time'
15
+ require 'uri'
16
+
17
+ require_relative 'axlsx/util/simple_typed_list'
18
+ require_relative 'axlsx/util/constants'
19
+ require_relative 'axlsx/util/validators'
20
+ require_relative 'axlsx/util/accessors'
21
+ require_relative 'axlsx/util/serialized_attributes'
22
+ require_relative 'axlsx/util/options_parser'
23
+ require_relative 'axlsx/util/mime_type_utils'
24
+ require_relative 'axlsx/util/buffered_zip_output_stream'
25
+ require_relative 'axlsx/util/zip_command'
26
+
27
+ require_relative 'axlsx/stylesheet/styles'
28
+
29
+ require_relative 'axlsx/doc_props/app'
30
+ require_relative 'axlsx/doc_props/core'
31
+ require_relative 'axlsx/content_type/content_type'
32
+ require_relative 'axlsx/rels/relationships'
33
+
34
+ require_relative 'axlsx/drawing/drawing'
35
+ require_relative 'axlsx/workbook/workbook'
36
+ require_relative 'axlsx/package'
36
37
 
37
38
  if Gem.loaded_specs.key?("axlsx_styler")
38
39
  raise StandardError, "Please remove `axlsx_styler` from your Gemfile, the associated functionality is now built-in to `caxlsx` directly."
@@ -88,12 +89,10 @@ module Axlsx
88
89
  letters_str = name[/[A-Z]+/]
89
90
 
90
91
  # capitalization?!?
91
- v = letters_str.reverse.chars.reduce({ base: 1, i: 0 }) do |val, c|
92
+ v = letters_str.reverse.chars.each_with_object({ base: 1, i: 0 }) do |c, val|
92
93
  val[:i] += ((c.bytes.first - 64) * val[:base])
93
94
 
94
95
  val[:base] *= 26
95
-
96
- next val
97
96
  end
98
97
 
99
98
  col_index = (v[:i] - 1)
@@ -154,7 +153,7 @@ module Axlsx
154
153
  end
155
154
  end
156
155
 
157
- # performs the increadible feat of changing snake_case to CamelCase
156
+ # performs the incredible feat of changing snake_case to CamelCase
158
157
  # @param [String] s The snake case string to camelize
159
158
  # @return [String]
160
159
  def self.camel(s = "", all_caps = true)
@@ -163,7 +162,7 @@ module Axlsx
163
162
  s.gsub(/_(.)/) { ::Regexp.last_match(1).upcase }
164
163
  end
165
164
 
166
- # returns the provided string with all invalid control charaters
165
+ # returns the provided string with all invalid control characters
167
166
  # removed.
168
167
  # @param [String] str The string to process
169
168
  # @return [String]
@@ -229,4 +228,19 @@ module Axlsx
229
228
  Axlsx.validate_boolean(value)
230
229
  @escape_formulas = value
231
230
  end
231
+
232
+ # Returns a URI parser instance, preferring RFC2396_PARSER if available,
233
+ # otherwise falling back to DEFAULT_PARSER. This method ensures consistent
234
+ # URI parsing across different Ruby versions.
235
+ # This method can be removed when dropping compatibility for Ruby < 3.4
236
+ # See https://github.com/ruby/uri/pull/114 for details.
237
+ # @return [Object]
238
+ def self.uri_parser
239
+ @uri_parser ||=
240
+ if defined?(URI::RFC2396_PARSER)
241
+ URI::RFC2396_PARSER
242
+ else
243
+ URI::DEFAULT_PARSER
244
+ end
245
+ end
232
246
  end
data/lib/caxlsx.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'axlsx'
3
+ require_relative 'axlsx'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Morgan
8
8
  - Jurriaan Pruis
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-28 00:00:00.000000000 Z
12
+ date: 2024-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: htmlentities
@@ -297,7 +297,7 @@ metadata:
297
297
  changelog_uri: https://github.com/caxlsx/caxlsx/blob/master/CHANGELOG.md
298
298
  source_code_uri: https://github.com/caxlsx/caxlsx
299
299
  rubygems_mfa_required: 'true'
300
- post_install_message:
300
+ post_install_message:
301
301
  rdoc_options: []
302
302
  require_paths:
303
303
  - lib
@@ -312,8 +312,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  - !ruby/object:Gem::Version
313
313
  version: '0'
314
314
  requirements: []
315
- rubygems_version: 3.2.3
316
- signing_key:
315
+ rubygems_version: 3.4.19
316
+ signing_key:
317
317
  specification_version: 4
318
318
  summary: Excel OOXML (xlsx) with charts, styles, images and autowidth columns.
319
319
  test_files: []