axlsx 1.3.1 → 1.3.2
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/README.md +13 -5
- data/examples/colored_links.rb +59 -0
- data/examples/example.rb +421 -266
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/finance.rb +82 -0
- data/examples/finance.xlsx +0 -0
- data/examples/financial.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/where_is_my_color.xlsx +0 -0
- data/lib/axlsx.rb +11 -4
- data/lib/axlsx/content_type/abstract_content_type.rb +32 -0
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/content_type/default.rb +6 -37
- data/lib/axlsx/content_type/override.rb +6 -38
- data/lib/axlsx/doc_props/app.rb +7 -4
- data/lib/axlsx/drawing/axis.rb +3 -3
- data/lib/axlsx/drawing/chart.rb +2 -3
- data/lib/axlsx/drawing/d_lbls.rb +21 -31
- data/lib/axlsx/drawing/drawing.rb +6 -0
- data/lib/axlsx/drawing/hyperlink.rb +40 -32
- data/lib/axlsx/drawing/marker.rb +13 -13
- data/lib/axlsx/drawing/num_data.rb +6 -6
- data/lib/axlsx/drawing/num_data_source.rb +17 -16
- data/lib/axlsx/drawing/one_cell_anchor.rb +20 -22
- data/lib/axlsx/drawing/pic.rb +25 -27
- data/lib/axlsx/drawing/picture_locking.rb +12 -44
- data/lib/axlsx/drawing/scaling.rb +13 -13
- data/lib/axlsx/drawing/scatter_chart.rb +3 -3
- data/lib/axlsx/drawing/series.rb +3 -6
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +7 -8
- data/lib/axlsx/drawing/view_3D.rb +51 -37
- data/lib/axlsx/drawing/vml_shape.rb +23 -23
- data/lib/axlsx/package.rb +14 -16
- data/lib/axlsx/stylesheet/border.rb +29 -20
- data/lib/axlsx/stylesheet/border_pr.rb +5 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +55 -29
- data/lib/axlsx/stylesheet/cell_protection.rb +7 -4
- data/lib/axlsx/stylesheet/cell_style.rb +19 -14
- data/lib/axlsx/stylesheet/color.rb +19 -16
- data/lib/axlsx/stylesheet/dxf.rb +4 -4
- data/lib/axlsx/stylesheet/font.rb +22 -22
- data/lib/axlsx/stylesheet/gradient_fill.rb +45 -21
- data/lib/axlsx/stylesheet/num_fmt.rb +22 -13
- data/lib/axlsx/stylesheet/pattern_fill.rb +12 -21
- data/lib/axlsx/stylesheet/styles.rb +1 -1
- data/lib/axlsx/stylesheet/table_style.rb +17 -16
- data/lib/axlsx/stylesheet/table_style_element.rb +15 -11
- data/lib/axlsx/stylesheet/table_styles.rb +14 -11
- data/lib/axlsx/stylesheet/xf.rb +28 -26
- data/lib/axlsx/util/accessors.rb +49 -0
- data/lib/axlsx/util/options_parser.rb +15 -0
- data/lib/axlsx/util/serialized_attributes.rb +46 -0
- data/lib/axlsx/util/simple_typed_list.rb +16 -4
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +13 -58
- data/lib/axlsx/workbook/workbook.rb +27 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +11 -19
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +20 -27
- data/lib/axlsx/workbook/worksheet/cell.rb +38 -39
- data/lib/axlsx/workbook/worksheet/cfvo.rb +15 -15
- data/lib/axlsx/workbook/worksheet/cfvos.rb +18 -0
- data/lib/axlsx/workbook/worksheet/col.rb +34 -27
- data/lib/axlsx/workbook/worksheet/color_scale.rb +7 -13
- data/lib/axlsx/workbook/worksheet/comment.rb +14 -11
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +11 -11
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +27 -25
- data/lib/axlsx/workbook/worksheet/data_bar.rb +44 -34
- data/lib/axlsx/workbook/worksheet/data_validation.rb +61 -62
- data/lib/axlsx/workbook/worksheet/dimension.rb +0 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +20 -20
- data/lib/axlsx/workbook/worksheet/page_margins.rb +21 -19
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -9
- data/lib/axlsx/workbook/worksheet/page_setup.rb +20 -19
- data/lib/axlsx/workbook/worksheet/pane.rb +48 -51
- data/lib/axlsx/workbook/worksheet/print_options.rb +8 -30
- data/lib/axlsx/workbook/worksheet/protected_range.rb +16 -13
- data/lib/axlsx/workbook/worksheet/selection.rb +30 -38
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -26
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +19 -57
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +51 -155
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +68 -234
- data/lib/axlsx/workbook/worksheet/table.rb +16 -18
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +10 -27
- data/lib/axlsx/workbook/worksheet/worksheet.rb +6 -7
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +11 -33
- data/test/content_type/tc_default.rb +0 -11
- data/test/content_type/tc_override.rb +0 -13
- data/test/drawing/tc_d_lbls.rb +14 -4
- data/test/tc_axlsx.rb +20 -2
- data/test/workbook/tc_defined_name.rb +2 -2
- data/test/workbook/tc_workbook.rb +15 -0
- data/test/workbook/worksheet/tc_col.rb +11 -1
- data/test/workbook/worksheet/tc_pane.rb +5 -45
- data/test/workbook/worksheet/tc_selection.rb +9 -48
- metadata +13 -3
|
@@ -4,110 +4,9 @@ module Axlsx
|
|
|
4
4
|
# The SheetProtection object manages worksheet protection options per sheet.
|
|
5
5
|
class SheetProtection
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
7
|
+
include Axlsx::OptionsParser
|
|
8
|
+
include Axlsx::SerializedAttributes
|
|
9
|
+
include Axlsx::Accessors
|
|
111
10
|
|
|
112
11
|
# Creates a new SheetProtection instance
|
|
113
12
|
# @option options [Boolean] sheet @see SheetProtection#sheet
|
|
@@ -127,64 +26,62 @@ module Axlsx
|
|
|
127
26
|
# @option options [Boolean] pivot_tables @see SheetProtection#pivot_tables
|
|
128
27
|
# @option options [Boolean] select_unlocked_cells @see SheetProtection#select_unlocked_cells
|
|
129
28
|
# @option options [String] password. The password required for unlocking. @see SheetProtection#password=
|
|
130
|
-
# @option options [Boolean] objects @see SheetProtection#objects
|
|
131
29
|
def initialize(options={})
|
|
132
30
|
@objects = @scenarios = @select_locked_cells = @select_unlocked_cells = false
|
|
133
31
|
@sheet = @format_cells = @format_rows = @format_columns = @insert_columns = @insert_rows = @insert_hyperlinks = @delete_columns = @delete_rows = @sort = @auto_filter = @pivot_tables = true
|
|
134
32
|
@password = nil
|
|
33
|
+
parse_options options
|
|
34
|
+
end
|
|
135
35
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
36
|
+
boolean_attr_accessor :sheet, :objects, :scenarios, :format_cells, :format_columns, :format_rows,
|
|
37
|
+
:insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns, :delete_rows,
|
|
38
|
+
:select_locked_cells, :sort, :auto_filter, :pivot_tables, :select_unlocked_cells
|
|
39
|
+
|
|
40
|
+
serializable_attributes :sheet, :objects, :scenarios, :format_cells, :format_columns, :format_rows,
|
|
41
|
+
:insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns, :delete_rows,
|
|
42
|
+
:select_locked_cells, :sort, :auto_filter, :pivot_tables, :select_unlocked_cells, :salt, :password
|
|
43
|
+
|
|
44
|
+
# Specifies the salt which was prepended to the user-supplied password before it was hashed using the hashing algorithm
|
|
45
|
+
# @return [String]
|
|
46
|
+
attr_reader :salt_value
|
|
47
|
+
|
|
48
|
+
# Password hash
|
|
49
|
+
# @return [String]
|
|
50
|
+
# default nil
|
|
51
|
+
attr_reader :password
|
|
52
|
+
|
|
53
|
+
# This block is intended to implement the salt_value, hash_value and spin count as per the ECMA-376 standard.
|
|
54
|
+
# However, it does not seem to actually work in EXCEL - instead they are using their old retro algorithm shown below
|
|
55
|
+
# defined in the transitional portion of the speck. I am leaving this code in in the hope that someday Ill be able to
|
|
56
|
+
# figure out why it does not work, and if Excel even supports it.
|
|
57
|
+
# def propper_password=(v)
|
|
58
|
+
# @algorithm_name = v == nil ? nil : 'SHA-1'
|
|
59
|
+
# @salt_value = @spin_count = @hash_value = v if v == nil
|
|
60
|
+
# return if v == nil
|
|
61
|
+
# require 'digest/sha1'
|
|
62
|
+
# @spin_count = 10000
|
|
63
|
+
# @salt_value = Digest::SHA1.hexdigest(rand(36**8).to_s(36))
|
|
64
|
+
# @spin_count.times do |count|
|
|
65
|
+
# @hash_value = Digest::SHA1.hexdigest((@hash_value ||= (@salt_value + v.to_s)) + Array(count).pack('V'))
|
|
66
|
+
# end
|
|
67
|
+
# end
|
|
68
|
+
|
|
69
|
+
# encodes password for protection locking
|
|
70
|
+
def password=(v)
|
|
71
|
+
return if v == nil
|
|
72
|
+
@password = create_password_hash(v)
|
|
139
73
|
end
|
|
140
74
|
|
|
75
|
+
# Serialize the object
|
|
76
|
+
# @param [String] str
|
|
77
|
+
# @return [String]
|
|
78
|
+
def to_xml_string(str = '')
|
|
79
|
+
str << '<sheetProtection '
|
|
80
|
+
serialized_attributes str
|
|
81
|
+
str << '/>'
|
|
82
|
+
end
|
|
141
83
|
|
|
142
|
-
|
|
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
|
|
84
|
+
private
|
|
188
85
|
# Creates a password hash for a given password
|
|
189
86
|
# @return [String]
|
|
190
87
|
def create_password_hash(password)
|
|
@@ -196,7 +93,6 @@ module Axlsx
|
|
|
196
93
|
password_as_string[2..3] + password_as_string[0..1]
|
|
197
94
|
end
|
|
198
95
|
|
|
199
|
-
|
|
200
96
|
# Encodes a given password
|
|
201
97
|
# Based on the algorithm provided by Daniel Rentz of OpenOffice.
|
|
202
98
|
# http://www.openoffice.org/sc/excelfileformat.pdf, Revision 1.42, page 115 (21.05.2012)
|
|
@@ -5,10 +5,54 @@ module Axlsx
|
|
|
5
5
|
# @note The recommended way to manage the sheet view is via Worksheet#sheet_view
|
|
6
6
|
# @see Worksheet#sheet_view
|
|
7
7
|
class SheetView
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
include Axlsx::OptionsParser
|
|
10
|
+
include Axlsx::Accessors
|
|
11
|
+
include Axlsx::SerializedAttributes
|
|
12
|
+
|
|
13
|
+
# Creates a new {SheetView} object
|
|
14
|
+
# @option options [Integer] color_id Color Id
|
|
15
|
+
# @option options [Boolean] default_grid_color Default Grid Color
|
|
16
|
+
# @option options [Boolean] right_to_left Right To Left
|
|
17
|
+
# @option options [Boolean] show_formulas Show Formulas
|
|
18
|
+
# @option options [Boolean] show_grid_lines Show Grid Lines
|
|
19
|
+
# @option options [Boolean] show_outline_symbols Show Outline Symbols
|
|
20
|
+
# @option options [Boolean] show_row_col_headers Show Headers
|
|
21
|
+
# @option options [Boolean] show_ruler Show Ruler
|
|
22
|
+
# @option options [Boolean] show_white_space Show White Space
|
|
23
|
+
# @option options [Boolean] show_zeros Show Zero Values
|
|
24
|
+
# @option options [Boolean] tab_selected Sheet Tab Selected
|
|
25
|
+
# @option options [String, Cell] top_left_cell Top Left Visible Cell
|
|
26
|
+
# @option options [Symbol] view View Type
|
|
27
|
+
# @option options [Boolean] window_protection Window Protection
|
|
28
|
+
# @option options [Integer] workbook_view_id Workbook View Index
|
|
29
|
+
# @option options [Integer] zoom_scale
|
|
30
|
+
# @option options [Integer] zoom_scale_normal Zoom Scale Normal View
|
|
31
|
+
# @option options [Integer] zoom_scale_page_layout_view Zoom Scale Page Layout View
|
|
32
|
+
# @option options [Integer] zoom_scale_sheet_layout_view Zoom Scale Page Break Preview
|
|
33
|
+
def initialize(options={})
|
|
34
|
+
#defaults
|
|
35
|
+
@color_id = @top_left_cell = @pane = nil
|
|
36
|
+
@right_to_left = @show_formulas = @show_outline_symbols = @show_white_space = @tab_selected = @window_protection = false
|
|
37
|
+
@default_grid_color = @show_grid_lines = @show_row_col_headers = @show_ruler = @show_zeros = true
|
|
38
|
+
@zoom_scale = 100
|
|
39
|
+
@zoom_scale_normal = @zoom_scale_page_layout_view = @zoom_scale_sheet_layout_view = @workbook_view_id = 0
|
|
40
|
+
@selections = {}
|
|
41
|
+
parse_options options
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
boolean_attr_accessor :default_grid_color, :right_to_left, :show_formulas, :show_grid_lines,
|
|
45
|
+
:show_row_col_headers, :show_ruler, :show_white_space, :show_zeros, :tab_selected, :window_protection, :show_outline_symbols
|
|
46
|
+
|
|
47
|
+
serializable_attributes :default_grid_color, :right_to_left, :show_formulas, :show_grid_lines,
|
|
48
|
+
:show_row_col_headers, :show_ruler, :show_white_space, :show_zeros, :tab_selected, :window_protection, :show_outline_symbols,
|
|
49
|
+
:zoom_scale_sheet_layout_view, :zoom_scale_page_layout_view, :zoom_scale_normal, :workbook_view_id,
|
|
50
|
+
:view, :top_left_cell, :color_id, :zoom_scale
|
|
51
|
+
|
|
52
|
+
|
|
9
53
|
# instance values that must be serialized as their own elements - e.g. not attributes.
|
|
10
54
|
CHILD_ELEMENTS = [ :pane, :selections ]
|
|
11
|
-
|
|
55
|
+
|
|
12
56
|
# The pane object for the sheet view
|
|
13
57
|
# @return [Pane]
|
|
14
58
|
# @see [Pane]
|
|
@@ -17,7 +61,7 @@ module Axlsx
|
|
|
17
61
|
yield @pane if block_given?
|
|
18
62
|
@pane
|
|
19
63
|
end
|
|
20
|
-
|
|
64
|
+
|
|
21
65
|
# A hash of selection objects keyed by pane type associated with this sheet view.
|
|
22
66
|
# @return [Hash]
|
|
23
67
|
attr_reader :selections
|
|
@@ -32,116 +76,7 @@ module Axlsx
|
|
|
32
76
|
# @return [Integer]
|
|
33
77
|
# default nil
|
|
34
78
|
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
|
-
|
|
79
|
+
|
|
145
80
|
# Top Left Visible Cell
|
|
146
81
|
# Location of the top left visible cell Location
|
|
147
82
|
# of the top left visible cell in the bottom right
|
|
@@ -162,19 +97,7 @@ module Axlsx
|
|
|
162
97
|
# @return [Symbol]
|
|
163
98
|
# default :normal
|
|
164
99
|
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
|
-
|
|
100
|
+
|
|
178
101
|
# Workbook View Index
|
|
179
102
|
# Zero-based index of this workbook view, pointing
|
|
180
103
|
# to a workbookView element in the bookViews collection.
|
|
@@ -182,8 +105,7 @@ module Axlsx
|
|
|
182
105
|
# @return [Integer]
|
|
183
106
|
# default 0
|
|
184
107
|
attr_reader :workbook_view_id
|
|
185
|
-
|
|
186
|
-
|
|
108
|
+
|
|
187
109
|
# Zoom Scale
|
|
188
110
|
# Window zoom magnification for current view
|
|
189
111
|
# representing percent values. This attribute
|
|
@@ -195,8 +117,8 @@ module Axlsx
|
|
|
195
117
|
# @return [Integer]
|
|
196
118
|
# default 100
|
|
197
119
|
attr_reader :zoom_scale
|
|
198
|
-
|
|
199
|
-
|
|
120
|
+
|
|
121
|
+
|
|
200
122
|
# Zoom Scale Normal View
|
|
201
123
|
# Zoom magnification to use when in normal view,
|
|
202
124
|
# representing percent values. This attribute is
|
|
@@ -208,8 +130,8 @@ module Axlsx
|
|
|
208
130
|
# @return [Integer]
|
|
209
131
|
# default 0
|
|
210
132
|
attr_reader :zoom_scale_normal
|
|
211
|
-
|
|
212
|
-
|
|
133
|
+
|
|
134
|
+
|
|
213
135
|
# Zoom Scale Page Layout View
|
|
214
136
|
# Zoom magnification to use when in page layout
|
|
215
137
|
# view, representing percent values. This attribute
|
|
@@ -221,8 +143,8 @@ module Axlsx
|
|
|
221
143
|
# @return [Integer]
|
|
222
144
|
# default 0
|
|
223
145
|
attr_reader :zoom_scale_page_layout_view
|
|
224
|
-
|
|
225
|
-
|
|
146
|
+
|
|
147
|
+
|
|
226
148
|
# Zoom Scale Page Break Preview
|
|
227
149
|
# Zoom magnification to use when in page break
|
|
228
150
|
# preview, representing percent values. This
|
|
@@ -235,43 +157,7 @@ module Axlsx
|
|
|
235
157
|
# @return [Integer]
|
|
236
158
|
# default 0
|
|
237
159
|
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
|
-
|
|
160
|
+
|
|
275
161
|
# Adds a new selection
|
|
276
162
|
# param [Symbol] pane
|
|
277
163
|
# param [Hash] options
|
|
@@ -279,94 +165,42 @@ module Axlsx
|
|
|
279
165
|
def add_selection(pane, options = {})
|
|
280
166
|
@selections[pane] = Selection.new(options.merge(:pane => pane))
|
|
281
167
|
end
|
|
282
|
-
|
|
168
|
+
|
|
283
169
|
# @see color_id
|
|
284
170
|
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
|
-
|
|
171
|
+
|
|
327
172
|
# @see top_left_cell
|
|
328
173
|
def top_left_cell=(v)
|
|
329
174
|
cell = (v.class == Axlsx::Cell ? v.r_abs : v)
|
|
330
175
|
Axlsx::validate_string(cell)
|
|
331
|
-
@top_left_cell = cell
|
|
176
|
+
@top_left_cell = cell
|
|
332
177
|
end
|
|
333
|
-
|
|
334
|
-
|
|
178
|
+
|
|
335
179
|
# @see view
|
|
336
180
|
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
|
-
|
|
181
|
+
|
|
343
182
|
# @see workbook_view_id
|
|
344
183
|
def workbook_view_id=(v); Axlsx::validate_unsigned_int(v); @workbook_view_id = v end
|
|
345
|
-
|
|
346
|
-
|
|
184
|
+
|
|
347
185
|
# @see zoom_scale
|
|
348
186
|
def zoom_scale=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale = v end
|
|
349
|
-
|
|
350
|
-
|
|
187
|
+
|
|
351
188
|
# @see zoom_scale_normal
|
|
352
189
|
def zoom_scale_normal=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale_normal = v end
|
|
353
|
-
|
|
354
|
-
|
|
190
|
+
|
|
355
191
|
# @see zoom_scale_page_layout_view
|
|
356
192
|
def zoom_scale_page_layout_view=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale_page_layout_view = v end
|
|
357
|
-
|
|
358
|
-
|
|
193
|
+
|
|
359
194
|
# @see zoom_scale_sheet_layout_view
|
|
360
195
|
def zoom_scale_sheet_layout_view=(v); Axlsx::validate_scale_0_10_400(v); @zoom_scale_sheet_layout_view = v end
|
|
361
|
-
|
|
362
|
-
|
|
196
|
+
|
|
363
197
|
# Serializes the data validation
|
|
364
198
|
# @param [String] str
|
|
365
199
|
# @return [String]
|
|
366
200
|
def to_xml_string(str = '')
|
|
367
201
|
str << '<sheetViews>'
|
|
368
202
|
str << '<sheetView '
|
|
369
|
-
str
|
|
203
|
+
serialized_attributes str
|
|
370
204
|
str << '>'
|
|
371
205
|
@pane.to_xml_string(str) if @pane
|
|
372
206
|
@selections.each do |key, selection|
|