ooxml_parser 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/.overcommit.yml +35 -0
  3. data/Changelog.md +25 -0
  4. data/LICENSE.txt +661 -0
  5. data/README.md +26 -0
  6. data/circle.yml +3 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alingment.rb +56 -0
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb +34 -0
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +123 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +34 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +38 -0
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +23 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +33 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_point.rb +11 -0
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2007_chart_style.rb +17 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2010_chart_style.rb +17 -0
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +26 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +49 -0
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +23 -0
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb +35 -0
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +11 -0
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +39 -0
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +32 -0
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +34 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_group_element.rb +10 -0
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_grouped_drawing.rb +34 -0
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +27 -0
  28. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +26 -0
  29. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +25 -0
  30. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties/preset_text_warp.rb +16 -0
  31. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +30 -0
  32. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +37 -0
  33. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb +20 -0
  34. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_gradient_color.rb +30 -0
  35. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_single_gradient_color.rb +6 -0
  36. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/solid_color/docx_solid_color.rb +10 -0
  37. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_element.rb +10 -0
  38. 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 +44 -0
  39. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +23 -0
  40. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb +43 -0
  41. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +54 -0
  42. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +25 -0
  43. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +40 -0
  44. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +31 -0
  45. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end/line_size.rb +20 -0
  46. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end.rb +21 -0
  47. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_style/docx_shape_style.rb +5 -0
  48. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +31 -0
  49. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_element.rb +10 -0
  50. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_properties.rb +6 -0
  51. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +26 -0
  52. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +24 -0
  53. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb +26 -0
  54. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +24 -0
  55. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/common_non_visual_properties.rb +25 -0
  56. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_properties.rb +19 -0
  57. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_shape_properties.rb +20 -0
  58. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape.rb +28 -0
  59. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_placeholder.rb +18 -0
  60. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/ooxml_shift.rb +15 -0
  61. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/transform_effect.rb +28 -0
  62. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties.rb +13 -0
  63. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb +26 -0
  64. data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/text_body.rb +23 -0
  65. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +58 -0
  66. data/lib/ooxml_parser/common_parser/common_data/color.rb +473 -0
  67. data/lib/ooxml_parser/common_parser/common_data/colors/color_alpha_channel.rb +14 -0
  68. data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +21 -0
  69. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +150 -0
  70. data/lib/ooxml_parser/common_parser/common_data/colors/image/fill_rectangle.rb +22 -0
  71. data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching.rb +11 -0
  72. data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +32 -0
  73. data/lib/ooxml_parser/common_parser/common_data/colors/image_properties.rb +16 -0
  74. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb +15 -0
  75. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/linear_gradient.rb +10 -0
  76. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +35 -0
  77. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb +22 -0
  78. data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb +33 -0
  79. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +14 -0
  80. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +22 -0
  81. data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +21 -0
  82. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +127 -0
  83. data/lib/ooxml_parser/common_parser/common_data/font_style.rb +101 -0
  84. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +53 -0
  85. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +87 -0
  86. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +48 -0
  87. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +23 -0
  88. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/strikeout.rb +16 -0
  89. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +79 -0
  90. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +24 -0
  91. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties/numbering_level.rb +25 -0
  92. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb +69 -0
  93. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering.rb +18 -0
  94. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +115 -0
  95. data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +35 -0
  96. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +35 -0
  97. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +47 -0
  98. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_cell_margin.rb +20 -0
  99. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_element.rb +20 -0
  100. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +43 -0
  101. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +49 -0
  102. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +83 -0
  103. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_elements.rb +21 -0
  104. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/line_join.rb +19 -0
  105. data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/table_cell_style.rb +20 -0
  106. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +43 -0
  107. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +142 -0
  108. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/merge.rb +18 -0
  109. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +25 -0
  110. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +125 -0
  111. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +35 -0
  112. data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties.rb +22 -0
  113. data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +33 -0
  114. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +9 -0
  115. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +77 -0
  116. data/lib/ooxml_parser/common_parser/common_data/table.rb +41 -0
  117. data/lib/ooxml_parser/common_parser/common_data/underline.rb +40 -0
  118. data/lib/ooxml_parser/common_parser/common_document_structure.rb +7 -0
  119. data/lib/ooxml_parser/configuration.rb +20 -0
  120. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +28 -0
  121. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +10 -0
  122. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb +21 -0
  123. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +70 -0
  124. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb +11 -0
  125. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +10 -0
  126. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +11 -0
  127. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +12 -0
  128. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/fraction.rb +11 -0
  129. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/function.rb +11 -0
  130. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/group_char.rb +13 -0
  131. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/index.rb +12 -0
  132. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +12 -0
  133. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +10 -0
  134. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +10 -0
  135. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/operator.rb +13 -0
  136. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +11 -0
  137. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +203 -0
  138. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/offset.rb +10 -0
  139. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shadow.rb +10 -0
  140. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_margins.rb +11 -0
  141. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_size.rb +10 -0
  142. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/stroke.rb +10 -0
  143. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties.rb +16 -0
  144. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +40 -0
  145. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_fill.rb +13 -0
  146. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +22 -0
  147. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +388 -0
  148. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +46 -0
  149. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +87 -0
  150. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/bookmark.rb +10 -0
  151. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/paragraph_tab.rb +19 -0
  152. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/style_parametres.rb +35 -0
  153. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style.rb +56 -0
  154. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +324 -0
  155. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +37 -0
  156. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/image.rb +15 -0
  157. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns/column.rb +10 -0
  158. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +37 -0
  159. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb +29 -0
  160. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +49 -0
  161. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +42 -0
  162. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +88 -0
  163. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/size.rb +84 -0
  164. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +232 -0
  165. data/lib/ooxml_parser/docx_parser/docx_parser.rb +16 -0
  166. data/lib/ooxml_parser/helpers/string_helper.rb +22 -0
  167. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment/presentation_comment_author.rb +25 -0
  168. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb +31 -0
  169. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +40 -0
  170. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +44 -0
  171. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +19 -0
  172. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +34 -0
  173. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +25 -0
  174. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +23 -0
  175. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/extents.rb +10 -0
  176. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/offset.rb +10 -0
  177. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/paragraph.rb +10 -0
  178. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/text_field.rb +18 -0
  179. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shapes_grouping/shapes_grouping.rb +9 -0
  180. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping/grouping_properties.rb +16 -0
  181. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +30 -0
  182. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb +22 -0
  183. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +28 -0
  184. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +31 -0
  185. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/set_time_node.rb +20 -0
  186. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition.rb +26 -0
  187. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb +33 -0
  188. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +52 -0
  189. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +23 -0
  190. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound/sound.rb +18 -0
  191. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound_action.rb +18 -0
  192. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +43 -0
  193. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb +9 -0
  194. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +110 -0
  195. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb +20 -0
  196. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +62 -0
  197. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +15 -0
  198. data/lib/ooxml_parser/version.rb +6 -0
  199. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character/excel_comment_character_properties.rb +27 -0
  200. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character.rb +25 -0
  201. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +20 -0
  202. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +43 -0
  203. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb +21 -0
  204. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb +23 -0
  205. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +18 -0
  206. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +24 -0
  207. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position/xlsx_drawing_position_parameters.rb +22 -0
  208. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position.rb +22 -0
  209. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_shape_grouping.rb +37 -0
  210. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +49 -0
  211. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb +30 -0
  212. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/foreground_color.rb +25 -0
  213. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb +38 -0
  214. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style.rb +95 -0
  215. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +47 -0
  216. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +19 -0
  217. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb +30 -0
  218. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +74 -0
  219. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +108 -0
  220. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +15 -0
  221. data/lib/ooxml_parser.rb +35 -0
  222. data/ooxml_parser.gemspec +30 -0
  223. metadata +310 -0
