ooxml_parser 0.8.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +55 -48
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/pivot_formats.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/plot_area/common_chart_data.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text/string_reference/number_string_cache.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +6 -10
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +4 -6
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +4 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +0 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +0 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +0 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +0 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +0 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/text_body.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/preset_geometry/shape_adjust_value_list.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/color.rb +6 -6
- data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +29 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +0 -33
- data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/content_types.rb +8 -1
- data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +2 -4
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +3 -3
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/relationships.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +1 -5
- data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/grid_span.rb +1 -7
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/underline.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +1 -1
- data/lib/ooxml_parser/common_parser/common_document_structure.rb +1 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +2 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments.rb +2 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb +2 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_settings.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +4 -4
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/math_run/math_run_properties.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +38 -21
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +2 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/style_parametres.rb +5 -8
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +2 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering/abstract_numbering/numbering_level/suffix.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +1 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +1 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +1 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +2 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -2
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/comment_authors.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comments.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +1 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +2 -2
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition_list.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +1 -3
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition/sound_action/sound.rb +1 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/table_styles.rb +1 -1
- data/lib/ooxml_parser/version.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +17 -3
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +6 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields.rb +43 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb +37 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field/shared_items.rb +42 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition.rb +114 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/column_row_items.rb +43 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/column_row_items/column_row_item.rb +22 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/location.rb +34 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields.rb +43 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field.rb +37 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb +43 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items/item.rb +26 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_table_style_info.rb +42 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/shared_string_table.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/cell_style/alignment.rb +5 -5
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/number_formats.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/xlsx_borders.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/comment_list.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column/custom_filters.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_columns.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +1 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +1 -1
- metadata +110 -35
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +0 -28
@@ -14,7 +14,7 @@ module OoxmlParser
|
|
14
14
|
def initialize(parent: nil)
|
15
15
|
@abstract_numbering_list = []
|
16
16
|
@numbering_definition_list = []
|
17
|
-
|
17
|
+
super
|
18
18
|
end
|
19
19
|
|
20
20
|
# Get properties by number id
|
@@ -38,7 +38,7 @@ module OoxmlParser
|
|
38
38
|
# Parse Numbering data
|
39
39
|
# @return [Numbering] result of parse
|
40
40
|
def parse
|
41
|
-
numbering_xml = OOXMLDocumentObject.path_to_folder
|
41
|
+
numbering_xml = "#{OOXMLDocumentObject.path_to_folder}word/numbering.xml"
|
42
42
|
return nil unless File.exist?(numbering_xml)
|
43
43
|
|
44
44
|
node = parse_xml(File.open(numbering_xml))
|
@@ -9,11 +9,12 @@ module OoxmlParser
|
|
9
9
|
@height = height
|
10
10
|
@width = width
|
11
11
|
@orientation = orientation
|
12
|
+
super(parent: nil)
|
12
13
|
end
|
13
14
|
|
14
15
|
# @return [String] convert to string
|
15
16
|
def to_s
|
16
|
-
|
17
|
+
"Height: #{@height} Width: #{@width} Orientation: #{@orientation}"
|
17
18
|
end
|
18
19
|
|
19
20
|
# @return [True, False] compare dimensions of size, ignoring orientation
|
@@ -11,13 +11,13 @@ module OoxmlParser
|
|
11
11
|
|
12
12
|
def initialize(parent: nil)
|
13
13
|
@styles = []
|
14
|
-
|
14
|
+
super
|
15
15
|
end
|
16
16
|
|
17
17
|
# Parse styles data
|
18
18
|
# @return [Styles] result of parsing
|
19
19
|
def parse
|
20
|
-
doc = parse_xml(OOXMLDocumentObject.path_to_folder
|
20
|
+
doc = parse_xml("#{OOXMLDocumentObject.path_to_folder}word/styles.xml")
|
21
21
|
doc.xpath('w:styles/*').each do |node_child|
|
22
22
|
case node_child.name
|
23
23
|
when 'docDefaults'
|
data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
CHANGED
@@ -9,7 +9,7 @@ module OoxmlParser
|
|
9
9
|
|
10
10
|
def initialize(graphic_data = [], parent: nil)
|
11
11
|
@graphic_data = graphic_data
|
12
|
-
|
12
|
+
super(parent: parent)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Parse GraphicFrame object
|
@@ -31,7 +31,7 @@ module OoxmlParser
|
|
31
31
|
graphic_data << Table.new(parent: self).parse(graphic_node_child)
|
32
32
|
when 'chart'
|
33
33
|
OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
|
34
|
-
graphic_data << Chart.
|
34
|
+
graphic_data << Chart.new(parent: self).parse
|
35
35
|
OOXMLDocumentObject.xmls_stack.pop
|
36
36
|
when 'oleObj'
|
37
37
|
graphic_data << OleObject.new(parent: self).parse(graphic_node_child)
|
@@ -20,9 +20,7 @@ module OoxmlParser
|
|
20
20
|
case object
|
21
21
|
when :image
|
22
22
|
elements.find { |e| e.is_a? DocxPicture }.properties.transform
|
23
|
-
when :chart
|
24
|
-
elements.find { |e| e.is_a? GraphicFrame }.transform
|
25
|
-
when :table
|
23
|
+
when :chart, :table
|
26
24
|
elements.find { |e| e.is_a? GraphicFrame }.transform
|
27
25
|
when :shape
|
28
26
|
elements.find { |e| !e.shape_properties.preset.nil? }.shape_properties.transform
|
data/lib/ooxml_parser/version.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'workbook/chartsheet'
|
4
4
|
require_relative 'workbook/pivot_cache'
|
5
|
+
require_relative 'workbook/pivot_table_definition'
|
5
6
|
require_relative 'workbook/shared_string_table'
|
6
7
|
require_relative 'workbook/style_sheet'
|
7
8
|
require_relative 'workbook/worksheet'
|
@@ -21,10 +22,13 @@ module OoxmlParser
|
|
21
22
|
attr_accessor :shared_strings_table
|
22
23
|
# @return [Array<PivotCache>] list of pivot caches
|
23
24
|
attr_accessor :pivot_caches
|
25
|
+
# @return [Array<PivotTableDefintion>] list of pivot table defitions
|
26
|
+
attr_accessor :pivot_table_definitions
|
24
27
|
|
25
28
|
def initialize(params = {})
|
26
29
|
@worksheets = []
|
27
30
|
@pivot_caches = []
|
31
|
+
@pivot_table_definitions = []
|
28
32
|
super
|
29
33
|
end
|
30
34
|
|
@@ -43,9 +47,10 @@ module OoxmlParser
|
|
43
47
|
return row.cells[column.to_i - 1]
|
44
48
|
elsif sheet.is_a?(String)
|
45
49
|
@worksheets.each do |worksheet|
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
next unless worksheet.name == sheet
|
51
|
+
next unless worksheet.rows[row.to_i - 1]
|
52
|
+
|
53
|
+
return worksheet.rows[row.to_i - 1].cells[column.to_i - 1]
|
49
54
|
end
|
50
55
|
return nil
|
51
56
|
end
|
@@ -119,6 +124,7 @@ module OoxmlParser
|
|
119
124
|
end
|
120
125
|
end
|
121
126
|
parse_pivot_cache
|
127
|
+
parse_pivot_table
|
122
128
|
OOXMLDocumentObject.xmls_stack.pop
|
123
129
|
self
|
124
130
|
end
|
@@ -135,5 +141,13 @@ module OoxmlParser
|
|
135
141
|
@pivot_caches << PivotCache.new(parent: self).parse(pivot_cache)
|
136
142
|
end
|
137
143
|
end
|
144
|
+
|
145
|
+
# Perform parsing of pivot table
|
146
|
+
def parse_pivot_table
|
147
|
+
files = @content_types.by_type('application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml')
|
148
|
+
files.each do |file|
|
149
|
+
@pivot_table_definitions << PivotTableDefinition.new(parent: self).parse(file.part_name)
|
150
|
+
end
|
151
|
+
end
|
138
152
|
end
|
139
153
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'pivot_cache_definition/cache_source'
|
4
|
+
require_relative 'pivot_cache_definition/cache_fields'
|
5
|
+
|
4
6
|
module OoxmlParser
|
5
7
|
# Class for parsing <pivotCacheDefinition> file
|
6
8
|
class PivotCacheDefinition < OOXMLDocumentObject
|
@@ -8,6 +10,8 @@ module OoxmlParser
|
|
8
10
|
attr_reader :id
|
9
11
|
# @return [CacheSource] source of pivot cache
|
10
12
|
attr_reader :cache_source
|
13
|
+
# @return [CacheFields] fields of pivot cache
|
14
|
+
attr_reader :cache_fields
|
11
15
|
|
12
16
|
# Parse PivotCacheDefinition file
|
13
17
|
# @param file [String] path to file
|
@@ -29,6 +33,8 @@ module OoxmlParser
|
|
29
33
|
case node_child.name
|
30
34
|
when 'cacheSource'
|
31
35
|
@cache_source = CacheSource.new(parent: self).parse(node_child)
|
36
|
+
when 'cacheFields'
|
37
|
+
@cache_fields = CacheFields.new(parent: self).parse(node_child)
|
32
38
|
end
|
33
39
|
end
|
34
40
|
self
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'cache_fields/cache_field'
|
4
|
+
|
5
|
+
module OoxmlParser
|
6
|
+
# Class for parsing <cacheFields> tag
|
7
|
+
class CacheFields < OOXMLDocumentObject
|
8
|
+
# @return [Integer] count
|
9
|
+
attr_reader :count
|
10
|
+
# @return [Array<CacheField>] list of CacheField object
|
11
|
+
attr_reader :cache_field
|
12
|
+
|
13
|
+
def initialize(parent: nil)
|
14
|
+
@cache_field = []
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [CacheField] accessor
|
19
|
+
def [](key)
|
20
|
+
@cache_field[key]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Parse `<cacheFields>` tag
|
24
|
+
# @param [Nokogiri::XML:Element] node with cacheFields data
|
25
|
+
# @return [cacheFields]
|
26
|
+
def parse(node)
|
27
|
+
node.attributes.each do |key, value|
|
28
|
+
case key
|
29
|
+
when 'count'
|
30
|
+
@count = value.value.to_i
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
node.xpath('*').each do |node_child|
|
35
|
+
case node_child.name
|
36
|
+
when 'cacheField'
|
37
|
+
@cache_field << CacheField.new(parent: self).parse(node_child)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
self
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|