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,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,63 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# Options for printing a worksheet. All options are boolean and false by default.
|
|
3
|
+
#
|
|
4
|
+
# @note The recommended way to manage print options is via Worksheet#print_options
|
|
5
|
+
# @see Worksheet#print_options
|
|
6
|
+
# @see Worksheet#initialize
|
|
7
|
+
class PrintOptions
|
|
8
|
+
|
|
9
|
+
# Whether grid lines should be printed.
|
|
10
|
+
# @return [Boolean]
|
|
11
|
+
attr_reader :grid_lines
|
|
12
|
+
|
|
13
|
+
# Whether row and column headings should be printed.
|
|
14
|
+
# @return [Boolean]
|
|
15
|
+
attr_reader :headings
|
|
16
|
+
|
|
17
|
+
# Whether the content should be centered horizontally on the page.
|
|
18
|
+
# @return [Boolean]
|
|
19
|
+
attr_reader :horizontal_centered
|
|
20
|
+
|
|
21
|
+
# Whether the content should be centered vertically on the page.
|
|
22
|
+
# @return [Boolean]
|
|
23
|
+
attr_reader :vertical_centered
|
|
24
|
+
|
|
25
|
+
# Creates a new PrintOptions object
|
|
26
|
+
# @option options [Boolean] grid_lines Whether grid lines should be printed
|
|
27
|
+
# @option options [Boolean] headings Whether row and column headings should be printed
|
|
28
|
+
# @option options [Boolean] horizontal_centered Whether the content should be centered horizontally
|
|
29
|
+
# @option options [Boolean] vertical_centered Whether the content should be centered vertically
|
|
30
|
+
def initialize(options = {})
|
|
31
|
+
@grid_lines = @headings = @horizontal_centered = @vertical_centered = false
|
|
32
|
+
set(options)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Set some or all options at once.
|
|
36
|
+
# @param [Hash] options The options to set (possible keys are :grid_lines, :headings, :horizontal_centered, and :vertical_centered).
|
|
37
|
+
def set(options)
|
|
38
|
+
options.each do |k, v|
|
|
39
|
+
send("#{k}=", v) if respond_to? "#{k}="
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @see grid_lines
|
|
44
|
+
def grid_lines=(v); Axlsx::validate_boolean(v); @grid_lines = v; end
|
|
45
|
+
# @see headings
|
|
46
|
+
def headings=(v); Axlsx::validate_boolean(v); @headings = v; end
|
|
47
|
+
# @see horizontal_centered
|
|
48
|
+
def horizontal_centered=(v); Axlsx::validate_boolean(v); @horizontal_centered = v; end
|
|
49
|
+
# @see vertical_centered
|
|
50
|
+
def vertical_centered=(v); Axlsx::validate_boolean(v); @vertical_centered = v; end
|
|
51
|
+
|
|
52
|
+
# Serializes the page options element.
|
|
53
|
+
# @note As all attributes default to "false" according to the xml schema definition, the generated xml includes only those attributes that are set to true.
|
|
54
|
+
# @param [String] str
|
|
55
|
+
# @return [String]
|
|
56
|
+
def to_xml_string(str = '')
|
|
57
|
+
str << '<printOptions '
|
|
58
|
+
#
|
|
59
|
+
str << instance_values.select{ |k,v| v == true }.map{ |k,v| k.gsub(/_(.)/){ $1.upcase } << %{="#{v}"} }.join(' ')
|
|
60
|
+
str << '/>'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# The Protected Range class represents a set of cells in the worksheet
|
|
3
|
+
# @note the recommended way to manage protected ranges with via Worksheet#protect_range
|
|
4
|
+
# @see Worksheet#protect_range
|
|
5
|
+
class ProtectedRange
|
|
6
|
+
|
|
7
|
+
# The reference for the protected range
|
|
8
|
+
# @return [String]
|
|
9
|
+
attr_reader :sqref
|
|
10
|
+
|
|
11
|
+
# The name of the protected range
|
|
12
|
+
# @return [String]
|
|
13
|
+
attr_reader :name
|
|
14
|
+
|
|
15
|
+
# Initializes a new protected range object
|
|
16
|
+
# @option [String] sqref The cell range reference to protect. This can be an absolute or a relateve range however, it only applies to the current sheet.
|
|
17
|
+
# @option [String] name An optional name for the protected name.
|
|
18
|
+
def initialize(options={})
|
|
19
|
+
options.each do |o|
|
|
20
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
21
|
+
end
|
|
22
|
+
yield self if block_given?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @see sqref
|
|
26
|
+
def sqref=(v)
|
|
27
|
+
Axlsx.validate_string(v)
|
|
28
|
+
@sqref = v
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @see name
|
|
32
|
+
def name=(v)
|
|
33
|
+
Axlsx.validate_string(v)
|
|
34
|
+
@name = v
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# serializes the proteted range
|
|
38
|
+
# @param [String] str if this string object is provided we append
|
|
39
|
+
# our output to that object. Use this - it helps limit the number of
|
|
40
|
+
# objects created during serialization
|
|
41
|
+
def to_xml_string(str="")
|
|
42
|
+
attrs = self.instance_values.reject{ |key, value| value == nil }
|
|
43
|
+
str << '<protectedRange ' << attrs.map { |key, value| '' << key << '="' << value.to_s << '"' }.join(' ') << '/>'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# A self serializing collection of ranges that should be protected in
|
|
4
|
+
# the worksheet
|
|
5
|
+
class ProtectedRanges < SimpleTypedList
|
|
6
|
+
|
|
7
|
+
attr_reader :worksheet
|
|
8
|
+
|
|
9
|
+
def initialize(worksheet)
|
|
10
|
+
raise ArgumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet)
|
|
11
|
+
super ProtectedRange
|
|
12
|
+
@worksheet = worksheet
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Adds a protected range
|
|
16
|
+
# @param [Array|String] cells A string range reference or array of cells that will be protected
|
|
17
|
+
def add_range(cells)
|
|
18
|
+
sqref = if cells.is_a?(String)
|
|
19
|
+
cells
|
|
20
|
+
elsif cells.is_a?(SimpleTypedList) || cells.is_a?(Array)
|
|
21
|
+
Axlsx::cell_range(cells, false)
|
|
22
|
+
end
|
|
23
|
+
@list << ProtectedRange.new(:sqref => sqref, :name => "Range#{size}")
|
|
24
|
+
last
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_xml_string(str = '')
|
|
28
|
+
return if empty?
|
|
29
|
+
str << '<protectedRanges>'
|
|
30
|
+
each { |range| range.to_xml_string(str) }
|
|
31
|
+
str << '</protectedRanges>'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -5,7 +5,16 @@ module Axlsx
|
|
|
5
5
|
# @see Worksheet#add_row
|
|
6
6
|
class Row
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# No support is provided for the following attributes
|
|
9
|
+
# spans
|
|
10
|
+
# thickTop
|
|
11
|
+
# thickBottom
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# A list of serilizable attributes.
|
|
15
|
+
# @note height(ht) and customHeight are manages separately for now. Have a look at Row#height
|
|
16
|
+
SERIALIZABLE_ATTRIBUTES = [:hidden, :outlineLevel, :collapsed, :s, :customFormat, :ph]
|
|
17
|
+
|
|
9
18
|
# The worksheet this row belongs to
|
|
10
19
|
# @return [Worksheet]
|
|
11
20
|
attr_reader :worksheet
|
|
@@ -14,38 +23,40 @@ module Axlsx
|
|
|
14
23
|
# @return [SimpleTypedList]
|
|
15
24
|
attr_reader :cells
|
|
16
25
|
|
|
17
|
-
#
|
|
26
|
+
# Row height measured in point size. There is no margin padding on row height.
|
|
18
27
|
# @return [Float]
|
|
19
28
|
attr_reader :height
|
|
20
29
|
|
|
21
|
-
# Flag indicating if the outlining of
|
|
30
|
+
# Flag indicating if the outlining of row.
|
|
22
31
|
# @return [Boolean]
|
|
23
32
|
attr_reader :collapsed
|
|
24
33
|
|
|
25
|
-
# Flag indicating if the
|
|
34
|
+
# Flag indicating if the the row is hidden.
|
|
26
35
|
# @return [Boolean]
|
|
27
36
|
attr_reader :hidden
|
|
28
37
|
|
|
29
|
-
#
|
|
38
|
+
# Outlining level of the row, when outlining is on
|
|
30
39
|
# @return [Integer]
|
|
31
40
|
attr_reader :outlineLevel
|
|
32
41
|
|
|
33
|
-
#
|
|
42
|
+
# The style applied ot the row. This affects the entire row.
|
|
34
43
|
# @return [Integer]
|
|
35
|
-
attr_reader :
|
|
36
|
-
|
|
37
|
-
# TODO 18.3.1.73
|
|
38
|
-
# # collapsed
|
|
39
|
-
# customFormat
|
|
40
|
-
# # hidden
|
|
41
|
-
# # outlineLevel
|
|
42
|
-
# ph
|
|
43
|
-
# # s (style)
|
|
44
|
-
# spans
|
|
45
|
-
# thickTop
|
|
46
|
-
# thickBottom
|
|
44
|
+
attr_reader :s
|
|
47
45
|
|
|
46
|
+
# indicates that a style has been applied directly to the row via Row#s
|
|
47
|
+
# @return [Boolean]
|
|
48
|
+
attr_reader :customFormat
|
|
48
49
|
|
|
50
|
+
# indicates if the row should show phonetic
|
|
51
|
+
# @return [Boolean]
|
|
52
|
+
attr_reader :ph
|
|
53
|
+
|
|
54
|
+
# NOTE removing this from the api as it is actually incorrect.
|
|
55
|
+
# having a method to style a row's cells is fine, but it is not an attribute on the row.
|
|
56
|
+
# The proper attribute is ':s'
|
|
57
|
+
# attr_reader style
|
|
58
|
+
#
|
|
59
|
+
|
|
49
60
|
# Creates a new row. New Cell objects are created based on the values, types and style options.
|
|
50
61
|
# A new cell is created for each item in the values array. style and types options are applied as follows:
|
|
51
62
|
# If the types option is defined and is a symbol it is applied to all the cells created.
|
|
@@ -81,6 +92,12 @@ module Axlsx
|
|
|
81
92
|
Axlsx.validate_boolean(v)
|
|
82
93
|
@hidden = v
|
|
83
94
|
end
|
|
95
|
+
|
|
96
|
+
# @see Row#ph
|
|
97
|
+
def ph=(v) Axlsx.validate_boolean(v); @ph = v end
|
|
98
|
+
|
|
99
|
+
# @see Row#s
|
|
100
|
+
def s=(v) Axlsx.validate_unsigned_numeric(v); @s = v; @customFormat = true end
|
|
84
101
|
|
|
85
102
|
# @see Row#outline
|
|
86
103
|
def outlineLevel=(v)
|
|
@@ -88,7 +105,6 @@ module Axlsx
|
|
|
88
105
|
@outlineLevel = v
|
|
89
106
|
end
|
|
90
107
|
|
|
91
|
-
|
|
92
108
|
# The index of this row in the worksheet
|
|
93
109
|
# @return [Integer]
|
|
94
110
|
def index
|
|
@@ -118,7 +134,7 @@ module Axlsx
|
|
|
118
134
|
# @return [Cell]
|
|
119
135
|
def add_cell(value="", options={})
|
|
120
136
|
c = Cell.new(self, value, options)
|
|
121
|
-
worksheet.send(:update_column_info, self.cells, []
|
|
137
|
+
worksheet.send(:update_column_info, self.cells, [])
|
|
122
138
|
c
|
|
123
139
|
end
|
|
124
140
|
|
|
@@ -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,49 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# the SheetCalcPr object for the worksheet
|
|
4
|
+
# This object contains calculation properties for the worksheet.
|
|
5
|
+
class SheetCalcPr
|
|
6
|
+
|
|
7
|
+
# creates a new SheetCalcPr
|
|
8
|
+
# @param [Hash] options Options for this object
|
|
9
|
+
# @option [Boolean] full_calc_on_load @see full_calc_on_load
|
|
10
|
+
def initialize(options={})
|
|
11
|
+
@full_calc_on_load = true
|
|
12
|
+
options.each do |key, value|
|
|
13
|
+
self.send("#{key}=", value) if self.respond_to?("#{key}=")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Indicates whether the application should do a full calculate on
|
|
18
|
+
# load due to contents on this sheet. After load and successful cal,c
|
|
19
|
+
# the application shall set this value to false. Set this to true
|
|
20
|
+
# when the application should calculate the workbook on load.
|
|
21
|
+
# @return [Boolean]
|
|
22
|
+
def full_calc_on_load
|
|
23
|
+
@full_calc_on_load
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# specify the full_calc_on_load value
|
|
27
|
+
# @param [Boolean] value
|
|
28
|
+
# @see full_calc_on_load
|
|
29
|
+
def full_calc_on_load=(value)
|
|
30
|
+
Axlsx.validate_boolean(value)
|
|
31
|
+
@full_calc_on_load = value
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Serialize the object
|
|
35
|
+
# @param [String] str the string to append this objects serialized
|
|
36
|
+
# content to.
|
|
37
|
+
# @return [String]
|
|
38
|
+
def to_xml_string(str='')
|
|
39
|
+
str << "<sheetCalcPr #{serialized_attributes}/>"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def serialized_attributes
|
|
45
|
+
instance_values.map { |key, value| "#{Axlsx.camel(key, false)}='#{value}'" }.join(' ')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# This class manages the serialization of rows for worksheets
|
|
4
|
+
class SheetData
|
|
5
|
+
|
|
6
|
+
# Creates a new SheetData object
|
|
7
|
+
# @param [Worksheet] worksheet The worksheet that owns this sheet data.
|
|
8
|
+
def initialize(worksheet)
|
|
9
|
+
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
|
10
|
+
@worksheet = worksheet
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
attr_reader :worksheet
|
|
14
|
+
|
|
15
|
+
# Serialize the sheet data
|
|
16
|
+
# @param [String] str the string this objects serializaton will be concacted to.
|
|
17
|
+
# @return [String]
|
|
18
|
+
def to_xml_string(str = '')
|
|
19
|
+
str << '<sheetData>'
|
|
20
|
+
worksheet.rows.each_with_index{ |row, index| row.to_xml_string(index, str) }
|
|
21
|
+
str << '</sheetData>'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# The SheetPr class manages serialization fo a worksheet's sheetPr element.
|
|
4
|
+
class SheetPr
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# These attributes are all boolean so I'm doing a bit of a hand
|
|
8
|
+
# waving magic show to set up the attriubte accessors
|
|
9
|
+
BOOLEAN_ATTRIBUTES = [:sync_horizontal,
|
|
10
|
+
:sync_vertical,
|
|
11
|
+
:transtion_evaluation,
|
|
12
|
+
:transition_entry,
|
|
13
|
+
:published,
|
|
14
|
+
:filter_mode,
|
|
15
|
+
:enable_format_conditions_calculation]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Creates a new SheetPr object
|
|
19
|
+
# @param [Worksheet] worksheet The worksheet that owns this SheetPr object
|
|
20
|
+
def initialize(worksheet, options={})
|
|
21
|
+
raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
|
|
22
|
+
@worksheet = worksheet
|
|
23
|
+
options.each do |key, value|
|
|
24
|
+
attr = "#{key}="
|
|
25
|
+
self.send(attr, value) if self.respond_to?(attr)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Dynamically create accessors for boolean attriubtes
|
|
30
|
+
BOOLEAN_ATTRIBUTES.each do |attr|
|
|
31
|
+
class_eval %{
|
|
32
|
+
# The #{attr} attribute reader
|
|
33
|
+
# @return [Boolean]
|
|
34
|
+
attr_reader :#{attr}
|
|
35
|
+
|
|
36
|
+
# The #{attr} writer
|
|
37
|
+
# @param [Boolean] value The value to assign to #{attr}
|
|
38
|
+
# @return [Boolean]
|
|
39
|
+
def #{attr}=(value)
|
|
40
|
+
Axlsx::validate_boolean(value)
|
|
41
|
+
@#{attr} = value
|
|
42
|
+
end
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Anchor point for worksheet's window.
|
|
47
|
+
# @return [String]
|
|
48
|
+
attr_reader :code_name
|
|
49
|
+
|
|
50
|
+
# Specifies a stable name of the sheet, which should not change over time,
|
|
51
|
+
# and does not change from user input. This name should be used by code
|
|
52
|
+
# to reference a particular sheet.
|
|
53
|
+
# @return [String]
|
|
54
|
+
attr_reader :sync_ref
|
|
55
|
+
|
|
56
|
+
# The worksheet these properties apply to!
|
|
57
|
+
# @return [Worksheet]
|
|
58
|
+
attr_reader :worksheet
|
|
59
|
+
|
|
60
|
+
# @see code_name
|
|
61
|
+
# @param [String] name
|
|
62
|
+
def code_name=(name)
|
|
63
|
+
@code_name = name
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @see sync_ref
|
|
67
|
+
# @param [String] ref A cell reference (e.g. "A1")
|
|
68
|
+
def sync_ref=(ref)
|
|
69
|
+
@sync_ref = ref
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Serialize the object
|
|
73
|
+
# @param [String] str serialized output will be appended to this object if provided.
|
|
74
|
+
# @return [String]
|
|
75
|
+
def to_xml_string(str = '')
|
|
76
|
+
update_properties
|
|
77
|
+
str << "<sheetPr #{serialized_attributes}>"
|
|
78
|
+
page_setup_pr.to_xml_string(str)
|
|
79
|
+
str << "</sheetPr>"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# The PageSetUpPr for this sheet pr object
|
|
83
|
+
# @return [PageSetUpPr]
|
|
84
|
+
def page_setup_pr
|
|
85
|
+
@page_setup_pr ||= PageSetUpPr.new
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def serialized_attributes(str = '')
|
|
91
|
+
instance_values.each do |key, value|
|
|
92
|
+
unless %(worksheet page_setup_pr).include? key
|
|
93
|
+
str << "#{Axlsx.camel(key, false)}='#{value}' "
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
str
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def update_properties
|
|
100
|
+
page_setup_pr.fit_to_page = worksheet.fit_to_page?
|
|
101
|
+
if worksheet.auto_filter.columns.size > 0
|
|
102
|
+
self.filter_mode = 1
|
|
103
|
+
self.enable_format_conditions_calculation = 1
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|