@@ -0,0 +1,20 @@
1
+ require_relative 'excel_comment/excel_comment_character'
2
+ # Single Comment of XLSX
3
+ module OoxmlParser
4
+ class ExcelComment < OOXMLDocumentObject
5
+ attr_accessor :characters
6
+
7
+ def initialize(characters = [])
8
+ @characters = characters
9
+ end
10
+
11
+ def self.parse(comment_node)
12
+ comment = ExcelComment.new
13
+ comment_node.xpath('xmlns:text/xmlns:r').each do |character_node|
14
+ character = ExcelCommentCharacter.parse(character_node)
15
+ comment.characters << character.dup
16
+ end
17
+ comment
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'excel_comments/excel_comment'
2
+ # All Comments of single XLSX
3
+ module OoxmlParser
4
+ class ExcelComments
5
+ attr_accessor :authors, :comments
6
+
7
+ def initialize(authors = [], comments = [])
8
+ @authors = authors
9
+ @comments = comments
10
+ end
11
+
12
+ def self.parse(file)
13
+ doc = Nokogiri::XML(File.open(file))
14
+ excel_comments = ExcelComments.new
15
+ comments_node = doc.search('//xmlns:comments').first
16
+ comments_node.xpath('*').each do |comments_node_child|
17
+ case comments_node_child.name
18
+ when 'authors'
19
+ comments_node_child.xpath('xmlns:author').each do |author_node|
20
+ excel_comments.authors << author_node.text
21
+ end
22
+ when 'commentList'
23
+ comments_node_child.xpath('xmlns:comment').each do |comment_node|
24
+ excel_comments.comments << ExcelComment.parse(comment_node)
25
+ end
26
+ end
27
+ end
28
+ excel_comments
29
+ end
30
+
31
+ def self.parse_file(file_name, path_to_folder)
32
+ path_to_comments_xml = ''
33
+ return nil unless File.exist?(path_to_folder + "xl/worksheets/_rels/#{file_name}.rels")
34
+ relationships = XmlSimple.xml_in(File.open(path_to_folder + "xl/worksheets/_rels/#{file_name}.rels"))
35
+ if relationships['Relationship']
36
+ relationships['Relationship'].each do |relationship|
37
+ path_to_comments_xml = path_to_folder + 'xl/' + relationship['Target'].gsub('..', '') if File.basename(relationship['Target']).include?('comment')
38
+ end
39
+ end
40
+ ExcelComments.parse(path_to_comments_xml) unless path_to_comments_xml == ''
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,21 @@
1
+ # Class for storing SheetFormatProperties
2
+ module OoxmlParser
3
+ class SheetFormatProperties
4
+ attr_accessor :default_column_width, :default_row_height
5
+
6
+ def initialize(column_width = nil, row_height = nil)
7
+ @default_column_width = column_width
8
+ @default_row_height = row_height
9
+ end
10
+
11
+ # Parse SheetFormatProperties
12
+ # @param node [Nokogiri::XML::Element] node to parse
13
+ # @return [SheetFormatProperties] value of SheetFormatProperties
14
+ def self.parse(node)
15
+ format_properties = SheetFormatProperties.new
16
+ format_properties.default_column_width = node.attribute('defaultColWidth').value.to_f
17
+ format_properties.default_row_height = node.attribute('defaultRowHeight').value.to_f
18
+ format_properties
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # XLSX data of pane
2
+ module OoxmlParser
3
+ class Pane
4
+ attr_accessor :state, :top_left_cell, :x_split, :y_split
5
+
6
+ def self.parse(pane_node)
7
+ pane = Pane.new
8
+ pane_node.attributes.each do |key, value|
9
+ case key
10
+ when 'state'
11
+ pane.state = value.value.to_sym
12
+ when 'topLeftCell'
13
+ pane.top_left_cell = Coordinates.parse_coordinates_from_string(value.value)
14
+ when 'xSplit'
15
+ pane.x_split = value.value
16
+ when 'ySplit'
17
+ pane.y_split = value.value
18
+ end
19
+ end
20
+ pane
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'sheet_view/pane'
2
+ # Class for Sheet View
3
+ module OoxmlParser
4
+ class SheetView
5
+ attr_accessor :pane
6
+
7
+ def self.parse(sheet_view_node)
8
+ sheet_view = SheetView.new
9
+ sheet_view_node.xpath('*').each do |sheet_view_node_child|
10
+ case sheet_view_node_child.name
11
+ when 'pane'
12
+ sheet_view.pane = Pane.parse(sheet_view_node_child)
13
+ end
14
+ end
15
+ sheet_view
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ # Properties of XLSX column
2
+ module OoxmlParser
3
+ class XlsxColumnProperties < OOXMLDocumentObject
4
+ attr_accessor :from, :to, :width, :style
5
+
6
+ def self.parse(col_node)
7
+ col = XlsxColumnProperties.new
8
+ col.from = col_node.attribute('min').value.to_i
9
+ col.to = col_node.attribute('max').value.to_i
10
+ col.style = CellStyle.parse(col_node.attribute('style').value) unless col_node.attribute('style').nil?
11
+ col.width = col_node.attribute('width').value.to_f - 0.7109375 if OOXMLDocumentObject.option_enabled?(col_node, 'customWidth')
12
+ col
13
+ end
14
+
15
+ def self.parse_list(columns_width_node)
16
+ columns = []
17
+ columns_width_node.xpath('xmlns:col').each do |col_node|
18
+ col = XlsxColumnProperties.parse(col_node)
19
+ columns << col
20
+ end
21
+ columns
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module OoxmlParser
2
+ class XlsxDrawingPositionParameters
3
+ attr_accessor :column, :column_offset, :row, :row_offset
4
+
5
+ def self.parse(position_node)
6
+ drawing_position_parameters = XlsxDrawingPositionParameters.new
7
+ position_node.xpath('*').each do |position_node_child|
8
+ case position_node_child.name
9
+ when 'col'
10
+ drawing_position_parameters.column = Coordinates.get_column_name(position_node_child.text.to_i + 1)
11
+ when 'colOff'
12
+ drawing_position_parameters.column_offset = (position_node_child.text.to_f / 360_000.0).round(3)
13
+ when 'row'
14
+ drawing_position_parameters.row = position_node_child.text.to_i + 1
15
+ when 'rowOff'
16
+ drawing_position_parameters.row_offset = (position_node_child.text.to_f / 360_000.0).round(3)
17
+ end
18
+ end
19
+ drawing_position_parameters
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'xlsx_drawing_position/xlsx_drawing_position_parameters'
2
+ module OoxmlParser
3
+ class XlsxDrawingPosition
4
+ attr_accessor :from, :to
5
+
6
+ # Parse XlsxDrawingPosition
7
+ # @param node [Nokogiri::XML::Element] node to parse
8
+ # @return [XlsxDrawingPosition] value of XlsxDrawingPosition
9
+ def self.parse(node)
10
+ position = XlsxDrawingPosition.new
11
+ node.xpath('*').each do |drawing_node_child|
12
+ case drawing_node_child.name
13
+ when 'from'
14
+ position.from = XlsxDrawingPositionParameters.parse(drawing_node_child)
15
+ when 'to'
16
+ position.to = XlsxDrawingPositionParameters.parse(drawing_node_child)
17
+ end
18
+ end
19
+ position
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ module OoxmlParser
2
+ class XlsxShapeGrouping
3
+ attr_accessor :properties, :shapes, :pictures, :grouping
4
+
5
+ def initialize(shapes = [], pictures = [])
6
+ @shapes = shapes
7
+ @pictures = pictures
8
+ end
9
+
10
+ def self.parse(grouping_node)
11
+ grouping = XlsxShapeGrouping.new
12
+ grouping_node.xpath('*').each do |grouping_node_child|
13
+ case grouping_node_child.name
14
+ when 'grpSpPr'
15
+ grouping.properties = DocxShapeProperties.parse(grouping_node_child)
16
+ when 'grpSp'
17
+ grouping.grouping = parse(grouping_node_child)
18
+ when 'sp'
19
+ grouping.shapes << DocxShape.parse(grouping_node_child)
20
+ when 'pic'
21
+ grouping.pictures << DocxPicture.parse(grouping_node_child)
22
+ when 'graphicFrame'
23
+ picture = DocxPicture.new
24
+ graphic_data_node = grouping_node_child.xpath('a:graphic/a:graphicData', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main')
25
+ graphic_data_node.xpath('*').each do |graphic_data_node_child|
26
+ case graphic_data_node_child.name
27
+ when 'chart'
28
+ picture.chart = Chart.parse
29
+ end
30
+ end
31
+ grouping.pictures << picture
32
+ end
33
+ end
34
+ grouping
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'xlsx_drawing/xlsx_drawing_position'
2
+ require_relative 'xlsx_drawing/xlsx_shape_grouping'
3
+ module OoxmlParser
4
+ class XlsxDrawing < OOXMLDocumentObject
5
+ attr_accessor :position, :picture, :shape, :grouping
6
+
7
+ def initialize(position = XlsxDrawingPosition.new)
8
+ @position = position
9
+ end
10
+
11
+ def self.parse(drawing_node)
12
+ drawing = XlsxDrawing.new
13
+ drawing.position = XlsxDrawingPosition.parse(drawing_node)
14
+ drawing_node.xpath('*').each do |drawing_node_child|
15
+ case drawing_node_child.name
16
+ when 'sp'
17
+ drawing.shape = DocxShape.parse(drawing_node_child)
18
+ when 'grpSp'
19
+ drawing.grouping = XlsxShapeGrouping.parse(drawing_node_child)
20
+ when 'pic'
21
+ drawing.picture = DocxPicture.parse(drawing_node_child)
22
+ when 'graphicFrame'
23
+ drawing.picture = DocxPicture.new
24
+ graphic_data_node = drawing_node_child.xpath('a:graphic/a:graphicData', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main')
25
+ graphic_data_node.xpath('*').each do |graphic_data_node_child|
26
+ case graphic_data_node_child.name
27
+ when 'chart'
28
+ path_to_chart_xml = OOXMLDocumentObject.get_link_from_rels(graphic_data_node_child.attribute('id').value)
29
+ OOXMLDocumentObject.add_to_xmls_stack(path_to_chart_xml)
30
+ drawing.picture.chart = Chart.parse
31
+ OOXMLDocumentObject.xmls_stack.pop
32
+ end
33
+ end
34
+ end
35
+ end
36
+ drawing
37
+ end
38
+
39
+ def self.parse_list(worksheet)
40
+ drawing_node = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
41
+ drawing_node.xpath('xdr:wsDr/*').each do |drawing_node_child|
42
+ case drawing_node_child.name
43
+ when 'twoCellAnchor'
44
+ worksheet.drawings << XlsxDrawing.parse(drawing_node_child)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,30 @@
1
+ # Character Alignment in XLSX
2
+ module OoxmlParser
3
+ class XlsxAlignment
4
+ attr_accessor :horizontal, :vertical, :wrap_text, :text_rotation
5
+
6
+ def initialize(horizontal = :left, vertical = :bottom, wrap_text = false)
7
+ @horizontal = horizontal
8
+ @vertical = vertical
9
+ @wrap_text = wrap_text
10
+ end
11
+
12
+ def self.parse(alignment_node)
13
+ alignment = XlsxAlignment.new
14
+ alignment_node.attributes.each do |key, value|
15
+ case key
16
+ when 'horizontal'
17
+ alignment.horizontal = value.value.to_sym
18
+ alignment.wrap_text = true if alignment.horizontal == :justify
19
+ when 'vertical'
20
+ alignment.vertical = value.value.to_sym
21
+ when 'wrapText'
22
+ alignment.wrap_text = value.value.to_s == '1'
23
+ when 'textRotation'
24
+ alignment.text_rotation = value.value.to_i
25
+ end
26
+ end
27
+ alignment
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ # Foreground Color Data
2
+ module OoxmlParser
3
+ class ForegroundColor < OOXMLDocumentObject
4
+ attr_accessor :type, :color
5
+
6
+ def initialize(type = nil, color = Color.new)
7
+ @type = type
8
+ @color = color
9
+ end
10
+
11
+ def nil?
12
+ @type.nil? && @color.nil?
13
+ end
14
+
15
+ def self.parse(style_number)
16
+ fill_color = ForegroundColor.new
17
+ fill_style_node = XLSXWorkbook.styles_node.xpath('//xmlns:fill')[style_number.to_i].xpath('xmlns:patternFill')
18
+ if fill_style_node && !fill_style_node.empty?
19
+ fill_color.type = fill_style_node.attribute('patternType').value.to_sym
20
+ fill_color.color = Color.parse_color_tag(fill_style_node.xpath('xmlns:fgColor').first)
21
+ end
22
+ fill_color
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ # Font Data
2
+ module OoxmlParser
3
+ class OOXMLFont < OOXMLDocumentObject
4
+ attr_accessor :name, :size, :font_style, :color
5
+
6
+ def initialize(name = 'Calibri', size = '11', font_style = nil, color = nil)
7
+ @name = name
8
+ @size = size
9
+ @font_style = font_style
10
+ @color = color
11
+ end
12
+
13
+ def self.parse(style_number)
14
+ font = OOXMLFont.new
15
+ font_style_node = XLSXWorkbook.styles_node.xpath('//xmlns:font')[style_number.to_i]
16
+ font.name = font_style_node.xpath('xmlns:name').first.attribute('val').value
17
+ font.size = font_style_node.xpath('xmlns:sz').first.attribute('val').value.to_i if font_style_node.xpath('xmlns:sz').first
18
+ font.font_style = FontStyle.new
19
+ font_style_node.xpath('*').each do |font_style_node_child|
20
+ case font_style_node_child.name
21
+ when 'b'
22
+ font.font_style.bold = true
23
+ when 'i'
24
+ font.font_style.italic = true
25
+ when 'strike'
26
+ font.font_style.strike = :single
27
+ when 'u'
28
+ unless font_style_node_child.attribute('val').value == 'none' && font_style_node_child
29
+ font.font_style.underlined = Underline.new((font_style_node_child.attribute('val').value || :single).to_sym)
30
+ end
31
+ when 'color'
32
+ font.color = Color.parse_color_tag(font_style_node_child)
33
+ end
34
+ end
35
+ font
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,95 @@
1
+ require_relative 'cell_style/foreground_color'
2
+ require_relative 'cell_style/alignment'
3
+ require_relative 'cell_style/ooxml_font'
4
+ module OoxmlParser
5
+ class CellStyle < OOXMLDocumentObject
6
+ ALL_FORMAT_VALUE = %w|0 0.00 #,##0 #,##0.00 $#,##0_);($#,##0) $#,##0_);[Red]($#,##0) $#,##0.00_);($#,##0.00)
7
+ $#,##0.00_);[Red]($#,##0.00)
8
+ 0.00% 0.00%
9
+ 0.00E+00
10
+ #\ ?/?
11
+ #\ ??/??
12
+ m/d/yyyy
13
+ d-mmm-yy
14
+ d-mmm
15
+ mmm-yy
16
+ h:mm AM/PM
17
+ h:mm:ss AM/PM
18
+ h:mm
19
+ h:mm:ss
20
+ m/d/yyyy h:mm
21
+ 0
22
+ 0
23
+ 0
24
+ 0
25
+ 0
26
+ 0
27
+ 0
28
+ 0
29
+ 0
30
+ 0
31
+ 0
32
+ 0
33
+ 0
34
+ 0
35
+ #,##0_);(#,##0)
36
+ #,##0_);[Red](#,##0)
37
+ #,##0.00_);(#,##0.00)
38
+ #,##0.00_);[Red](#,##0.00)
39
+ 0
40
+ 0
41
+ 0
42
+ 0
43
+ mm:ss
44
+ General
45
+ mm:ss.0
46
+ ##0.0E+0
47
+ @|.freeze
48
+
49
+ attr_accessor :font, :borders, :fill_color, :numerical_format, :alignment
50
+ # @return [True, False] check if style should add QuotePrefix (' symbol) to start of the string
51
+ attr_accessor :quote_prefix
52
+
53
+ def initialize(font = nil, borders = nil, fill_color = ForegroundColor.new, numerical_format = 'General', alignment = nil)
54
+ @font = font
55
+ @borders = borders
56
+ @fill_color = fill_color
57
+ @numerical_format = numerical_format
58
+ @alignment = alignment
59
+ end
60
+
61
+ def self.parse(style_number)
62
+ current_cell_style = XLSXWorkbook.styles_node.xpath('//xmlns:cellXfs/xmlns:xf')[style_number.to_i]
63
+ cell_style = CellStyle.new
64
+ cell_style.alignment = XlsxAlignment.new
65
+ cell_style.font = if current_cell_style.attribute('applyFont').nil? || current_cell_style.attribute('applyFont').value == '0'
66
+ OOXMLFont.parse(0)
67
+ else
68
+ OOXMLFont.parse(current_cell_style.attribute('fontId').value.to_i)
69
+ end
70
+ unless current_cell_style.attribute('applyBorder').nil? || current_cell_style.attribute('applyBorder').value == '0'
71
+ cell_style.borders = Borders.parse_from_style(current_cell_style.attribute('borderId').value.to_i)
72
+ end
73
+ unless current_cell_style.attribute('applyFill').nil? || current_cell_style.attribute('applyFill').value == '0'
74
+ cell_style.fill_color = ForegroundColor.parse(current_cell_style.attribute('fillId').value.to_i)
75
+ end
76
+ unless current_cell_style.attribute('applyNumberFormat').nil? || current_cell_style.attribute('applyNumberFormat').value == '0'
77
+ format_id = current_cell_style.attribute('numFmtId').value.to_i
78
+ XLSXWorkbook.styles_node.xpath('//xmlns:numFmt').each do |numeric_format|
79
+ if format_id == numeric_format.attribute('numFmtId').value.to_i
80
+ cell_style.numerical_format = numeric_format.attribute('formatCode').value
81
+ elsif CellStyle::ALL_FORMAT_VALUE[format_id - 1]
82
+ cell_style.numerical_format = CellStyle::ALL_FORMAT_VALUE[format_id - 1]
83
+ end
84
+ end
85
+ cell_style.numerical_format = CellStyle::ALL_FORMAT_VALUE[format_id - 1] if CellStyle::ALL_FORMAT_VALUE[format_id - 1]
86
+ end
87
+ unless current_cell_style.attribute('applyAlignment').nil? || current_cell_style.attribute('applyAlignment').value == '0'
88
+ alignment_node = current_cell_style.xpath('xmlns:alignment').first
89
+ cell_style.alignment = XlsxAlignment.parse(alignment_node) unless alignment_node.nil?
90
+ end
91
+ cell_style.quote_prefix = option_enabled?(current_cell_style, 'quotePrefix')
92
+ cell_style
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'xlsx_cell/cell_style'
2
+ # Single Cell of XLSX
3
+ module OoxmlParser
4
+ class XlsxCell < OOXMLDocumentObject
5
+ attr_accessor :style, :text, :formula, :character
6
+
7
+ # @return [String] text without applying any style modificators, like quote_prefix
8
+ attr_accessor :raw_text
9
+
10
+ def initialize(style = nil, text = '')
11
+ @style = style
12
+ @text = text
13
+ @raw_text = ''
14
+ end
15
+
16
+ def self.parse(cell_node)
17
+ text_string_id = nil
18
+ text_string_id = cell_node.attribute('s').value unless cell_node.attribute('s').nil?
19
+ cell = XlsxCell.new(CellStyle.parse(text_string_id))
20
+ if cell_node.attribute('t').nil?
21
+ cell.raw_text = cell_node.xpath('xmlns:v').text
22
+ else
23
+ cell_node.attribute('t').value == 's' ? get_shared_string(cell_node.xpath('xmlns:v').text, cell) : cell.raw_text = cell_node.xpath('xmlns:v').text
24
+ end
25
+ cell.formula = cell_node.xpath('xmlns:f').text unless cell_node.xpath('xmlns:f').text == ''
26
+ cell.text = cell.raw_text.dup unless cell.raw_text.nil?
27
+ cell.text.insert(0, "'") if cell.style.quote_prefix
28
+ cell
29
+ end
30
+
31
+ # Get shared string by it's number
32
+ # @param [String] value number of shared string
33
+ # @param [XlsxCell] cell to write value of string
34
+ # @return [Nothing]
35
+ def self.get_shared_string(value, cell)
36
+ return '' if value == ''
37
+ XLSXWorkbook.shared_strings[value.to_i].xpath('*').each do |si_node_child|
38
+ case si_node_child.name
39
+ when 'r'
40
+ cell.character = ParagraphRun.parse(si_node_child)
41
+ when 't'
42
+ cell.raw_text = si_node_child.text
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'xlsx_row/xlsx_cell'
2
+ # Single Row of XLSX
3
+ module OoxmlParser
4
+ class XlsxRow < OOXMLDocumentObject
5
+ attr_accessor :cells, :height, :style, :hidden
6
+
7
+ def initialize(cells = [])
8
+ @cells = cells
9
+ end
10
+
11
+ def self.parse(row_node)
12
+ row = XlsxRow.new
13
+ row.height = row_node.attribute('ht').value if OOXMLDocumentObject.option_enabled?(row_node, 'customHeight')
14
+ row.hidden = OOXMLDocumentObject.option_enabled?(row_node, 'hidden')
15
+ row_node.xpath('xmlns:c').each { |cell_node| row.cells[Coordinates.parse_coordinates_from_string(cell_node.attribute('r').value.to_s).get_column_number.to_i - 1] = XlsxCell.parse(cell_node) }
16
+ row
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ # Table in xlsx
2
+ module OoxmlParser
3
+ class XlsxTable < OOXMLDocumentObject
4
+ attr_accessor :name, :display_name, :reference, :autofilter, :columns
5
+
6
+ def self.parse(table_part_node)
7
+ table = XlsxTable.new
8
+ link_to_table_part_xml = OOXMLDocumentObject.get_link_from_rels(table_part_node.attribute('id').value)
9
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + link_to_table_part_xml.gsub('..', 'xl')))
10
+ table_node = doc.xpath('xmlns:table').first
11
+ table_node.attributes.each do |key, value|
12
+ case key
13
+ when 'name'
14
+ table.name = value.value.to_s
15
+ when 'displayName'
16
+ table.display_name = value.value.to_s
17
+ when 'ref'
18
+ table.reference = Coordinates.parser_coordinates_range value.value.to_s
19
+ end
20
+ end
21
+ table_node.xpath('*').each do |table_node_child|
22
+ case table_node_child.name
23
+ when 'autoFilter'
24
+ table.autofilter = Coordinates.parser_coordinates_range table_node_child.attribute('ref').value
25
+ end
26
+ end
27
+ table
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,74 @@
1
+ require_relative 'worksheet/excel_comments'
2
+ require_relative 'worksheet/sheet_format_properties'
3
+ require_relative 'worksheet/sheet_view'
4
+ require_relative 'worksheet/xlsx_column_properties'
5
+ require_relative 'worksheet/xlsx_drawing'
6
+ require_relative 'worksheet/xlsx_row'
7
+ require_relative 'worksheet/xlsx_table'
8
+ # Properties of worksheet
9
+ module OoxmlParser
10
+ class Worksheet < OOXMLDocumentObject
11
+ attr_accessor :name, :rows, :merge, :charts, :hyperlinks, :drawings, :comments, :columns, :sheet_format_properties,
12
+ :autofilter, :table_parts, :sheet_views
13
+
14
+ def initialize
15
+ @columns = []
16
+ @name = ''
17
+ @rows = []
18
+ @merge = []
19
+ @charts = []
20
+ @hyperlinks = []
21
+ @drawings = []
22
+ @sheet_views = []
23
+ @table_parts = []
24
+ end
25
+
26
+ def self.parse(path_to_xml_file)
27
+ worksheet = Worksheet.new
28
+ @current_sheet_xml_name = File.basename path_to_xml_file
29
+ OOXMLDocumentObject.add_to_xmls_stack("#{OOXMLDocumentObject.root_subfolder}/worksheets/#{File.basename(path_to_xml_file)}")
30
+ doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml))
31
+ sheet = doc.search('//xmlns:worksheet').first
32
+ sheet.xpath('*').each do |worksheet_node_child|
33
+ case worksheet_node_child.name
34
+ when 'sheetData'
35
+ worksheet_node_child.xpath('xmlns:row').each do |row_node|
36
+ worksheet.rows[row_node.attribute('r').value.to_i - 1] = XlsxRow.parse(row_node)
37
+ worksheet.rows[row_node.attribute('r').value.to_i - 1].style = CellStyle.parse(row_node.attribute('s').value) unless row_node.attribute('s').nil?
38
+ end
39
+ when 'sheetFormatPr'
40
+ if !worksheet_node_child.attribute('defaultColWidth').nil? && !worksheet_node_child.attribute('defaultRowHeight').nil?
41
+ worksheet.sheet_format_properties = SheetFormatProperties.parse(worksheet_node_child)
42
+ end
43
+ when 'mergeCells'
44
+ worksheet_node_child.xpath('xmlns:mergeCell').each do |merge_node|
45
+ worksheet.merge << merge_node.attribute('ref').value.to_s
46
+ end
47
+ when 'drawing'
48
+ path_to_drawing = OOXMLDocumentObject.get_link_from_rels(worksheet_node_child.attribute('id').value)
49
+ unless path_to_drawing.nil?
50
+ OOXMLDocumentObject.add_to_xmls_stack(path_to_drawing)
51
+ XlsxDrawing.parse_list(worksheet)
52
+ OOXMLDocumentObject.xmls_stack.pop
53
+ end
54
+ when 'hyperlinks'
55
+ worksheet_node_child.xpath('xmlns:hyperlink').each do |hyperlink_node|
56
+ worksheet.hyperlinks << Hyperlink.parse(hyperlink_node).dup
57
+ end
58
+ when 'cols'
59
+ worksheet.columns = XlsxColumnProperties.parse_list(worksheet_node_child)
60
+ when 'autoFilter'
61
+ worksheet.autofilter = Coordinates.parser_coordinates_range(worksheet_node_child.attribute('ref').value.to_s)
62
+ when 'tableParts'
63
+ worksheet.table_parts = []
64
+ worksheet_node_child.xpath('xmlns:tablePart').each { |table_part_node| worksheet.table_parts << XlsxTable.parse(table_part_node) }
65
+ when 'sheetViews'
66
+ worksheet_node_child.xpath('xmlns:sheetView').each { |sheet_view_node| worksheet.sheet_views << SheetView.parse(sheet_view_node) }
67
+ end
68
+ end
69
+ worksheet.comments = ExcelComments.parse_file(File.basename(path_to_xml_file), OOXMLDocumentObject.path_to_folder)
70
+ OOXMLDocumentObject.xmls_stack.pop
71
+ worksheet
72
+ end
73
+ end
74
+ end