axlsx 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -6
- data/examples/axis-titles.xlsx +0 -0
- data/examples/basic_charts.rb +46 -0
- data/examples/basic_charts.xlsx +0 -0
- data/examples/charts.xlsx +0 -0
- data/examples/example.rb +17 -1
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/pie_chart_excel.xlsx +0 -0
- data/examples/pie_chart_saved.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_view.rb +34 -0
- data/examples/sheet_view.xlsx +0 -0
- data/examples/~$example.xlsx +0 -0
- data/lib/axlsx.rb +3 -2
- data/lib/axlsx/drawing/axis.rb +18 -0
- data/lib/axlsx/drawing/cat_axis.rb +3 -3
- data/lib/axlsx/drawing/chart.rb +3 -3
- data/lib/axlsx/drawing/drawing.rb +0 -1
- data/lib/axlsx/drawing/graphic_frame.rb +2 -2
- data/lib/axlsx/drawing/num_data.rb +2 -2
- data/lib/axlsx/drawing/title.rb +21 -9
- data/lib/axlsx/package.rb +9 -5
- data/lib/axlsx/util/validators.rb +28 -4
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +7 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +4 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +1 -1
- data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
- data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +27 -10
- data/test/drawing/tc_axis.rb +19 -2
- data/test/drawing/tc_cat_axis.rb +3 -3
- data/test/drawing/tc_num_data.rb +5 -1
- data/test/drawing/tc_title.rb +16 -0
- data/test/tc_package.rb +24 -4
- data/test/util/tc_validators.rb +68 -11
- data/test/workbook/worksheet/tc_pane.rb +94 -0
- data/test/workbook/worksheet/tc_selection.rb +94 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
- data/test/workbook/worksheet/tc_worksheet.rb +0 -7
- metadata +28 -13
- data/examples/pie_chart.rb +0 -16
- data/examples/pie_chart.xlsx +0 -0
- data/examples/~$pie_chart_saved.xlsx +0 -0
data/lib/axlsx/version.rb
CHANGED
@@ -5,6 +5,6 @@ module Axlsx
|
|
5
5
|
# When using bunle exec rake and referencing the gem on github or locally
|
6
6
|
# it will use the gemspec, which preloads this constant for the gem's version.
|
7
7
|
# We check to make sure that it has not already been loaded
|
8
|
-
VERSION="1.1.
|
8
|
+
VERSION="1.1.7" unless defined? Axlsx::VERSION
|
9
9
|
|
10
10
|
end
|
@@ -21,7 +21,9 @@ require 'axlsx/workbook/worksheet/worksheet.rb'
|
|
21
21
|
require 'axlsx/workbook/shared_strings_table.rb'
|
22
22
|
require 'axlsx/workbook/worksheet/table.rb'
|
23
23
|
require 'axlsx/workbook/worksheet/data_validation.rb'
|
24
|
-
|
24
|
+
require 'axlsx/workbook/worksheet/sheet_view.rb'
|
25
|
+
require 'axlsx/workbook/worksheet/pane.rb'
|
26
|
+
require 'axlsx/workbook/worksheet/selection.rb'
|
25
27
|
# The Workbook class is an xlsx workbook that manages worksheets, charts, drawings and styles.
|
26
28
|
# The following parts of the Office Open XML spreadsheet specification are not implimented in this version.
|
27
29
|
#
|
@@ -169,12 +171,14 @@ require 'axlsx/workbook/worksheet/data_validation.rb'
|
|
169
171
|
def self.date1904() @@date1904; end
|
170
172
|
|
171
173
|
# Indicates if the workbook should use autowidths or not.
|
172
|
-
#
|
174
|
+
# @note This gem no longer depends on RMagick for autowidth
|
175
|
+
# calculation. Thus the performance benefits of turning this off are
|
176
|
+
# marginal unless you are creating a very large sheet.
|
173
177
|
# @return [Boolean]
|
174
178
|
def use_autowidth() @use_autowidth; end
|
175
179
|
|
176
180
|
# see @use_autowidth
|
177
|
-
def use_autowidth=(v) Axlsx::validate_boolean v; @use_autowidth = v; end
|
181
|
+
def use_autowidth=(v=true) Axlsx::validate_boolean v; @use_autowidth = v; end
|
178
182
|
|
179
183
|
# Adds a worksheet to this workbook
|
180
184
|
# @return [Worksheet]
|
@@ -79,7 +79,7 @@ module Axlsx
|
|
79
79
|
# @see paper_width
|
80
80
|
def paper_width=(v); Axlsx::validate_number_with_unit(v); @paper_width = v; end
|
81
81
|
# @see scale
|
82
|
-
def scale=(v); Axlsx::
|
82
|
+
def scale=(v); Axlsx::validate_scale_10_400(v); @scale = v; end
|
83
83
|
|
84
84
|
# convenience method to achieve sanity when setting fit_to_width and fit_to_height
|
85
85
|
# as they both default to 1 if only their counterpart is specified.
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Axlsx
|
3
|
+
# Pane options for a worksheet.
|
4
|
+
#
|
5
|
+
# @note The recommended way to manage the pane options is via SheetView#pane
|
6
|
+
# @see SheetView#pane
|
7
|
+
class Pane
|
8
|
+
|
9
|
+
# Active Pane
|
10
|
+
# The pane that is active.
|
11
|
+
# Options are
|
12
|
+
# * bottom_left: Bottom left pane, when both vertical and horizontal
|
13
|
+
# splits are applied. This value is also used when only
|
14
|
+
# a horizontal split has been applied, dividing the pane
|
15
|
+
# into upper and lower regions. In that case, this value
|
16
|
+
# specifies the bottom pane.
|
17
|
+
# * bottom_right: Bottom right pane, when both vertical and horizontal
|
18
|
+
# splits are applied.
|
19
|
+
# * top_left: Top left pane, when both vertical and horizontal splits
|
20
|
+
# are applied. This value is also used when only a horizontal
|
21
|
+
# split has been applied, dividing the pane into upper and lower
|
22
|
+
# regions. In that case, this value specifies the top pane.
|
23
|
+
# This value is also used when only a vertical split has
|
24
|
+
# been applied, dividing the pane into right and left
|
25
|
+
# regions. In that case, this value specifies the left pane
|
26
|
+
# * top_right: Top right pane, when both vertical and horizontal
|
27
|
+
# splits are applied. This value is also used when only
|
28
|
+
# a vertical split has been applied, dividing the pane
|
29
|
+
# into right and left regions. In that case, this value
|
30
|
+
# specifies the right pane.
|
31
|
+
# @see type
|
32
|
+
# @return [Symbol]
|
33
|
+
# default nil
|
34
|
+
attr_reader :active_pane
|
35
|
+
|
36
|
+
|
37
|
+
# Split State
|
38
|
+
# Indicates whether the pane has horizontal / vertical
|
39
|
+
# splits, and whether those splits are frozen.
|
40
|
+
# Options are
|
41
|
+
# * frozen: Panes are frozen, but were not split being frozen. In
|
42
|
+
# this state, when the panes are unfrozen again, a single
|
43
|
+
# pane results, with no split. In this state, the split
|
44
|
+
# bars are not adjustable.
|
45
|
+
# * frozen_split: Panes are frozen and were split before being frozen. In
|
46
|
+
# this state, when the panes are unfrozen again, the split
|
47
|
+
# remains, but is adjustable.
|
48
|
+
# * split: Panes are split, but not frozen. In this state, the split
|
49
|
+
# bars are adjustable by the user.
|
50
|
+
# @see type
|
51
|
+
# @return [Symbol]
|
52
|
+
# default nil
|
53
|
+
attr_reader :state
|
54
|
+
|
55
|
+
|
56
|
+
# Top Left Visible Cell
|
57
|
+
# Location of the top left visible cell in the bottom
|
58
|
+
# right pane (when in Left-To-Right mode).
|
59
|
+
# @see type
|
60
|
+
# @return [String]
|
61
|
+
# default nil
|
62
|
+
attr_reader :top_left_cell
|
63
|
+
|
64
|
+
|
65
|
+
# Horizontal Split Position
|
66
|
+
# Horizontal position of the split, in 1/20th of a point; 0 (zero)
|
67
|
+
# if none. If the pane is frozen, this value indicates the number
|
68
|
+
# of columns visible in the top pane.
|
69
|
+
# @see type
|
70
|
+
# @return [Integer]
|
71
|
+
# default 0
|
72
|
+
attr_reader :x_split
|
73
|
+
|
74
|
+
|
75
|
+
# Vertical Split Position
|
76
|
+
# Vertical position of the split, in 1/20th of a point; 0 (zero)
|
77
|
+
# if none. If the pane is frozen, this value indicates the number
|
78
|
+
# of rows visible in the left pane.
|
79
|
+
# @see type
|
80
|
+
# @return [Integer]
|
81
|
+
# default 0
|
82
|
+
attr_reader :y_split
|
83
|
+
|
84
|
+
|
85
|
+
# Creates a new {Pane} object
|
86
|
+
# @option options [Symbol] active_pane Active Pane
|
87
|
+
# @option options [Symbol] state Split State
|
88
|
+
# @option options [Cell, String] top_left_cell Top Left Visible Cell
|
89
|
+
# @option options [Integer] x_split Horizontal Split Position
|
90
|
+
# @option options [Integer] y_split Vertical Split Position
|
91
|
+
def initialize(options={})
|
92
|
+
#defaults
|
93
|
+
@active_pane = @state = @top_left_cell = nil
|
94
|
+
@x_split = @y_split = 0
|
95
|
+
|
96
|
+
# write options to instance variables
|
97
|
+
options.each do |o|
|
98
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
# @see active_pane
|
104
|
+
def active_pane=(v); Axlsx::validate_pane_type(v); @active_pane = v end
|
105
|
+
|
106
|
+
|
107
|
+
# @see state
|
108
|
+
def state=(v); Axlsx::validate_split_state_type(v); @state = v end
|
109
|
+
|
110
|
+
|
111
|
+
# @see top_left_cell
|
112
|
+
def top_left_cell=(v)
|
113
|
+
cell = (v.class == Axlsx::Cell ? v.r_abs : v)
|
114
|
+
Axlsx::validate_string(cell)
|
115
|
+
@top_left_cell = cell
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
# @see x_split
|
120
|
+
def x_split=(v); Axlsx::validate_unsigned_int(v); @x_split = v end
|
121
|
+
|
122
|
+
|
123
|
+
# @see y_split
|
124
|
+
def y_split=(v); Axlsx::validate_unsigned_int(v); @y_split = v end
|
125
|
+
|
126
|
+
|
127
|
+
# Serializes the data validation
|
128
|
+
# @param [String] str
|
129
|
+
# @return [String]
|
130
|
+
def to_xml_string(str = '')
|
131
|
+
if @state == :frozen && @top_left_cell.nil?
|
132
|
+
row = @y_split || 0
|
133
|
+
column = @x_split || 0
|
134
|
+
|
135
|
+
@top_left_cell = "#{('A'..'ZZ').to_a[column]}#{row+1}"
|
136
|
+
end
|
137
|
+
|
138
|
+
str << '<pane '
|
139
|
+
str << instance_values.map { |key, value| '' << key.gsub(/_(.)/){ $1.upcase } <<
|
140
|
+
%{="#{[:active_pane, :state].include?(key.to_sym) ? value.to_s.gsub(/_(.)/){ $1.upcase } : value}"} unless value.nil? }.join(' ')
|
141
|
+
str << '/>'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Axlsx
|
3
|
+
# Selection options for worksheet panes.
|
4
|
+
#
|
5
|
+
# @note The recommended way to manage the selection pane options is via SheetView#add_selection
|
6
|
+
# @see SheetView#add_selection
|
7
|
+
class Selection
|
8
|
+
|
9
|
+
# Active Cell Location
|
10
|
+
# Location of the active cell.
|
11
|
+
# @see type
|
12
|
+
# @return [String]
|
13
|
+
# default nil
|
14
|
+
attr_reader :active_cell
|
15
|
+
|
16
|
+
|
17
|
+
# Active Cell Index
|
18
|
+
# 0-based index of the range reference (in the array of references listed in sqref)
|
19
|
+
# containing the active cell. Only used when the selection in sqref is not contiguous.
|
20
|
+
# Therefore, this value needs to be aware of the order in which the range references are
|
21
|
+
# written in sqref.
|
22
|
+
# When this value is out of range then activeCell can be used.
|
23
|
+
# @see type
|
24
|
+
# @return [Integer]
|
25
|
+
# default nil
|
26
|
+
attr_reader :active_cell_id
|
27
|
+
|
28
|
+
|
29
|
+
# Pane
|
30
|
+
# The pane to which this selection belongs.
|
31
|
+
# Options are
|
32
|
+
# * bottom_left: Bottom left pane, when both vertical and horizontal
|
33
|
+
# splits are applied. This value is also used when only
|
34
|
+
# a horizontal split has been applied, dividing the pane
|
35
|
+
# into upper and lower regions. In that case, this value
|
36
|
+
# specifies the bottom pane.
|
37
|
+
# * bottom_right: Bottom right pane, when both vertical and horizontal
|
38
|
+
# splits are applied.
|
39
|
+
# * top_left: Top left pane, when both vertical and horizontal splits
|
40
|
+
# are applied. This value is also used when only a horizontal
|
41
|
+
# split has been applied, dividing the pane into upper and lower
|
42
|
+
# regions. In that case, this value specifies the top pane.
|
43
|
+
# This value is also used when only a vertical split has
|
44
|
+
# been applied, dividing the pane into right and left
|
45
|
+
# regions. In that case, this value specifies the left pane
|
46
|
+
# * top_right: Top right pane, when both vertical and horizontal
|
47
|
+
# splits are applied. This value is also used when only
|
48
|
+
# a vertical split has been applied, dividing the pane
|
49
|
+
# into right and left regions. In that case, this value
|
50
|
+
# specifies the right pane.
|
51
|
+
# @see type
|
52
|
+
# @return [Symbol]
|
53
|
+
# default nil
|
54
|
+
attr_reader :pane
|
55
|
+
|
56
|
+
|
57
|
+
# Sequence of References
|
58
|
+
# Range of the selection. Can be non-contiguous set of ranges.
|
59
|
+
# @see type
|
60
|
+
# @return [String]
|
61
|
+
# default nil
|
62
|
+
attr_reader :sqref
|
63
|
+
|
64
|
+
|
65
|
+
# Creates a new {Selection} object
|
66
|
+
# @option options [Cell, String] active_cell Active Cell Location
|
67
|
+
# @option options [Integer] active_cell_id Active Cell Index
|
68
|
+
# @option options [Symbol] pane Pane
|
69
|
+
# @option options [String] sqref Sequence of References
|
70
|
+
def initialize(options={})
|
71
|
+
#defaults
|
72
|
+
@active_cell = @active_cell_id = @pane = @sqref = nil
|
73
|
+
|
74
|
+
# write options to instance variables
|
75
|
+
options.each do |o|
|
76
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
# @see active_cell
|
82
|
+
def active_cell=(v)
|
83
|
+
cell = (v.class == Axlsx::Cell ? v.r_abs : v)
|
84
|
+
Axlsx::validate_string(cell)
|
85
|
+
@active_cell = cell
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
# @see active_cell_id
|
90
|
+
def active_cell_id=(v); Axlsx::validate_unsigned_int(v); @active_cell_id = v end
|
91
|
+
|
92
|
+
|
93
|
+
# @see pane
|
94
|
+
def pane=(v); Axlsx::validate_pane_type(v); @pane = v end
|
95
|
+
|
96
|
+
|
97
|
+
# @see sqref
|
98
|
+
def sqref=(v); Axlsx::validate_string(v); @sqref = v end
|
99
|
+
|
100
|
+
|
101
|
+
# Serializes the data validation
|
102
|
+
# @param [String] str
|
103
|
+
# @return [String]
|
104
|
+
def to_xml_string(str = '')
|
105
|
+
str << '<selection '
|
106
|
+
str << instance_values.map { |key, value| '' << key.gsub(/_(.)/){ $1.upcase } <<
|
107
|
+
%{="#{[:pane].include?(key.to_sym) ? value.to_s.gsub(/_(.)/){ $1.upcase } : value}"} unless value.nil? }.join(' ')
|
108
|
+
str << '/>'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
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
|