caxlsx 3.3.0 → 4.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +87 -11
- data/README.md +43 -16
- data/Rakefile +5 -11
- data/examples/generate.rb +3 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +15 -10
- data/lib/axlsx/content_type/content_type.rb +8 -10
- data/lib/axlsx/content_type/default.rb +7 -6
- data/lib/axlsx/content_type/override.rb +6 -5
- data/lib/axlsx/doc_props/app.rb +96 -32
- data/lib/axlsx/doc_props/core.rb +9 -12
- data/lib/axlsx/drawing/area_chart.rb +16 -17
- data/lib/axlsx/drawing/area_series.rb +23 -18
- data/lib/axlsx/drawing/ax_data_source.rb +4 -7
- data/lib/axlsx/drawing/axes.rb +11 -10
- data/lib/axlsx/drawing/axis.rb +83 -36
- data/lib/axlsx/drawing/bar_3D_chart.rb +30 -21
- data/lib/axlsx/drawing/bar_chart.rb +29 -20
- data/lib/axlsx/drawing/bar_series.rb +23 -18
- data/lib/axlsx/drawing/bubble_chart.rb +9 -10
- data/lib/axlsx/drawing/bubble_series.rb +11 -12
- data/lib/axlsx/drawing/cat_axis.rb +38 -28
- data/lib/axlsx/drawing/chart.rb +52 -30
- data/lib/axlsx/drawing/d_lbls.rb +36 -32
- data/lib/axlsx/drawing/drawing.rb +61 -62
- data/lib/axlsx/drawing/graphic_frame.rb +6 -7
- data/lib/axlsx/drawing/hyperlink.rb +22 -14
- data/lib/axlsx/drawing/line_3D_chart.rb +15 -17
- data/lib/axlsx/drawing/line_chart.rb +16 -17
- data/lib/axlsx/drawing/line_series.rb +23 -18
- data/lib/axlsx/drawing/marker.rb +29 -16
- data/lib/axlsx/drawing/num_data.rb +13 -16
- data/lib/axlsx/drawing/num_data_source.rb +11 -13
- data/lib/axlsx/drawing/num_val.rb +10 -11
- data/lib/axlsx/drawing/one_cell_anchor.rb +16 -10
- data/lib/axlsx/drawing/pic.rb +68 -24
- data/lib/axlsx/drawing/picture_locking.rb +6 -7
- data/lib/axlsx/drawing/pie_3D_chart.rb +9 -12
- data/lib/axlsx/drawing/pie_chart.rb +36 -0
- data/lib/axlsx/drawing/pie_series.rb +26 -17
- data/lib/axlsx/drawing/scaling.rb +26 -13
- data/lib/axlsx/drawing/scatter_chart.rb +10 -11
- data/lib/axlsx/drawing/scatter_series.rb +17 -18
- data/lib/axlsx/drawing/ser_axis.rb +22 -19
- data/lib/axlsx/drawing/series.rb +14 -8
- data/lib/axlsx/drawing/series_title.rb +6 -6
- data/lib/axlsx/drawing/str_data.rb +10 -13
- data/lib/axlsx/drawing/str_val.rb +8 -9
- data/lib/axlsx/drawing/title.rb +23 -27
- data/lib/axlsx/drawing/two_cell_anchor.rb +9 -9
- data/lib/axlsx/drawing/val_axis.rb +7 -8
- data/lib/axlsx/drawing/view_3D.rb +38 -30
- data/lib/axlsx/drawing/vml_drawing.rb +19 -20
- data/lib/axlsx/drawing/vml_shape.rb +25 -26
- data/lib/axlsx/package.rb +134 -99
- data/lib/axlsx/rels/relationship.rb +42 -30
- data/lib/axlsx/rels/relationships.rb +9 -10
- data/lib/axlsx/stylesheet/border.rb +16 -8
- data/lib/axlsx/stylesheet/border_pr.rb +24 -12
- data/lib/axlsx/stylesheet/cell_alignment.rb +44 -21
- data/lib/axlsx/stylesheet/cell_protection.rb +13 -7
- data/lib/axlsx/stylesheet/cell_style.rb +36 -15
- data/lib/axlsx/stylesheet/color.rb +23 -14
- data/lib/axlsx/stylesheet/dxf.rb +36 -15
- data/lib/axlsx/stylesheet/fill.rb +7 -6
- data/lib/axlsx/stylesheet/font.rb +71 -22
- data/lib/axlsx/stylesheet/gradient_fill.rb +16 -10
- data/lib/axlsx/stylesheet/gradient_stop.rb +14 -6
- data/lib/axlsx/stylesheet/num_fmt.rb +15 -14
- data/lib/axlsx/stylesheet/pattern_fill.rb +20 -8
- data/lib/axlsx/stylesheet/styles.rb +167 -118
- data/lib/axlsx/stylesheet/table_style.rb +20 -10
- data/lib/axlsx/stylesheet/table_style_element.rb +16 -8
- data/lib/axlsx/stylesheet/table_styles.rb +16 -11
- data/lib/axlsx/stylesheet/theme.rb +163 -0
- data/lib/axlsx/stylesheet/xf.rb +78 -25
- data/lib/axlsx/util/accessors.rb +13 -11
- data/lib/axlsx/util/buffered_zip_output_stream.rb +64 -0
- data/lib/axlsx/util/constants.rb +133 -110
- data/lib/axlsx/util/mime_type_utils.rb +75 -5
- data/lib/axlsx/util/options_parser.rb +4 -3
- data/lib/axlsx/util/serialized_attributes.rb +47 -23
- data/lib/axlsx/util/simple_typed_list.rb +77 -64
- data/lib/axlsx/util/storage.rb +38 -41
- data/lib/axlsx/util/uri_utils.rb +70 -0
- data/lib/axlsx/util/validators.rb +111 -48
- data/lib/axlsx/util/zip_command.rb +10 -12
- data/lib/axlsx/version.rb +3 -2
- data/lib/axlsx/workbook/defined_name.rb +13 -9
- data/lib/axlsx/workbook/defined_names.rb +5 -4
- data/lib/axlsx/workbook/shared_strings_table.rb +13 -14
- data/lib/axlsx/workbook/workbook.rb +152 -120
- data/lib/axlsx/workbook/workbook_view.rb +9 -12
- data/lib/axlsx/workbook/workbook_views.rb +5 -5
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +87 -15
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +16 -10
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +28 -25
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +54 -0
- data/lib/axlsx/workbook/worksheet/border_creator.rb +34 -29
- data/lib/axlsx/workbook/worksheet/break.rb +4 -5
- data/lib/axlsx/workbook/worksheet/cell.rb +125 -78
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +33 -29
- data/lib/axlsx/workbook/worksheet/cfvo.rb +13 -5
- data/lib/axlsx/workbook/worksheet/cfvos.rb +5 -5
- data/lib/axlsx/workbook/worksheet/col.rb +32 -19
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +9 -8
- data/lib/axlsx/workbook/worksheet/color_scale.rb +16 -16
- data/lib/axlsx/workbook/worksheet/cols.rb +10 -8
- data/lib/axlsx/workbook/worksheet/comment.rb +14 -13
- data/lib/axlsx/workbook/worksheet/comments.rb +11 -13
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +19 -9
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +75 -22
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +8 -8
- data/lib/axlsx/workbook/worksheet/data_bar.rb +29 -30
- data/lib/axlsx/workbook/worksheet/data_validation.rb +73 -33
- data/lib/axlsx/workbook/worksheet/data_validations.rb +8 -9
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +8 -8
- data/lib/axlsx/workbook/worksheet/dimension.rb +10 -7
- data/lib/axlsx/workbook/worksheet/header_footer.rb +5 -4
- data/lib/axlsx/workbook/worksheet/icon_set.rb +40 -12
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +11 -11
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +7 -4
- data/lib/axlsx/workbook/worksheet/page_margins.rb +41 -13
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +7 -6
- data/lib/axlsx/workbook/worksheet/page_setup.rb +153 -131
- data/lib/axlsx/workbook/worksheet/pane.rb +34 -26
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +78 -29
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +12 -13
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +6 -5
- data/lib/axlsx/workbook/worksheet/print_options.rb +4 -2
- data/lib/axlsx/workbook/worksheet/protected_range.rb +6 -5
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +13 -11
- data/lib/axlsx/workbook/worksheet/rich_text.rb +6 -6
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +66 -28
- data/lib/axlsx/workbook/worksheet/row.rb +34 -23
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +9 -8
- data/lib/axlsx/workbook/worksheet/selection.rb +22 -16
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +11 -7
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +7 -7
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +23 -19
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +12 -8
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +22 -21
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +71 -55
- data/lib/axlsx/workbook/worksheet/table.rb +13 -13
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +8 -6
- data/lib/axlsx/workbook/worksheet/tables.rb +8 -6
- data/lib/axlsx/workbook/worksheet/worksheet.rb +120 -79
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +13 -11
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +11 -4
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +12 -10
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +9 -7
- data/lib/axlsx.rb +120 -60
- data/lib/caxlsx.rb +3 -2
- metadata +42 -75
data/lib/axlsx/util/constants.rb
CHANGED
|
@@ -1,265 +1,277 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
module Axlsx
|
|
3
4
|
# XML Encoding
|
|
4
|
-
ENCODING = "UTF-8"
|
|
5
|
+
ENCODING = "UTF-8"
|
|
5
6
|
|
|
6
7
|
# spreadsheetML namespace
|
|
7
|
-
XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
|
8
|
+
XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
|
8
9
|
|
|
9
10
|
# content-types namespace
|
|
10
|
-
XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
11
|
+
XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
11
12
|
|
|
12
13
|
# extended-properties namespace
|
|
13
|
-
APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
|
|
14
|
+
APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
|
|
14
15
|
|
|
15
16
|
# doc props namespace
|
|
16
|
-
APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
|
|
17
|
+
APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
|
|
17
18
|
|
|
18
19
|
# core properties namespace
|
|
19
|
-
CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
|
|
20
|
+
CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
|
|
20
21
|
|
|
21
22
|
# dc elements (core) namespace
|
|
22
|
-
CORE_NS_DC = "http://purl.org/dc/elements/1.1/"
|
|
23
|
+
CORE_NS_DC = "http://purl.org/dc/elements/1.1/"
|
|
23
24
|
|
|
24
25
|
# dcmit (core) namespcace
|
|
25
|
-
CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/"
|
|
26
|
+
CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/"
|
|
26
27
|
|
|
27
28
|
# dc terms namespace
|
|
28
|
-
CORE_NS_DCT = "http://purl.org/dc/terms/"
|
|
29
|
+
CORE_NS_DCT = "http://purl.org/dc/terms/"
|
|
29
30
|
|
|
30
31
|
# xml schema namespace
|
|
31
|
-
CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
|
|
32
|
+
CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
|
|
32
33
|
|
|
33
34
|
# Digital signature namespace
|
|
34
|
-
DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature"
|
|
35
|
+
DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature"
|
|
35
36
|
|
|
36
37
|
# spreadsheet drawing namespace
|
|
37
|
-
XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
|
|
38
|
+
XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
|
|
38
39
|
|
|
39
40
|
# drawing namespace
|
|
40
|
-
XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
41
|
+
XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
41
42
|
|
|
42
43
|
# chart namespace
|
|
43
|
-
XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart"
|
|
44
|
+
XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart"
|
|
44
45
|
|
|
45
46
|
# relationships namespace
|
|
46
|
-
XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
47
|
+
XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
47
48
|
|
|
48
49
|
# relationships name space
|
|
49
|
-
RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
50
|
+
RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
50
51
|
|
|
51
52
|
# table rels namespace
|
|
52
|
-
TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
|
|
53
|
+
TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
|
|
53
54
|
|
|
54
55
|
# pivot table rels namespace
|
|
55
|
-
PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
|
|
56
|
+
PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
|
|
56
57
|
|
|
57
58
|
# pivot table cache definition namespace
|
|
58
|
-
PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
|
|
59
|
+
PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
|
|
59
60
|
|
|
60
61
|
# workbook rels namespace
|
|
61
|
-
WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
|
62
|
+
WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
|
62
63
|
|
|
63
64
|
# worksheet rels namespace
|
|
64
|
-
WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
|
|
65
|
+
WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
|
|
65
66
|
|
|
66
67
|
# app rels namespace
|
|
67
|
-
APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
|
|
68
|
+
APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
|
|
68
69
|
|
|
69
70
|
# core rels namespace
|
|
70
|
-
CORE_R = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
|
|
71
|
+
CORE_R = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
|
|
71
72
|
|
|
72
73
|
# digital signature rels namespace
|
|
73
|
-
DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature"
|
|
74
|
+
DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature"
|
|
74
75
|
|
|
75
76
|
# styles rels namespace
|
|
76
|
-
STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
|
|
77
|
+
STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
|
|
77
78
|
|
|
78
79
|
# shared strings namespace
|
|
79
|
-
SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
|
|
80
|
+
SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
|
|
81
|
+
|
|
82
|
+
# theme rels namespace
|
|
83
|
+
THEME_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
|
|
80
84
|
|
|
81
85
|
# drawing rels namespace
|
|
82
|
-
DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
|
|
86
|
+
DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
|
|
83
87
|
|
|
84
88
|
# chart rels namespace
|
|
85
|
-
CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
|
|
89
|
+
CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
|
|
86
90
|
|
|
87
91
|
# image rels namespace
|
|
88
|
-
IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
|
|
92
|
+
IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
|
|
89
93
|
|
|
90
94
|
# hyperlink rels namespace
|
|
91
|
-
HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
|
|
95
|
+
HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
|
|
92
96
|
|
|
93
97
|
# comment rels namespace
|
|
94
|
-
COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
|
|
98
|
+
COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
|
|
95
99
|
|
|
96
100
|
# comment relation for nil target
|
|
97
|
-
COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
|
|
101
|
+
COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
|
|
98
102
|
|
|
99
|
-
#vml drawing relation namespace
|
|
103
|
+
# vml drawing relation namespace
|
|
100
104
|
VML_DRAWING_R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'
|
|
101
105
|
|
|
102
106
|
# VML Drawing content type
|
|
103
|
-
VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
107
|
+
VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
104
108
|
|
|
105
109
|
# table content type
|
|
106
|
-
TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
|
|
110
|
+
TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
|
|
107
111
|
|
|
108
112
|
# pivot table content type
|
|
109
|
-
PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
|
|
113
|
+
PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
|
|
110
114
|
|
|
111
115
|
# pivot table cache definition content type
|
|
112
|
-
PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
|
|
116
|
+
PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
|
|
113
117
|
|
|
114
118
|
# workbook content type
|
|
115
|
-
WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
|
|
119
|
+
WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
|
|
116
120
|
|
|
117
121
|
# app content type
|
|
118
|
-
APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml"
|
|
122
|
+
APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml"
|
|
119
123
|
|
|
120
124
|
# rels content type
|
|
121
|
-
RELS_CT = "application/vnd.openxmlformats-package.relationships+xml"
|
|
125
|
+
RELS_CT = "application/vnd.openxmlformats-package.relationships+xml"
|
|
122
126
|
|
|
123
127
|
# styles content type
|
|
124
|
-
STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
128
|
+
STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
125
129
|
|
|
126
130
|
# xml content type
|
|
127
|
-
XML_CT = "application/xml"
|
|
131
|
+
XML_CT = "application/xml"
|
|
128
132
|
|
|
129
133
|
# worksheet content type
|
|
130
|
-
WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
|
|
134
|
+
WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
|
|
131
135
|
|
|
132
136
|
# shared strings content type
|
|
133
|
-
SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
|
|
137
|
+
SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
|
|
138
|
+
|
|
139
|
+
# theme content type
|
|
140
|
+
THEME_CT = "application/vnd.openxmlformats-officedocument.theme+xml"
|
|
134
141
|
|
|
135
142
|
# core content type
|
|
136
|
-
CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml"
|
|
143
|
+
CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml"
|
|
137
144
|
|
|
138
145
|
# digital signature xml content type
|
|
139
|
-
DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
|
|
146
|
+
DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
|
|
140
147
|
|
|
141
148
|
# digital signature origin content type
|
|
142
|
-
DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin"
|
|
149
|
+
DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin"
|
|
143
150
|
|
|
144
151
|
# digital signature certificate content type
|
|
145
|
-
DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate"
|
|
152
|
+
DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate"
|
|
146
153
|
|
|
147
154
|
# chart content type
|
|
148
|
-
CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
|
|
155
|
+
CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
|
|
149
156
|
|
|
150
157
|
# comments content type
|
|
151
|
-
COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
158
|
+
COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
152
159
|
|
|
153
160
|
# jpeg content type
|
|
154
|
-
JPEG_CT = "image/jpeg"
|
|
161
|
+
JPEG_CT = "image/jpeg"
|
|
155
162
|
|
|
156
163
|
# gif content type
|
|
157
|
-
GIF_CT = "image/gif"
|
|
164
|
+
GIF_CT = "image/gif"
|
|
158
165
|
|
|
159
166
|
# png content type
|
|
160
|
-
PNG_CT = "image/png"
|
|
161
|
-
|
|
162
|
-
#drawing content type
|
|
163
|
-
DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml".freeze
|
|
167
|
+
PNG_CT = "image/png"
|
|
164
168
|
|
|
169
|
+
# drawing content type
|
|
170
|
+
DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml"
|
|
165
171
|
|
|
166
172
|
# xml content type extensions
|
|
167
|
-
XML_EX = "xml"
|
|
173
|
+
XML_EX = "xml"
|
|
168
174
|
|
|
169
|
-
# jpeg
|
|
170
|
-
|
|
175
|
+
# jpeg extensions
|
|
176
|
+
JPEG_EXS = ["jpeg", "jpg"].freeze
|
|
171
177
|
|
|
172
178
|
# gif extension
|
|
173
|
-
GIF_EX = "gif"
|
|
179
|
+
GIF_EX = "gif"
|
|
174
180
|
|
|
175
181
|
# png extension
|
|
176
|
-
PNG_EX = "png"
|
|
182
|
+
PNG_EX = "png"
|
|
177
183
|
|
|
178
184
|
# rels content type extension
|
|
179
|
-
RELS_EX = "rels"
|
|
185
|
+
RELS_EX = "rels"
|
|
180
186
|
|
|
181
187
|
# workbook part
|
|
182
|
-
WORKBOOK_PN = "xl/workbook.xml"
|
|
188
|
+
WORKBOOK_PN = "xl/workbook.xml"
|
|
183
189
|
|
|
184
190
|
# styles part
|
|
185
|
-
STYLES_PN = "styles.xml"
|
|
191
|
+
STYLES_PN = "styles.xml"
|
|
186
192
|
|
|
187
193
|
# shared_strings part
|
|
188
|
-
SHARED_STRINGS_PN = "sharedStrings.xml"
|
|
194
|
+
SHARED_STRINGS_PN = "sharedStrings.xml"
|
|
195
|
+
|
|
196
|
+
# theme part
|
|
197
|
+
THEME_PN = "theme/theme1.xml"
|
|
189
198
|
|
|
190
199
|
# app part
|
|
191
|
-
APP_PN = "docProps/app.xml"
|
|
200
|
+
APP_PN = "docProps/app.xml"
|
|
192
201
|
|
|
193
202
|
# core part
|
|
194
|
-
CORE_PN = "docProps/core.xml"
|
|
203
|
+
CORE_PN = "docProps/core.xml"
|
|
195
204
|
|
|
196
205
|
# content types part
|
|
197
|
-
CONTENT_TYPES_PN = "[Content_Types].xml"
|
|
206
|
+
CONTENT_TYPES_PN = "[Content_Types].xml"
|
|
198
207
|
|
|
199
208
|
# rels part
|
|
200
|
-
RELS_PN = "_rels/.rels"
|
|
209
|
+
RELS_PN = "_rels/.rels"
|
|
201
210
|
|
|
202
211
|
# workbook rels part
|
|
203
|
-
WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels"
|
|
212
|
+
WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels"
|
|
204
213
|
|
|
205
214
|
# worksheet part
|
|
206
|
-
WORKSHEET_PN = "worksheets/sheet%d.xml"
|
|
215
|
+
WORKSHEET_PN = "worksheets/sheet%d.xml"
|
|
207
216
|
|
|
208
217
|
# worksheet rels part
|
|
209
|
-
WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels"
|
|
218
|
+
WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels"
|
|
210
219
|
|
|
211
220
|
# drawing part
|
|
212
|
-
DRAWING_PN = "drawings/drawing%d.xml"
|
|
221
|
+
DRAWING_PN = "drawings/drawing%d.xml"
|
|
213
222
|
|
|
214
223
|
# drawing rels part
|
|
215
|
-
DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels"
|
|
224
|
+
DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels"
|
|
216
225
|
|
|
217
226
|
# vml drawing part
|
|
218
|
-
VML_DRAWING_PN = "drawings/vmlDrawing%d.vml"
|
|
227
|
+
VML_DRAWING_PN = "drawings/vmlDrawing%d.vml"
|
|
219
228
|
|
|
220
229
|
# drawing part
|
|
221
|
-
TABLE_PN = "tables/table%d.xml"
|
|
230
|
+
TABLE_PN = "tables/table%d.xml"
|
|
222
231
|
|
|
223
232
|
# pivot table parts
|
|
224
|
-
PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml"
|
|
233
|
+
PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml"
|
|
225
234
|
|
|
226
235
|
# pivot table cache definition part name
|
|
227
|
-
PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml"
|
|
236
|
+
PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml"
|
|
228
237
|
|
|
229
238
|
# pivot table rels parts
|
|
230
|
-
PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels"
|
|
239
|
+
PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels"
|
|
231
240
|
|
|
232
241
|
# chart part
|
|
233
|
-
CHART_PN = "charts/chart%d.xml"
|
|
242
|
+
CHART_PN = "charts/chart%d.xml"
|
|
234
243
|
|
|
235
244
|
# chart part
|
|
236
|
-
IMAGE_PN = "media/image%d.%s"
|
|
245
|
+
IMAGE_PN = "media/image%d.%s"
|
|
237
246
|
|
|
238
247
|
# comment part
|
|
239
|
-
COMMENT_PN = "comments%d.xml"
|
|
248
|
+
COMMENT_PN = "comments%d.xml"
|
|
240
249
|
|
|
241
250
|
# location of schema files for validation
|
|
242
|
-
SCHEMA_BASE =
|
|
251
|
+
SCHEMA_BASE = "#{File.dirname(__FILE__)}/../../schema/"
|
|
243
252
|
|
|
244
253
|
# App validation schema
|
|
245
|
-
APP_XSD =
|
|
254
|
+
APP_XSD = "#{SCHEMA_BASE}shared-documentPropertiesExtended.xsd"
|
|
246
255
|
|
|
247
256
|
# core validation schema
|
|
248
|
-
CORE_XSD =
|
|
257
|
+
CORE_XSD = "#{SCHEMA_BASE}opc-coreProperties.xsd"
|
|
249
258
|
|
|
250
259
|
# content types validation schema
|
|
251
|
-
CONTENT_TYPES_XSD =
|
|
260
|
+
CONTENT_TYPES_XSD = "#{SCHEMA_BASE}opc-contentTypes.xsd"
|
|
252
261
|
|
|
253
262
|
# rels validation schema
|
|
254
|
-
RELS_XSD =
|
|
263
|
+
RELS_XSD = "#{SCHEMA_BASE}opc-relationships.xsd"
|
|
255
264
|
|
|
256
265
|
# spreadsheetML validation schema
|
|
257
|
-
SML_XSD =
|
|
266
|
+
SML_XSD = "#{SCHEMA_BASE}sml.xsd"
|
|
258
267
|
|
|
259
268
|
# drawing validation schema
|
|
260
|
-
DRAWING_XSD =
|
|
269
|
+
DRAWING_XSD = "#{SCHEMA_BASE}dml-spreadsheetDrawing.xsd"
|
|
261
270
|
|
|
262
|
-
#
|
|
271
|
+
# theme validation schema
|
|
272
|
+
THEME_XSD = "#{SCHEMA_BASE}dml-main.xsd"
|
|
273
|
+
|
|
274
|
+
# number format id for percentage formatting using the default formatting id.
|
|
263
275
|
NUM_FMT_PERCENT = 9
|
|
264
276
|
|
|
265
277
|
# number format id for date format like 2011/11/13
|
|
@@ -281,46 +293,46 @@ module Axlsx
|
|
|
281
293
|
WORKSHEET_NAME_FORBIDDEN_CHARS = '[]*/\?:'.chars.freeze
|
|
282
294
|
|
|
283
295
|
# error messages RestrictionValidor
|
|
284
|
-
ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s."
|
|
296
|
+
ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s."
|
|
285
297
|
|
|
286
298
|
# error message DataTypeValidator
|
|
287
|
-
ERR_TYPE = "Invalid Data %s for %s. must be %s."
|
|
299
|
+
ERR_TYPE = "Invalid Data %s for %s. must be %s."
|
|
288
300
|
|
|
289
301
|
# error message for RegexValidator
|
|
290
|
-
ERR_REGEX = "Invalid Data. %s does not match %s."
|
|
302
|
+
ERR_REGEX = "Invalid Data. %s does not match %s."
|
|
291
303
|
|
|
292
304
|
# error message for RangeValidator
|
|
293
|
-
ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s"
|
|
305
|
+
ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s"
|
|
294
306
|
|
|
295
307
|
# error message for sheets that use explicit empty string name
|
|
296
|
-
ERR_SHEET_NAME_EMPTY = "Your worksheet name is empty. Worksheet name can't be empty. Please assign name of your sheet or don't use name option at all."
|
|
308
|
+
ERR_SHEET_NAME_EMPTY = "Your worksheet name is empty. Worksheet name can't be empty. Please assign name of your sheet or don't use name option at all."
|
|
297
309
|
|
|
298
310
|
# error message for sheets that use a name which is longer than 31 bytes
|
|
299
|
-
ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be #{WORKSHEET_MAX_NAME_LENGTH} characters (bytes) or less"
|
|
311
|
+
ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be #{WORKSHEET_MAX_NAME_LENGTH} characters (bytes) or less"
|
|
300
312
|
|
|
301
313
|
# error message for sheets that use a name which include invalid characters
|
|
302
|
-
ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet."
|
|
314
|
+
ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet."
|
|
303
315
|
|
|
304
316
|
# error message for duplicate sheet names
|
|
305
|
-
ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name"
|
|
317
|
+
ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name"
|
|
306
318
|
|
|
307
319
|
# error message when user does not provide color and or style options for border in Style#add_sytle
|
|
308
|
-
ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s"
|
|
320
|
+
ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s"
|
|
309
321
|
|
|
310
322
|
# error message for invalid border id reference
|
|
311
|
-
ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index."
|
|
323
|
+
ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index."
|
|
312
324
|
|
|
313
325
|
# error message for invalid angles
|
|
314
|
-
ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s"
|
|
326
|
+
ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s"
|
|
315
327
|
|
|
316
328
|
# error message for non 'integerish' value
|
|
317
|
-
ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s"
|
|
329
|
+
ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s"
|
|
318
330
|
|
|
319
331
|
# error message for invalid cell reference
|
|
320
|
-
ERR_CELL_REFERENCE_INVALID = "Invalid cell definition `%s`"
|
|
332
|
+
ERR_CELL_REFERENCE_INVALID = "Invalid cell definition `%s`"
|
|
321
333
|
|
|
322
334
|
# error message for cell reference with last cell missing
|
|
323
|
-
ERR_CELL_REFERENCE_MISSING_CELL = "Missing cell `%s` for the specified range `%s`"
|
|
335
|
+
ERR_CELL_REFERENCE_MISSING_CELL = "Missing cell `%s` for the specified range `%s`"
|
|
324
336
|
|
|
325
337
|
# Regex to match forbidden control characters
|
|
326
338
|
# The following will be automatically stripped from worksheets.
|
|
@@ -356,7 +368,7 @@ module Axlsx
|
|
|
356
368
|
# x1F Information Separator One
|
|
357
369
|
#
|
|
358
370
|
# The following are not dealt with.
|
|
359
|
-
# If you have this in your data, expect
|
|
371
|
+
# If you have this in your data, expect Excel to blow up!
|
|
360
372
|
#
|
|
361
373
|
# x7F Delete
|
|
362
374
|
# x80 Control 0080
|
|
@@ -397,15 +409,14 @@ module Axlsx
|
|
|
397
409
|
# x0A Line Feed (Lf)
|
|
398
410
|
# x0D Carriage Return (Cr)
|
|
399
411
|
# x09 Character Tabulation
|
|
400
|
-
# @see
|
|
401
|
-
pattern = "\x0-\x08\x0B\x0C\x0E-\x1F"
|
|
402
|
-
pattern = pattern.respond_to?(:encode) ? pattern.encode('UTF-8') : pattern
|
|
412
|
+
# @see https://www.codetable.net/asciikeycodes
|
|
413
|
+
pattern = "\x0-\x08\x0B\x0C\x0E-\x1F".encode(Encoding::UTF_8)
|
|
403
414
|
|
|
404
415
|
# The regular expression used to remove control characters from worksheets
|
|
405
416
|
CONTROL_CHARS = pattern.freeze
|
|
406
417
|
|
|
407
418
|
# ISO 8601 date recognition
|
|
408
|
-
ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)
|
|
419
|
+
ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?\Z/.freeze
|
|
409
420
|
|
|
410
421
|
# FLOAT recognition
|
|
411
422
|
SAFE_FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]{1,2})?\Z/.freeze
|
|
@@ -413,4 +424,16 @@ module Axlsx
|
|
|
413
424
|
|
|
414
425
|
# Numeric recognition
|
|
415
426
|
NUMERIC_REGEX = /\A[+-]?\d+?\Z/.freeze
|
|
427
|
+
|
|
428
|
+
# Leading characters that indicate a formula.
|
|
429
|
+
# See: https://owasp.org/www-community/attacks/CSV_Injection
|
|
430
|
+
FORMULA_PREFIX = '='
|
|
431
|
+
|
|
432
|
+
# Leading characters that indicate an array formula.
|
|
433
|
+
ARRAY_FORMULA_PREFIX = '{='
|
|
434
|
+
|
|
435
|
+
# Trailing character that indicates an array formula.
|
|
436
|
+
ARRAY_FORMULA_SUFFIX = '}'
|
|
437
|
+
|
|
438
|
+
BOOLEAN_VALUES = [true, false].freeze
|
|
416
439
|
end
|
|
@@ -1,11 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Axlsx
|
|
2
4
|
# This module defines some utils related with mime type detection
|
|
3
5
|
module MimeTypeUtils
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
# Extension to MIME type mapping for Windows fallback
|
|
7
|
+
EXTENSION_FALLBACKS = {
|
|
8
|
+
'.jpg' => 'image/jpeg',
|
|
9
|
+
'.jpeg' => 'image/jpeg',
|
|
10
|
+
'.png' => 'image/png',
|
|
11
|
+
'.gif' => 'image/gif'
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# Detect a file mime type
|
|
16
|
+
# @param [String] v File path
|
|
17
|
+
# @return [String] File mime type
|
|
18
|
+
def get_mime_type(v)
|
|
19
|
+
mime_type = Marcel::MimeType.for(Pathname.new(v))
|
|
20
|
+
|
|
21
|
+
# Windows fallback: Marcel sometimes returns application/octet-stream for valid image files
|
|
22
|
+
if mime_type == 'application/octet-stream' && windows_platform?
|
|
23
|
+
extension = File.extname(v).downcase
|
|
24
|
+
# Verify it's actually an image by checking the file header
|
|
25
|
+
if EXTENSION_FALLBACKS.key?(extension) && File.exist?(v) && valid_image_file?(v, extension)
|
|
26
|
+
mime_type = EXTENSION_FALLBACKS[extension]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
mime_type
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Detect a file mime type from URI
|
|
34
|
+
# @param [String] v URI
|
|
35
|
+
# @return [String] File mime type
|
|
36
|
+
def get_mime_type_from_uri(v)
|
|
37
|
+
uri = URI.parse(v)
|
|
38
|
+
|
|
39
|
+
unless uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
|
|
40
|
+
raise URI::InvalidURIError, "Only HTTP/HTTPS URIs are supported"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
response = UriUtils.fetch_headers(uri)
|
|
44
|
+
mime_type = response&.[]('content-type')&.split(';')&.first&.strip
|
|
45
|
+
|
|
46
|
+
if mime_type.nil? || mime_type.empty?
|
|
47
|
+
raise ArgumentError, "Unable to determine MIME type from response"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
mime_type
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def windows_platform?
|
|
56
|
+
RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def valid_image_file?(file_path, extension)
|
|
60
|
+
return false unless File.exist?(file_path)
|
|
61
|
+
|
|
62
|
+
# Check magic bytes for common image formats
|
|
63
|
+
begin
|
|
64
|
+
header = File.binread(file_path, 10)
|
|
65
|
+
case extension
|
|
66
|
+
when '.jpg', '.jpeg'
|
|
67
|
+
header[0..2].bytes == [0xFF, 0xD8, 0xFF] # JPEG magic bytes
|
|
68
|
+
when '.png'
|
|
69
|
+
header[0..7].bytes == [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A] # PNG magic bytes
|
|
70
|
+
when '.gif'
|
|
71
|
+
header[0..2] == 'GIF' # GIF magic bytes
|
|
72
|
+
else
|
|
73
|
+
false
|
|
74
|
+
end
|
|
75
|
+
rescue StandardError
|
|
76
|
+
false
|
|
77
|
+
end
|
|
78
|
+
end
|
|
9
79
|
end
|
|
10
80
|
end
|
|
11
81
|
end
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Axlsx
|
|
2
4
|
# This module defines a single method for parsing options in class
|
|
3
5
|
# initializers.
|
|
4
6
|
module OptionsParser
|
|
5
|
-
|
|
6
7
|
# Parses an options hash by calling any defined method by the same
|
|
7
8
|
# name of the key postfixed with an '='
|
|
8
9
|
# @param [Hash] options Options to parse.
|
|
9
|
-
def parse_options(options={})
|
|
10
|
+
def parse_options(options = {})
|
|
10
11
|
options.each do |key, value|
|
|
11
12
|
key = :"#{key}="
|
|
12
|
-
|
|
13
|
+
send(key, value) if !value.nil? && respond_to?(key)
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
end
|