axlsx 1.1.4 → 1.3.1
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.
- data/.yardopts +6 -2
- data/CHANGELOG.md +72 -0
- data/README.md +114 -31
- data/Rakefile +11 -3
- data/examples/auto_filter.rb +16 -0
- data/examples/auto_filter.xlsx +0 -0
- data/examples/basic_charts.rb +58 -0
- data/examples/chart_colors.rb +17 -2
- data/examples/data_validation.rb +50 -0
- data/examples/example.rb +171 -60
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.pdf +0 -0
- data/examples/extractive.rb +3 -0
- data/examples/extractive.xlsx +0 -0
- data/examples/hyperlinks.rb +23 -0
- data/examples/hyperlinks.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/page_setup.rb +11 -0
- data/examples/page_setup.xlsx +0 -0
- data/examples/scraping_html.rb +91 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_protection.rb +10 -0
- data/examples/sheet_view.rb +34 -0
- data/examples/skydrive/axlsx.csv +1 -0
- data/examples/skydrive/axlsx.xlsx +0 -0
- data/examples/skydrive/real_example.rb +8 -8
- data/examples/sprk2012/Screen Shot 2012-09-11 at 10.42.06 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-11 at 11.07.48 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-11 at 8.31.50 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-11 at 9.23.27 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-11 at 9.32.06 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-11 at 9.33.35 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-11 at 9.46.44 PM.png +0 -0
- data/examples/sprk2012/Screen Shot 2012-09-12 at 5.07.23 PM.png +0 -0
- data/examples/sprk2012/basics.rb +11 -0
- data/examples/sprk2012/basics.xlsx +0 -0
- data/examples/sprk2012/gravatar.jpeg +0 -0
- data/examples/sprk2012/hair_club.jpg +0 -0
- data/examples/sprk2012/images.rb +9 -0
- data/examples/sprk2012/images.xlsx +0 -0
- data/examples/sprk2012/line_chart.rb +56 -0
- data/examples/sprk2012/line_chart.xlsx +0 -0
- data/examples/sprk2012/sprk2012.key +0 -0
- data/examples/sprk2012/styles.rb +20 -0
- data/examples/sprk2012/styles.xlsx +0 -0
- data/examples/styles.rb +62 -0
- data/examples/styles.xlsx +0 -0
- data/examples/two_cell_anchor_image.rb +11 -0
- data/lib/axlsx/content_type/content_type.rb +2 -0
- data/lib/axlsx/content_type/default.rb +30 -15
- data/lib/axlsx/content_type/override.rb +29 -14
- data/lib/axlsx/doc_props/app.rb +161 -104
- data/lib/axlsx/doc_props/core.rb +9 -5
- data/lib/axlsx/drawing/ax_data_source.rb +7 -6
- data/lib/axlsx/drawing/axis.rb +82 -36
- data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
- data/lib/axlsx/drawing/bar_series.rb +2 -1
- data/lib/axlsx/drawing/cat_axis.rb +43 -39
- data/lib/axlsx/drawing/chart.rb +65 -54
- data/lib/axlsx/drawing/d_lbls.rb +100 -0
- data/lib/axlsx/drawing/drawing.rb +20 -8
- data/lib/axlsx/drawing/graphic_frame.rb +2 -1
- data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
- data/lib/axlsx/drawing/num_data.rb +2 -2
- data/lib/axlsx/drawing/num_data_source.rb +4 -1
- data/lib/axlsx/drawing/pic.rb +44 -4
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
- data/lib/axlsx/drawing/scatter_chart.rb +2 -8
- data/lib/axlsx/drawing/title.rb +21 -9
- data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
- data/lib/axlsx/drawing/view_3D.rb +42 -32
- data/lib/axlsx/drawing/vml_drawing.rb +42 -0
- data/lib/axlsx/drawing/vml_shape.rb +125 -0
- data/lib/axlsx/package.rb +43 -16
- data/lib/axlsx/rels/relationship.rb +3 -3
- data/lib/axlsx/rels/relationships.rb +1 -11
- data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +11 -2
- data/lib/axlsx/stylesheet/table_style.rb +3 -3
- data/lib/axlsx/util/constants.rb +131 -2
- data/lib/axlsx/util/simple_typed_list.rb +18 -22
- data/lib/axlsx/util/validators.rb +100 -9
- data/lib/axlsx/version.rb +2 -7
- data/lib/axlsx/workbook/defined_name.rb +174 -0
- data/lib/axlsx/workbook/defined_names.rb +21 -0
- data/lib/axlsx/workbook/workbook.rb +70 -13
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +102 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +253 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +41 -8
- data/lib/axlsx/workbook/worksheet/col.rb +15 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
- data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
- data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
- data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
- data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -1
- data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +47 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +241 -0
- data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
- data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
- data/lib/axlsx/workbook/worksheet/row.rb +36 -20
- data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +49 -0
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +107 -0
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
- data/lib/axlsx/workbook/worksheet/table.rb +10 -3
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +68 -0
- data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +414 -254
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +101 -0
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
- data/lib/axlsx.rb +38 -16
- data/test/content_type/tc_content_type.rb +1 -6
- data/test/doc_props/tc_app.rb +31 -1
- data/test/doc_props/tc_core.rb +3 -1
- data/test/drawing/tc_axis.rb +38 -3
- data/test/drawing/tc_bar_3D_chart.rb +12 -12
- data/test/drawing/tc_bar_series.rb +1 -2
- data/test/drawing/tc_cat_axis.rb +3 -3
- data/test/drawing/tc_chart.rb +29 -9
- data/test/drawing/tc_d_lbls.rb +47 -0
- data/test/drawing/tc_drawing.rb +11 -5
- data/test/drawing/tc_hyperlink.rb +4 -5
- data/test/drawing/tc_line_series.rb +7 -3
- data/test/drawing/tc_num_data.rb +5 -1
- data/test/drawing/tc_pic.rb +22 -2
- data/test/drawing/tc_pie_3D_chart.rb +4 -8
- data/test/drawing/tc_pie_series.rb +7 -2
- data/test/drawing/tc_scatter_chart.rb +6 -1
- data/test/drawing/tc_scatter_series.rb +1 -1
- data/test/drawing/tc_series.rb +1 -1
- data/test/drawing/tc_title.rb +16 -0
- data/test/drawing/tc_two_cell_anchor.rb +1 -2
- data/test/drawing/tc_view_3D.rb +18 -18
- data/test/drawing/tc_vml_drawing.rb +25 -0
- data/test/drawing/tc_vml_shape.rb +100 -0
- data/test/rels/tc_relationship.rb +1 -0
- data/test/stylesheet/tc_gradient_fill.rb +8 -0
- data/test/stylesheet/tc_pattern_fill.rb +7 -1
- data/test/stylesheet/tc_styles.rb +16 -4
- data/test/stylesheet/tc_table_style.rb +8 -0
- data/test/stylesheet/tc_table_style_element.rb +10 -1
- data/test/tc_helper.rb +1 -0
- data/test/tc_package.rb +94 -17
- data/test/util/tc_simple_typed_list.rb +13 -0
- data/test/util/tc_validators.rb +101 -8
- data/test/workbook/tc_defined_name.rb +41 -0
- data/test/workbook/tc_workbook.rb +5 -3
- data/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +38 -0
- data/test/workbook/worksheet/auto_filter/tc_filter_column.rb +76 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +50 -0
- data/test/workbook/worksheet/tc_cell.rb +53 -7
- data/test/workbook/worksheet/tc_col.rb +9 -0
- data/test/workbook/worksheet/tc_comment.rb +57 -0
- data/test/workbook/worksheet/tc_comments.rb +57 -0
- data/test/workbook/worksheet/tc_conditional_formatting.rb +44 -0
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +265 -0
- data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
- data/test/workbook/worksheet/tc_page_setup.rb +143 -0
- data/test/workbook/worksheet/tc_pane.rb +94 -0
- data/test/workbook/worksheet/tc_print_options.rb +72 -0
- data/test/workbook/worksheet/tc_protected_range.rb +17 -0
- data/test/workbook/worksheet/tc_row.rb +32 -14
- data/test/workbook/worksheet/tc_selection.rb +94 -0
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
- data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
- data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
- data/test/workbook/worksheet/{table/tc_table.rb → tc_table.rb} +9 -12
- data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
- data/test/workbook/worksheet/tc_worksheet.rb +155 -51
- data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +64 -0
- metadata +194 -81
- data/examples/#extractive.csv# +0 -0
- data/examples/#extractive.rb# +0 -45
- data/examples/chart_colors.rb~ +0 -0
- data/examples/chart_colors.xlsx +0 -0
- data/examples/colored_series_data.xlsx +0 -0
- data/examples/conditional_formatting/getting_barred.xlsx +0 -0
- data/examples/example.csv +0 -1000
- data/examples/extractive.csv +0 -1
- data/examples/extractive.csv~ +0 -1
- data/examples/extractive.rb~ +0 -3
- data/examples/stack.rb +0 -21
- data/examples/stack.rb~ +0 -27
- data/examples/stack.xlsx +0 -0
- data/examples/~$chart_colors.xlsx +0 -0
- data/examples/~$extractive.xlsx +0 -0
- data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
- data/lib/axlsx/drawing/data_source.rb~ +0 -51
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
- data/lib/axlsx/drawing/num_data.rb~ +0 -51
- data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
- data/lib/axlsx/drawing/num_val.rb~ +0 -40
- data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
- data/lib/axlsx/drawing/ref.rb~ +0 -41
- data/lib/axlsx/drawing/str_data.rb~ +0 -58
- data/lib/axlsx/drawing/str_val.rb~ +0 -35
- data/lib/axlsx/util/cbf.rb +0 -333
- data/lib/axlsx/util/cfb.rb~ +0 -201
- data/lib/axlsx/util/font_tables.rb~ +0 -0
- data/lib/axlsx/util/ms_off_crypto.rb +0 -189
- data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
- data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
- data/lib/axlsx/util/parser.rb~ +0 -6
- data/lib/axlsx/util/storage.rb~ +0 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
- data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
- data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- data/test/drawing/tc_data_source.rb~ +0 -30
- data/test/drawing/tc_num_data.rb~ +0 -35
- data/test/drawing/tc_num_val.rb~ +0 -29
- data/test/drawing/tc_str_data.rb~ +0 -30
- data/test/drawing/tc_str_val.rb~ +0 -26
- data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
- data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
- data/test/workbook/worksheet/tc_col.rb~ +0 -10
- data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
- data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
- data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
|
|
4
|
+
# The SheetProtection object manages worksheet protection options per sheet.
|
|
5
|
+
class SheetProtection
|
|
6
|
+
|
|
7
|
+
# If 1 or true then AutoFilters should not be allowed to operate when the sheet is protected.
|
|
8
|
+
# If 0 or false then AutoFilters should be allowed to operate when the sheet is protected.
|
|
9
|
+
# @return [Boolean]
|
|
10
|
+
# default true
|
|
11
|
+
attr_reader :auto_filter
|
|
12
|
+
|
|
13
|
+
# If 1 or true then deleting columns should not be allowed when the sheet is protected.
|
|
14
|
+
# If 0 or false then deleting columns should be allowed when the sheet is protected.
|
|
15
|
+
# @return [Boolean]
|
|
16
|
+
# default true
|
|
17
|
+
attr_reader :delete_columns
|
|
18
|
+
|
|
19
|
+
# If 1 or true then deleting rows should not be allowed when the sheet is protected.
|
|
20
|
+
# If 0 or false then deleting rows should be allowed when the sheet is protected.
|
|
21
|
+
# @return [Boolean]
|
|
22
|
+
# default true
|
|
23
|
+
attr_reader :delete_rows
|
|
24
|
+
|
|
25
|
+
# If 1 or true then formatting cells should not be allowed when the sheet is protected.
|
|
26
|
+
# If 0 or false then formatting cells should be allowed when the sheet is protected.
|
|
27
|
+
# @return [Boolean]
|
|
28
|
+
# default true
|
|
29
|
+
attr_reader :format_cells
|
|
30
|
+
|
|
31
|
+
# If 1 or true then formatting columns should not be allowed when the sheet is protected.
|
|
32
|
+
# If 0 or false then formatting columns should be allowed when the sheet is protected.
|
|
33
|
+
# @return [Boolean]
|
|
34
|
+
# default true
|
|
35
|
+
attr_reader :format_columns
|
|
36
|
+
|
|
37
|
+
# If 1 or true then formatting rows should not be allowed when the sheet is protected.
|
|
38
|
+
# If 0 or false then formatting rows should be allowed when the sheet is protected.
|
|
39
|
+
# @return [Boolean]
|
|
40
|
+
# default true
|
|
41
|
+
attr_reader :format_rows
|
|
42
|
+
|
|
43
|
+
# If 1 or true then inserting columns should not be allowed when the sheet is protected.
|
|
44
|
+
# If 0 or false then inserting columns should be allowed when the sheet is protected.
|
|
45
|
+
# @return [Boolean]
|
|
46
|
+
# default true
|
|
47
|
+
attr_reader :insert_columns
|
|
48
|
+
|
|
49
|
+
# If 1 or true then inserting hyperlinks should not be allowed when the sheet is protected.
|
|
50
|
+
# If 0 or false then inserting hyperlinks should be allowed when the sheet is protected.
|
|
51
|
+
# @return [Boolean]
|
|
52
|
+
# default true
|
|
53
|
+
attr_reader :insert_hyperlinks
|
|
54
|
+
|
|
55
|
+
# If 1 or true then inserting rows should not be allowed when the sheet is protected.
|
|
56
|
+
# If 0 or false then inserting rows should be allowed when the sheet is protected.
|
|
57
|
+
# @return [Boolean]
|
|
58
|
+
# default true
|
|
59
|
+
attr_reader :insert_rows
|
|
60
|
+
|
|
61
|
+
# If 1 or true then editing of objects should not be allowed when the sheet is protected.
|
|
62
|
+
# If 0 or false then objects are allowed to be edited when the sheet is protected.
|
|
63
|
+
# @return [Boolean]
|
|
64
|
+
# default false
|
|
65
|
+
attr_reader :objects
|
|
66
|
+
|
|
67
|
+
# If 1 or true then PivotTables should not be allowed to operate when the sheet is protected.
|
|
68
|
+
# If 0 or false then PivotTables should be allowed to operate when the sheet is protected.
|
|
69
|
+
# @return [Boolean]
|
|
70
|
+
# default true
|
|
71
|
+
attr_reader :pivot_tables
|
|
72
|
+
|
|
73
|
+
# Specifies the salt which was prepended to the user-supplied password before it was hashed using the hashing algorithm
|
|
74
|
+
# @return [String]
|
|
75
|
+
attr_reader :salt_value
|
|
76
|
+
|
|
77
|
+
# If 1 or true then Scenarios should not be edited when the sheet is protected.
|
|
78
|
+
# If 0 or false then Scenarios are allowed to be edited when the sheet is protected.
|
|
79
|
+
# @return [Boolean]
|
|
80
|
+
# default false
|
|
81
|
+
attr_reader :scenarios
|
|
82
|
+
|
|
83
|
+
# If 1 or true then selection of locked cells should not be allowed when the sheet is protected.
|
|
84
|
+
# If 0 or false then selection of locked cells should be allowed when the sheet is protected.
|
|
85
|
+
# @return [Boolean]
|
|
86
|
+
# default false
|
|
87
|
+
attr_reader :select_locked_cells
|
|
88
|
+
|
|
89
|
+
# If 1 or true then selection of unlocked cells should not be allowed when the sheet is protected.
|
|
90
|
+
# If 0 or false then selection of unlocked cells should be allowed when the sheet is protected.
|
|
91
|
+
# @return [Boolean]
|
|
92
|
+
# default false
|
|
93
|
+
attr_reader :select_unlocked_cells
|
|
94
|
+
|
|
95
|
+
# If 1 or true then the sheet is protected.
|
|
96
|
+
# If 0 or false then the sheet is not protected.
|
|
97
|
+
# @return [Boolean]
|
|
98
|
+
# default true
|
|
99
|
+
attr_reader :sheet
|
|
100
|
+
|
|
101
|
+
# If 1 or true then sorting should not be allowed when the sheet is protected.
|
|
102
|
+
# If 0 or false then sorting should be allowed when the sheet is protected.
|
|
103
|
+
# @return [Boolean]
|
|
104
|
+
# default true
|
|
105
|
+
attr_reader :sort
|
|
106
|
+
|
|
107
|
+
# Password hash
|
|
108
|
+
# @return [String]
|
|
109
|
+
# default nil
|
|
110
|
+
attr_reader :password
|
|
111
|
+
|
|
112
|
+
# Creates a new SheetProtection instance
|
|
113
|
+
# @option options [Boolean] sheet @see SheetProtection#sheet
|
|
114
|
+
# @option options [Boolean] objects @see SheetProtection#objects
|
|
115
|
+
# @option options [Boolean] scenarios @see SheetProtection#scenarios
|
|
116
|
+
# @option options [Boolean] format_cells @see SheetProtection#objects
|
|
117
|
+
# @option options [Boolean] format_columns @see SheetProtection#format_columns
|
|
118
|
+
# @option options [Boolean] format_rows @see SheetProtection#format_rows
|
|
119
|
+
# @option options [Boolean] insert_columns @see SheetProtection#insert_columns
|
|
120
|
+
# @option options [Boolean] insert_rows @see SheetProtection#insert_rows
|
|
121
|
+
# @option options [Boolean] insert_hyperlinks @see SheetProtection#insert_hyperlinks
|
|
122
|
+
# @option options [Boolean] delete_columns @see SheetProtection#delete_columns
|
|
123
|
+
# @option options [Boolean] delete_rows @see SheetProtection#delete_rows
|
|
124
|
+
# @option options [Boolean] select_locked_cells @see SheetProtection#select_locked_cells
|
|
125
|
+
# @option options [Boolean] sort @see SheetProtection#sort
|
|
126
|
+
# @option options [Boolean] auto_filter @see SheetProtection#auto_filter
|
|
127
|
+
# @option options [Boolean] pivot_tables @see SheetProtection#pivot_tables
|
|
128
|
+
# @option options [Boolean] select_unlocked_cells @see SheetProtection#select_unlocked_cells
|
|
129
|
+
# @option options [String] password. The password required for unlocking. @see SheetProtection#password=
|
|
130
|
+
# @option options [Boolean] objects @see SheetProtection#objects
|
|
131
|
+
def initialize(options={})
|
|
132
|
+
@objects = @scenarios = @select_locked_cells = @select_unlocked_cells = false
|
|
133
|
+
@sheet = @format_cells = @format_rows = @format_columns = @insert_columns = @insert_rows = @insert_hyperlinks = @delete_columns = @delete_rows = @sort = @auto_filter = @pivot_tables = true
|
|
134
|
+
@password = nil
|
|
135
|
+
|
|
136
|
+
options.each do |o|
|
|
137
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# create validating setters for boolean values
|
|
143
|
+
# @return [Boolean]
|
|
144
|
+
[:sheet, :objects, :scenarios, :select_locked_cells, :sort,
|
|
145
|
+
:select_unlocked_cells, :format_cells, :format_rows, :format_columns,
|
|
146
|
+
:insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns,
|
|
147
|
+
:delete_rows, :auto_filter, :pivot_tables].each do |f_name|
|
|
148
|
+
define_method "#{f_name.to_s}=".to_sym do |v|
|
|
149
|
+
Axlsx::validate_boolean(v)
|
|
150
|
+
instance_variable_set "@#{f_name.to_s}".to_sym, v
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# This block is intended to implement the salt_value, hash_value and spin count as per the ECMA-376 standard.
|
|
155
|
+
# However, it does not seem to actually work in EXCEL - instead they are using their old retro algorithm shown below
|
|
156
|
+
# defined in the transitional portion of the speck. I am leaving this code in in the hope that someday Ill be able to
|
|
157
|
+
# figure out why it does not work, and if Excel even supports it.
|
|
158
|
+
# def propper_password=(v)
|
|
159
|
+
# @algorithm_name = v == nil ? nil : 'SHA-1'
|
|
160
|
+
# @salt_value = @spin_count = @hash_value = v if v == nil
|
|
161
|
+
# return if v == nil
|
|
162
|
+
# require 'digest/sha1'
|
|
163
|
+
# @spin_count = 10000
|
|
164
|
+
# @salt_value = Digest::SHA1.hexdigest(rand(36**8).to_s(36))
|
|
165
|
+
# @spin_count.times do |count|
|
|
166
|
+
# @hash_value = Digest::SHA1.hexdigest((@hash_value ||= (@salt_value + v.to_s)) + Array(count).pack('V'))
|
|
167
|
+
# end
|
|
168
|
+
# end
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# encodes password for protection locking
|
|
173
|
+
def password=(v)
|
|
174
|
+
return if v == nil
|
|
175
|
+
@password = create_password_hash(v)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Serialize the object
|
|
179
|
+
# @param [String] str
|
|
180
|
+
# @return [String]
|
|
181
|
+
def to_xml_string(str = '')
|
|
182
|
+
str << '<sheetProtection '
|
|
183
|
+
str << instance_values.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v.to_s}"} }.join(' ')
|
|
184
|
+
str << '/>'
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
private
|
|
188
|
+
# Creates a password hash for a given password
|
|
189
|
+
# @return [String]
|
|
190
|
+
def create_password_hash(password)
|
|
191
|
+
encoded_password = encode_password(password)
|
|
192
|
+
|
|
193
|
+
password_as_hex = [encoded_password].pack("v")
|
|
194
|
+
password_as_string = password_as_hex.unpack("H*").first.upcase
|
|
195
|
+
|
|
196
|
+
password_as_string[2..3] + password_as_string[0..1]
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
# Encodes a given password
|
|
201
|
+
# Based on the algorithm provided by Daniel Rentz of OpenOffice.
|
|
202
|
+
# http://www.openoffice.org/sc/excelfileformat.pdf, Revision 1.42, page 115 (21.05.2012)
|
|
203
|
+
# @return [String]
|
|
204
|
+
def encode_password(password)
|
|
205
|
+
i = 0
|
|
206
|
+
chars = password.split(//)
|
|
207
|
+
count = chars.size
|
|
208
|
+
|
|
209
|
+
chars.collect! do |char|
|
|
210
|
+
i += 1
|
|
211
|
+
char = char.unpack('c')[0] << i #ord << i
|
|
212
|
+
low_15 = char & 0x7fff
|
|
213
|
+
high_15 = char & 0x7fff << 15
|
|
214
|
+
high_15 = high_15 >> 15
|
|
215
|
+
char = low_15 | high_15
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
encoded_password = 0x0000
|
|
219
|
+
chars.each { |c| encoded_password ^= c }
|
|
220
|
+
encoded_password ^= count
|
|
221
|
+
encoded_password ^= 0xCE4B
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
# View options for a worksheet.
|
|
4
|
+
#
|
|
5
|
+
# @note The recommended way to manage the sheet view is via Worksheet#sheet_view
|
|
6
|
+
# @see Worksheet#sheet_view
|
|
7
|
+
class SheetView
|
|
8
|
+
|
|
9
|
+
# instance values that must be serialized as their own elements - e.g. not attributes.
|
|
10
|
+
CHILD_ELEMENTS = [ :pane, :selections ]
|
|
11
|
+
|
|
12
|
+
# The pane object for the sheet view
|
|
13
|
+
# @return [Pane]
|
|
14
|
+
# @see [Pane]
|
|
15
|
+
def pane
|
|
16
|
+
@pane ||= Pane.new
|
|
17
|
+
yield @pane if block_given?
|
|
18
|
+
@pane
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# A hash of selection objects keyed by pane type associated with this sheet view.
|
|
22
|
+
# @return [Hash]
|
|
23
|
+
attr_reader :selections
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Color Id
|
|
27
|
+
# Index to the color value for row/column
|
|
28
|
+
# text headings and gridlines. This is an
|
|
29
|
+
# 'index color value' (ICV) rather than
|
|
30
|
+
# rgb value.
|
|
31
|
+
# @see type
|
|
32
|
+
# @return [Integer]
|
|
33
|
+
# default nil
|
|
34
|
+
attr_reader :color_id
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Default Grid Color
|
|
38
|
+
# Flag indicating that the consuming application
|
|
39
|
+
# should use the default grid lines color
|
|
40
|
+
# (system dependent). Overrides any color
|
|
41
|
+
# specified in colorId.
|
|
42
|
+
# @see type
|
|
43
|
+
# @return [Boolean]
|
|
44
|
+
# default true
|
|
45
|
+
attr_reader :default_grid_color
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# Right To Left
|
|
49
|
+
# Flag indicating whether the sheet is in
|
|
50
|
+
# 'right to left' display mode. When in this
|
|
51
|
+
# mode, Column A is on the far right, Column B ;
|
|
52
|
+
# is one column left of Column A, and so on. Also,
|
|
53
|
+
# information in cells is displayed in the Right
|
|
54
|
+
# to Left format.
|
|
55
|
+
# @see type
|
|
56
|
+
# @return [Boolean]
|
|
57
|
+
# default false
|
|
58
|
+
attr_reader :right_to_left
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Show Formulas
|
|
62
|
+
# Flag indicating whether this sheet should
|
|
63
|
+
# display formulas.
|
|
64
|
+
# @see type
|
|
65
|
+
# @return [Boolean]
|
|
66
|
+
# default false
|
|
67
|
+
attr_reader :show_formulas
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# Show Grid Lines
|
|
71
|
+
# Flag indicating whether this sheet
|
|
72
|
+
# should display gridlines.
|
|
73
|
+
# @see type
|
|
74
|
+
# @return [Boolean]
|
|
75
|
+
# default true
|
|
76
|
+
attr_reader :show_grid_lines
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# Show Outline Symbols
|
|
80
|
+
# Flag indicating whether the sheet has outline
|
|
81
|
+
# symbols visible. This flag shall always override
|
|
82
|
+
# SheetPr element's outlinePr child element
|
|
83
|
+
# whose attribute is named showOutlineSymbols
|
|
84
|
+
# when there is a conflict.
|
|
85
|
+
# @see type
|
|
86
|
+
# @return [Boolean]
|
|
87
|
+
# default false
|
|
88
|
+
attr_reader :show_outline_symbols
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# Show Headers
|
|
92
|
+
# Flag indicating whether the sheet should
|
|
93
|
+
# display row and column headings.
|
|
94
|
+
# @see type
|
|
95
|
+
# @return [Boolean]
|
|
96
|
+
# default true
|
|
97
|
+
attr_reader :show_row_col_headers
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# Show Ruler
|
|
101
|
+
# Show the ruler in Page Layout View.
|
|
102
|
+
# @see type
|
|
103
|
+
# @return [Boolean]
|
|
104
|
+
# default true
|
|
105
|
+
attr_reader :show_ruler
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# Show White Space
|
|
109
|
+
# Flag indicating whether page layout
|
|
110
|
+
# view shall display margins. False means
|
|
111
|
+
# do not display left, right, top (header),
|
|
112
|
+
# and bottom (footer) margins (even when
|
|
113
|
+
# there is data in the header or footer).
|
|
114
|
+
# @see type
|
|
115
|
+
# @return [Boolean]
|
|
116
|
+
# default false
|
|
117
|
+
attr_reader :show_white_space
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# Show Zero Values
|
|
121
|
+
# Flag indicating whether the window should
|
|
122
|
+
# show 0 (zero) in cells containing zero value.
|
|
123
|
+
# When false, cells with zero value appear
|
|
124
|
+
# blank instead of showing the number zero.
|
|
125
|
+
# @see type
|
|
126
|
+
# @return [Boolean]
|
|
127
|
+
# default true
|
|
128
|
+
attr_reader :show_zeros
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Sheet Tab Selected
|
|
132
|
+
# Flag indicating whether this sheet is selected.
|
|
133
|
+
# When only 1 sheet is selected and active, this
|
|
134
|
+
# value should be in synch with the activeTab value.
|
|
135
|
+
# In case of a conflict, the Start Part setting
|
|
136
|
+
# wins and sets the active sheet tab. Multiple
|
|
137
|
+
# sheets can be selected, but only one sheet shall
|
|
138
|
+
# be active at one time.
|
|
139
|
+
# @see type
|
|
140
|
+
# @return [Boolean]
|
|
141
|
+
# default false
|
|
142
|
+
attr_reader :tab_selected
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Top Left Visible Cell
|
|
146
|
+
# Location of the top left visible cell Location
|
|
147
|
+
# of the top left visible cell in the bottom right
|
|
148
|
+
# pane (when in Left-to-Right mode).
|
|
149
|
+
# @see type
|
|
150
|
+
# @return [String]
|
|
151
|
+
# default nil
|
|
152
|
+
attr_reader :top_left_cell
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# View Type
|
|
156
|
+
# Indicates the view type.
|
|
157
|
+
# Options are
|
|
158
|
+
# * normal: Normal view
|
|
159
|
+
# * page_break_preview: Page break preview
|
|
160
|
+
# * page_layout: Page Layout View
|
|
161
|
+
# @see type
|
|
162
|
+
# @return [Symbol]
|
|
163
|
+
# default :normal
|
|
164
|
+
attr_reader :view
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# Window Protection
|
|
168
|
+
# Flag indicating whether the panes in the window
|
|
169
|
+
# are locked due to workbook protection.
|
|
170
|
+
# This is an option when the workbook structure is
|
|
171
|
+
# protected.
|
|
172
|
+
# @see type
|
|
173
|
+
# @return [Boolean]
|
|
174
|
+
# default true
|
|
175
|
+
attr_reader :window_protection
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# Workbook View Index
|
|
179
|
+
# Zero-based index of this workbook view, pointing
|
|
180
|
+
# to a workbookView element in the bookViews collection.
|
|
181
|
+
# @see type
|
|
182
|
+
# @return [Integer]
|
|
183
|
+
# default 0
|
|
184
|
+
attr_reader :workbook_view_id
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# Zoom Scale
|
|
188
|
+
# Window zoom magnification for current view
|
|
189
|
+
# representing percent values. This attribute
|
|
190
|
+
# is restricted to values ranging from 10 to 400.
|
|
191
|
+
# Horizontal & Vertical scale together.
|
|
192
|
+
# Current view can be Normal, Page Layout, or
|
|
193
|
+
# Page Break Preview.
|
|
194
|
+
# @see type
|
|
195
|
+
# @return [Integer]
|
|
196
|
+
# default 100
|
|
197
|
+
attr_reader :zoom_scale
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
# Zoom Scale Normal View
|
|
201
|
+
# Zoom magnification to use when in normal view,
|
|
202
|
+
# representing percent values. This attribute is
|
|
203
|
+
# restricted to values ranging from 10 to 400.
|
|
204
|
+
# Horizontal & Vertical scale together.
|
|
205
|
+
# Applies for worksheets only; zero implies the
|
|
206
|
+
# automatic setting.
|
|
207
|
+
# @see type
|
|
208
|
+
# @return [Integer]
|
|
209
|
+
# default 0
|
|
210
|
+
attr_reader :zoom_scale_normal
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
# Zoom Scale Page Layout View
|
|
214
|
+
# Zoom magnification to use when in page layout
|
|
215
|
+
# view, representing percent values. This attribute
|
|
216
|
+
# is restricted to values ranging from 10 to 400.
|
|
217
|
+
# Horizontal & Vertical scale together.
|
|
218
|
+
# Applies for worksheets only; zero implies
|
|
219
|
+
# the automatic setting.
|
|
220
|
+
# @see type
|
|
221
|
+
# @return [Integer]
|
|
222
|
+
# default 0
|
|
223
|
+
attr_reader :zoom_scale_page_layout_view
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
# Zoom Scale Page Break Preview
|
|
227
|
+
# Zoom magnification to use when in page break
|
|
228
|
+
# preview, representing percent values. This
|
|
229
|
+
# attribute is restricted to values ranging
|
|
230
|
+
# from 10 to 400. Horizontal & Vertical scale
|
|
231
|
+
# together.
|
|
232
|
+
# Applies for worksheet only; zero implies
|
|
233
|
+
# the automatic setting.
|
|
234
|
+
# @see type
|
|
235
|
+
# @return [Integer]
|
|
236
|
+
# default 0
|
|
237
|
+
attr_reader :zoom_scale_sheet_layout_view
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
# Creates a new {SheetView} object
|
|
241
|
+
# @option options [Integer] color_id Color Id
|
|
242
|
+
# @option options [Boolean] default_grid_color Default Grid Color
|
|
243
|
+
# @option options [Boolean] right_to_left Right To Left
|
|
244
|
+
# @option options [Boolean] show_formulas Show Formulas
|
|
245
|
+
# @option options [Boolean] show_grid_lines Show Grid Lines
|
|
246
|
+
# @option options [Boolean] show_outline_symbols Show Outline Symbols
|
|
247
|
+
# @option options [Boolean] show_row_col_headers Show Headers
|
|
248
|
+
# @option options [Boolean] show_ruler Show Ruler
|
|
249
|
+
# @option options [Boolean] show_white_space Show White Space
|
|
250
|
+
# @option options [Boolean] show_zeros Show Zero Values
|
|
251
|
+
# @option options [Boolean] tab_selected Sheet Tab Selected
|
|
252
|
+
# @option options [String, Cell] top_left_cell Top Left Visible Cell
|
|
253
|
+
# @option options [Symbol] view View Type
|
|
254
|
+
# @option options [Boolean] window_protection Window Protection
|
|
255
|
+
# @option options [Integer] workbook_view_id Workbook View Index
|
|
256
|
+
# @option options [Integer] zoom_scale_normal Zoom Scale Normal View
|
|
257
|
+
# @option options [Integer] zoom_scale_page_layout_view Zoom Scale Page Layout View
|
|
258
|
+
# @option options [Integer] zoom_scale_sheet_layout_view Zoom Scale Page Break Preview
|
|
259
|
+
def initialize(options={})
|
|
260
|
+
#defaults
|
|
261
|
+
@color_id = @top_left_cell = @pane = nil
|
|
262
|
+
@right_to_left = @show_formulas = @show_outline_symbols = @show_white_space = @tab_selected = @window_protection = false
|
|
263
|
+
@default_grid_color = @show_grid_lines = @show_row_col_headers = @show_ruler = @show_zeros = true
|
|
264
|
+
@zoom_scale = 100
|
|
265
|
+
@zoom_scale_normal = @zoom_scale_page_layout_view = @zoom_scale_sheet_layout_view = @workbook_view_id = 0
|
|
266
|
+
@selections = {}
|
|
267
|
+
|
|
268
|
+
# write options to instance variables
|
|
269
|
+
options.each do |o|
|
|
270
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
# Adds a new selection
|
|
276
|
+
# param [Symbol] pane
|
|
277
|
+
# param [Hash] options
|
|
278
|
+
# return [Selection]
|
|
279
|
+
def add_selection(pane, options = {})
|
|
280
|
+
@selections[pane] = Selection.new(options.merge(:pane => pane))
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# @see color_id
|
|
284
|
+
def color_id=(v); Axlsx::validate_unsigned_int(v); @color_id = v end
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
# @see default_grid_color
|
|
288
|
+
def default_grid_color=(v); Axlsx::validate_boolean(v); @default_grid_color = v end
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
# @see right_to_left
|
|
292
|
+
def right_to_left=(v); Axlsx::validate_boolean(v); @right_to_left = v end
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
# @see show_formulas
|
|
296
|
+
def show_formulas=(v); Axlsx::validate_boolean(v); @show_formulas = v end
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
# @see show_grid_lines
|
|
300
|
+
def show_grid_lines=(v); Axlsx::validate_boolean(v); @show_grid_lines = v end
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# @see show_outline_symbols
|
|
304
|
+
def show_outline_symbols=(v); Axlsx::validate_boolean(v); @show_outline_symbols = v end
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
# @see show_row_col_headers
|
|
308
|
+
def show_row_col_headers=(v); Axlsx::validate_boolean(v); @show_row_col_headers = v end
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
# @see show_ruler
|
|
312
|
+
def show_ruler=(v); Axlsx::validate_boolean(v); @show_ruler = v end
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
# @see show_white_space
|
|
316
|
+
def show_white_space=(v); Axlsx::validate_boolean(v); @show_white_space = v end
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
# @see show_zeros
|
|
320
|
+
def show_zeros=(v); Axlsx::validate_boolean(v); @show_zeros = v end
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
# @see tab_selected
|
|
324
|
+
def tab_selected=(v); Axlsx::validate_boolean(v); @tab_selected = v end
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
# @see top_left_cell
|
|
328
|
+
def top_left_cell=(v)
|
|
329
|
+
cell = (v.class == Axlsx::Cell ? v.r_abs : v)
|
|
330
|
+
Axlsx::validate_string(cell)
|
|
331
|
+
@top_left_cell = cell
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
# @see view
|
|
336
|
+
def view=(v); Axlsx::validate_sheet_view_type(v); @view = v end
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
# @see window_protection
|
|
340
|
+
def window_protection=(v); Axlsx::validate_boolean(v); @window_protection = v end
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
# @see workbook_view_id
|
|
344
|
+
def workbook_view_id=(v); Axlsx::validate_unsigned_int(v); @workbook_view_id = v end
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# @see zoom_scale
|
|
348
|
+
def zoom_scale=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale = v end
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
# @see zoom_scale_normal
|
|
352
|
+
def zoom_scale_normal=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale_normal = v end
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
# @see zoom_scale_page_layout_view
|
|
356
|
+
def zoom_scale_page_layout_view=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale_page_layout_view = v end
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
# @see zoom_scale_sheet_layout_view
|
|
360
|
+
def zoom_scale_sheet_layout_view=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale_sheet_layout_view = v end
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
# Serializes the data validation
|
|
364
|
+
# @param [String] str
|
|
365
|
+
# @return [String]
|
|
366
|
+
def to_xml_string(str = '')
|
|
367
|
+
str << '<sheetViews>'
|
|
368
|
+
str << '<sheetView '
|
|
369
|
+
str << instance_values.map { |key, value| (Axlsx::camel(key.to_s, false) << '="' << value.to_s << '"') unless CHILD_ELEMENTS.include?(key.to_sym) || value == nil }.join(' ')
|
|
370
|
+
str << '>'
|
|
371
|
+
@pane.to_xml_string(str) if @pane
|
|
372
|
+
@selections.each do |key, selection|
|
|
373
|
+
selection.to_xml_string(str)
|
|
374
|
+
end
|
|
375
|
+
str << '</sheetView>'
|
|
376
|
+
str << '</sheetViews>'
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
end
|
|
@@ -19,8 +19,8 @@ module Axlsx
|
|
|
19
19
|
attr_reader :style
|
|
20
20
|
|
|
21
21
|
# Creates a new Table object
|
|
22
|
-
# @param [String] ref The reference to the table data.
|
|
23
|
-
# @param [
|
|
22
|
+
# @param [String] ref The reference to the table data like 'A1:G24'.
|
|
23
|
+
# @param [Worksheet] sheet The sheet containing the table data.
|
|
24
24
|
# @option options [Cell, String] name
|
|
25
25
|
# @option options [TableStyle] style
|
|
26
26
|
def initialize(ref, sheet, options={})
|
|
@@ -28,6 +28,7 @@ module Axlsx
|
|
|
28
28
|
@sheet = sheet
|
|
29
29
|
@style = nil
|
|
30
30
|
@sheet.workbook.tables << self
|
|
31
|
+
@table_style_info = TableStyleInfo.new(options[:style_info]) if options[:style_info]
|
|
31
32
|
@name = "Table#{index+1}"
|
|
32
33
|
options.each do |o|
|
|
33
34
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
@@ -62,6 +63,12 @@ module Axlsx
|
|
|
62
63
|
@name = v
|
|
63
64
|
end
|
|
64
65
|
end
|
|
66
|
+
|
|
67
|
+
# TableStyleInfo for the table.
|
|
68
|
+
# initialization can be fed via the :style_info option
|
|
69
|
+
def table_style_info
|
|
70
|
+
@table_style_info ||= TableStyleInfo.new
|
|
71
|
+
end
|
|
65
72
|
|
|
66
73
|
# Serializes the object
|
|
67
74
|
# @param [String] str
|
|
@@ -77,7 +84,7 @@ module Axlsx
|
|
|
77
84
|
end
|
|
78
85
|
str << '</tableColumns>'
|
|
79
86
|
#TODO implement tableStyleInfo
|
|
80
|
-
str
|
|
87
|
+
table_style_info.to_xml_string(str) # '<tableStyleInfo showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0" name="TableStyleMedium9" />'
|
|
81
88
|
str << '</table>'
|
|
82
89
|
end
|
|
83
90
|
|