ooxml_parser 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed12c90b346ab55a8a41932a3fb957bfbddccf71fdedf15ec6f7b140b1be88eb
4
- data.tar.gz: 24bff23c9c3f29cfac0e6db68def27199d984366c07b951fe5adb0f88e54468d
3
+ metadata.gz: 6d49ee5c48167b1fec3d73c1f146b1f5039ad13591d91cd01076c2026a4da9d5
4
+ data.tar.gz: c903db5d14db5c9603c1a42b8c3a96666ea421ceb6264c3de142a23e6b4f4871
5
5
  SHA512:
6
- metadata.gz: '09bad9d23a5157e19fecf0989ac7c812a0b300920c5978f9f6c8ea9241e311dd4e3f3c68f965b52955eba1791c46b46ef22f47728148583e7a0a703d7aaadff0'
7
- data.tar.gz: c31c20c9a9ca7e4ade83b93653d8d04eed3117a822d9a81d4b9f10f1d7323bb164c281e0f4b75a5c061acb430ee8d08e424a9a8c723c3346dbc74fddd0ed4685
6
+ metadata.gz: 7e1a32945ce66a7b668a734526a5cdb3f936a4ef78f0e88dfb3955e10505a21e7fae326cc3f515977bbee0b04e7cdd0d584963243b2c756de41f25c9be93514f
7
+ data.tar.gz: 1f01fbad38dd7c8ad7271d01fdc93ebb693f71ec0af1483bec680f3afbee8a6f32ded803cd01e889aba7c767de6bab3b6ce732a07ed5d771dff9faf95c023ffd
@@ -4,6 +4,6 @@ module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
6
  # [String] Version of Gem
7
- STRING = '0.20.0'
7
+ STRING = '0.21.0'
8
8
  end
9
9
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing <sheet> tag
5
+ class Sheet < OOXMLDocumentObject
6
+ # @return [String] Name of sheet
7
+ attr_reader :name
8
+ # @return [Integer] SheetId of sheet
9
+ attr_reader :sheet_id
10
+ # @return [Symbol] Specifies if sheet is hidden
11
+ attr_reader :state
12
+ # @return [String] Id of sheet
13
+ attr_reader :id
14
+
15
+ def initialize(parent: nil)
16
+ @state = :visible
17
+ super
18
+ end
19
+
20
+ # Parse Sheet data
21
+ # @param [Nokogiri::XML:Element] node with Sheet data
22
+ # @return [Sheet] value of Sheet
23
+ def parse(node)
24
+ node.attributes.each do |key, value|
25
+ case key
26
+ when 'name'
27
+ @name = value.value.to_s
28
+ when 'sheetId'
29
+ @sheet_id = value.value.to_i
30
+ when 'state'
31
+ @state = value.value.to_sym
32
+ when 'id'
33
+ @id = value.value.to_s
34
+ end
35
+ end
36
+ self
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for `selection` data
5
+ class Selection < OOXMLDocumentObject
6
+ # @return [Coordinates] Reference to the active cell
7
+ attr_reader :active_cell
8
+ # @return [Integer] Id of active cell
9
+ attr_reader :active_cell_id
10
+ # @return [String] Selected range
11
+ attr_reader :reference_sequence
12
+
13
+ # Parse Selection object
14
+ # @param node [Nokogiri::XML:Element] node to parse
15
+ # @return [Selection] result of parsing
16
+ def parse(node)
17
+ node.attributes.each do |key, value|
18
+ case key
19
+ when 'activeCell'
20
+ @active_cell = Coordinates.parse_coordinates_from_string(value.value)
21
+ when 'activeCellId'
22
+ @active_cell_id = value.value.to_i
23
+ when 'sqref'
24
+ @reference_sequence = value.value.to_s
25
+ end
26
+ end
27
+ self
28
+ end
29
+ end
30
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'sheet_view/pane'
4
+ require_relative 'sheet_view/selection'
4
5
  module OoxmlParser
5
6
  # Class for `sheetView` data
6
7
  class SheetView < OOXMLDocumentObject
@@ -9,6 +10,14 @@ module OoxmlParser
9
10
  attr_accessor :show_gridlines
10
11
  # @return [True, False] Flag indicating whether the sheet should display row and column headings.
11
12
  attr_accessor :show_row_column_headers
13
+ # @return [Coordinates] Reference to the top left cell
14
+ attr_reader :top_left_cell
15
+ # @return [Integer] Id of workbook view
16
+ attr_reader :workbook_view_id
17
+ # @return [Integer] Zoom scale
18
+ attr_reader :zoom_scale
19
+ # @return [Selection] Properties of selection
20
+ attr_reader :selection
12
21
 
13
22
  def initialize(parent: nil)
14
23
  @show_gridlines = true
@@ -20,12 +29,18 @@ module OoxmlParser
20
29
  # @param node [Nokogiri::XML:Element] node to parse
21
30
  # @return [SheetView] result of parsing
22
31
  def parse(node)
23
- node.attributes.each_key do |key|
32
+ node.attributes.each do |key, value|
24
33
  case key
25
34
  when 'showGridLines'
26
- @show_gridlines = attribute_enabled?(node, key)
35
+ @show_gridlines = attribute_enabled?(value)
27
36
  when 'showRowColHeaders'
28
- @show_row_column_headers = attribute_enabled?(node, key)
37
+ @show_row_column_headers = attribute_enabled?(value)
38
+ when 'topLeftCell'
39
+ @top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
40
+ when 'workbookViewId'
41
+ @workbook_view_id = value.value.to_i
42
+ when 'zoomScale'
43
+ @zoom_scale = value.value.to_i
29
44
  end
30
45
  end
31
46
 
@@ -33,6 +48,8 @@ module OoxmlParser
33
48
  case node_child.name
34
49
  when 'pane'
35
50
  @pane = Pane.new(parent: self).parse(node_child)
51
+ when 'selection'
52
+ @selection = Selection.new(parent: self).parse(node_child)
36
53
  end
37
54
  end
38
55
  self
@@ -7,12 +7,15 @@ require_relative 'workbook/defined_name'
7
7
  require_relative 'workbook/shared_string_table'
8
8
  require_relative 'workbook/style_sheet'
9
9
  require_relative 'workbook/worksheet'
10
+ require_relative 'workbook/sheet'
10
11
  require_relative 'workbook/workbook_helpers'
11
12
  module OoxmlParser
12
13
  # Class for storing XLSX Workbook
13
14
  class XLSXWorkbook < CommonDocumentStructure
14
15
  include WorkbookHelpers
15
16
  attr_accessor :worksheets
17
+ # @return [Array<Sheet>] list of sheets
18
+ attr_reader :sheets
16
19
  # @return [PresentationTheme] theme of Workbook
17
20
  attr_accessor :theme
18
21
  # @return [Relationships] rels of book
@@ -30,6 +33,7 @@ module OoxmlParser
30
33
 
31
34
  def initialize(params = {})
32
35
  @worksheets = []
36
+ @sheets = []
33
37
  @pivot_caches = []
34
38
  @pivot_table_definitions = []
35
39
  @defined_names = []
@@ -119,10 +123,11 @@ module OoxmlParser
119
123
  @theme = PresentationTheme.parse("xl/#{link_to_theme_xml}") if link_to_theme_xml
120
124
  @style_sheet = StyleSheet.new(parent: self).parse
121
125
  @doc.xpath('xmlns:workbook/xmlns:sheets/xmlns:sheet').each do |sheet|
126
+ @sheets << Sheet.new(parent: self).parse(sheet)
122
127
  file = @relationships.target_by_id(sheet.attribute('id').value)
123
128
  if file.start_with?('worksheets')
124
129
  @worksheets << Worksheet.new(parent: self).parse(file)
125
- @worksheets.last.name = sheet.attribute('name').value
130
+ @worksheets.last.name = @sheets.last.name
126
131
  elsif file.start_with?('chartsheets')
127
132
  @worksheets << Chartsheet.new(parent: self).parse(file)
128
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ooxml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-11-18 00:00:00.000000000 Z
13
+ date: 2021-12-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -510,6 +510,7 @@ files:
510
510
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_table_style_info.rb
511
511
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb
512
512
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table/string_index.rb
513
+ - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/sheet.rb
513
514
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb
514
515
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb
515
516
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb
@@ -535,6 +536,7 @@ files:
535
536
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb
536
537
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb
537
538
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb
539
+ - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/selection.rb
538
540
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb
539
541
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb
540
542
  - lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb
@@ -595,7 +597,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
595
597
  - !ruby/object:Gem::Version
596
598
  version: '0'
597
599
  requirements: []
598
- rubygems_version: 3.2.29
600
+ rubygems_version: 3.2.32
599
601
  signing_key:
600
602
  specification_version: 4
601
603
  summary: OoxmlParser Gem