axlsx 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +3 -2
- data/.yardopts_guide +19 -0
- data/CHANGELOG.md +64 -1
- data/README.md +105 -87
- data/Rakefile +0 -5
- data/examples/2010_comments.rb +17 -0
- data/examples/anchor_swapping.rb +28 -0
- data/examples/auto_filter.rb +16 -0
- data/examples/basic_charts.rb +4 -0
- data/examples/colored_links.rb +59 -0
- data/examples/conditional_formatting/example_conditional_formatting.rb +4 -2
- data/examples/example.rb +569 -258
- data/examples/ios_preview.rb +14 -0
- data/examples/page_setup.rb +11 -0
- data/examples/pivot_table.rb +39 -0
- data/examples/skydrive/real_example.rb +8 -8
- data/examples/styles.rb +66 -0
- data/examples/underline.rb +13 -0
- data/examples/wrap_text.rb +21 -0
- 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 +10 -7
- data/lib/axlsx/doc_props/core.rb +6 -1
- data/lib/axlsx/drawing/axes.rb +61 -0
- data/lib/axlsx/drawing/axis.rb +20 -17
- data/lib/axlsx/drawing/bar_3D_chart.rb +31 -22
- data/lib/axlsx/drawing/cat_axis.rb +2 -10
- data/lib/axlsx/drawing/chart.rb +33 -6
- data/lib/axlsx/drawing/d_lbls.rb +21 -31
- data/lib/axlsx/drawing/drawing.rb +11 -17
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +42 -36
- data/lib/axlsx/drawing/line_3D_chart.rb +28 -70
- data/lib/axlsx/drawing/line_chart.rb +99 -0
- data/lib/axlsx/drawing/line_series.rb +20 -2
- data/lib/axlsx/drawing/marker.rb +38 -18
- 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 +28 -21
- data/lib/axlsx/drawing/pic.rb +43 -45
- data/lib/axlsx/drawing/picture_locking.rb +12 -44
- data/lib/axlsx/drawing/pie_3D_chart.rb +2 -1
- data/lib/axlsx/drawing/scaling.rb +13 -13
- data/lib/axlsx/drawing/scatter_chart.rb +32 -21
- data/lib/axlsx/drawing/ser_axis.rb +15 -16
- 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/two_cell_anchor.rb +7 -27
- data/lib/axlsx/drawing/val_axis.rb +14 -13
- data/lib/axlsx/drawing/view_3D.rb +52 -38
- data/lib/axlsx/drawing/vml_shape.rb +20 -79
- data/lib/axlsx/package.rb +58 -28
- data/lib/axlsx/rels/relationship.rb +75 -9
- data/lib/axlsx/rels/relationships.rb +8 -1
- 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 +20 -17
- 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 +23 -14
- data/lib/axlsx/stylesheet/pattern_fill.rb +12 -21
- data/lib/axlsx/stylesheet/styles.rb +37 -22
- 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 +64 -0
- data/lib/axlsx/util/constants.rb +127 -6
- data/lib/axlsx/util/options_parser.rb +15 -0
- data/lib/axlsx/util/serialized_attributes.rb +79 -0
- data/lib/axlsx/util/simple_typed_list.rb +50 -15
- data/lib/axlsx/util/validators.rb +51 -16
- data/lib/axlsx/version.rb +2 -2
- data/lib/axlsx/workbook/defined_name.rb +14 -59
- data/lib/axlsx/workbook/shared_strings_table.rb +13 -4
- data/lib/axlsx/workbook/workbook.rb +85 -6
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +94 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +246 -0
- data/lib/axlsx/workbook/worksheet/break.rb +37 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +109 -107
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +144 -0
- data/lib/axlsx/workbook/worksheet/cfvo.rb +15 -15
- data/lib/axlsx/workbook/worksheet/cfvos.rb +15 -0
- data/lib/axlsx/workbook/worksheet/col.rb +43 -29
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +35 -0
- data/lib/axlsx/workbook/worksheet/color_scale.rb +62 -28
- data/lib/axlsx/workbook/worksheet/comment.rb +28 -37
- data/lib/axlsx/workbook/worksheet/comments.rb +3 -3
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +11 -11
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +31 -27
- data/lib/axlsx/workbook/worksheet/data_bar.rb +75 -41
- data/lib/axlsx/workbook/worksheet/data_validation.rb +61 -62
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +6 -5
- data/lib/axlsx/workbook/worksheet/dimension.rb +0 -1
- data/lib/axlsx/workbook/worksheet/header_footer.rb +54 -0
- 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 +44 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +152 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +48 -51
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +273 -0
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +66 -0
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +24 -0
- 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/row.rb +59 -83
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +33 -0
- data/lib/axlsx/workbook/worksheet/selection.rb +30 -38
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +29 -0
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +60 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +49 -4
- 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 +25 -19
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +51 -0
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +174 -35
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -5
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +4 -10
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +74 -0
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
- data/lib/axlsx.rb +55 -5
- data/lib/schema/sml.xsd +4 -0
- data/test/axlsx.qcachegrind +2226 -0
- data/test/benchmark.rb +2 -3
- data/test/content_type/tc_default.rb +0 -11
- data/test/content_type/tc_override.rb +0 -13
- data/test/doc_props/tc_core.rb +7 -0
- data/test/drawing/tc_axes.rb +8 -0
- data/test/drawing/tc_axis.rb +15 -17
- data/test/drawing/tc_bar_3D_chart.rb +6 -0
- data/test/drawing/tc_cat_axis.rb +9 -9
- data/test/drawing/tc_chart.rb +20 -0
- data/test/drawing/tc_d_lbls.rb +14 -4
- data/test/drawing/tc_drawing.rb +0 -5
- data/test/drawing/tc_graphic_frame.rb +5 -3
- data/test/drawing/tc_hyperlink.rb +0 -4
- data/test/drawing/tc_line_chart.rb +39 -0
- data/test/drawing/tc_line_series.rb +8 -2
- data/test/drawing/tc_pic.rb +14 -3
- data/test/drawing/tc_ser_axis.rb +13 -12
- data/test/drawing/tc_two_cell_anchor.rb +3 -3
- data/test/drawing/tc_val_axis.rb +6 -6
- data/test/drawing/tc_vml_shape.rb +9 -3
- data/test/profile.rb +11 -21
- data/test/rels/tc_relationship.rb +32 -9
- data/test/rels/tc_relationships.rb +12 -1
- data/test/stylesheet/tc_color.rb +6 -0
- data/test/stylesheet/tc_styles.rb +15 -2
- data/test/tc_axlsx.rb +35 -2
- data/test/tc_helper.rb +7 -1
- data/test/tc_package.rb +44 -5
- data/test/util/tc_serialized_attributes.rb +19 -0
- data/test/util/tc_validators.rb +26 -1
- data/test/workbook/tc_defined_name.rb +2 -2
- data/test/workbook/tc_shared_strings_table.rb +6 -0
- data/test/workbook/tc_workbook.rb +38 -1
- 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_break.rb +49 -0
- data/test/workbook/worksheet/tc_cell.rb +40 -6
- data/test/workbook/worksheet/tc_col.rb +11 -1
- data/test/workbook/worksheet/tc_color_scale.rb +31 -2
- data/test/workbook/worksheet/tc_comment.rb +21 -6
- data/test/workbook/worksheet/tc_comments.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +7 -0
- data/test/workbook/worksheet/tc_data_bar.rb +7 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +3 -11
- data/test/workbook/worksheet/tc_header_footer.rb +151 -0
- data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
- data/test/workbook/worksheet/tc_page_setup.rb +6 -1
- data/test/workbook/worksheet/tc_pane.rb +5 -45
- data/test/workbook/worksheet/tc_pivot_table.rb +120 -0
- data/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +54 -0
- data/test/workbook/worksheet/tc_row.rb +4 -4
- data/test/workbook/worksheet/tc_selection.rb +9 -48
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +88 -0
- data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +39 -39
- data/test/workbook/worksheet/{table/tc_table.rb → tc_table.rb} +8 -3
- data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
- data/test/workbook/worksheet/tc_worksheet.rb +131 -16
- data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +55 -0
- metadata +97 -64
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.pdf +0 -0
- data/examples/image1.gif +0 -0
- data/examples/image1.jpg +0 -0
- data/examples/image1.png +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/sample.png +0 -0
- data/examples/scraping_html.rb +0 -91
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_view.rb +0 -34
- data/examples/two_cell_anchor_image.rb +0 -11
- data/lib/axlsx/workbook/worksheet/auto_filter.rb +0 -34
|
@@ -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|
|
|
@@ -5,18 +5,7 @@ module Axlsx
|
|
|
5
5
|
# @see README for examples
|
|
6
6
|
class Table
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
# The reference to the table data
|
|
10
|
-
# @return [String]
|
|
11
|
-
attr_reader :ref
|
|
12
|
-
|
|
13
|
-
# The name of the table.
|
|
14
|
-
# @return [String]
|
|
15
|
-
attr_reader :name
|
|
16
|
-
|
|
17
|
-
# The style for the table.
|
|
18
|
-
# @return [TableStyle]
|
|
19
|
-
attr_reader :style
|
|
8
|
+
include Axlsx::OptionsParser
|
|
20
9
|
|
|
21
10
|
# Creates a new Table object
|
|
22
11
|
# @param [String] ref The reference to the table data like 'A1:G24'.
|
|
@@ -28,13 +17,24 @@ module Axlsx
|
|
|
28
17
|
@sheet = sheet
|
|
29
18
|
@style = nil
|
|
30
19
|
@sheet.workbook.tables << self
|
|
20
|
+
@table_style_info = TableStyleInfo.new(options[:style_info]) if options[:style_info]
|
|
31
21
|
@name = "Table#{index+1}"
|
|
32
|
-
options
|
|
33
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
34
|
-
end
|
|
22
|
+
parse_options options
|
|
35
23
|
yield self if block_given?
|
|
36
24
|
end
|
|
37
25
|
|
|
26
|
+
# The reference to the table data
|
|
27
|
+
# @return [String]
|
|
28
|
+
attr_reader :ref
|
|
29
|
+
|
|
30
|
+
# The name of the table.
|
|
31
|
+
# @return [String]
|
|
32
|
+
attr_reader :name
|
|
33
|
+
|
|
34
|
+
# The style for the table.
|
|
35
|
+
# @return [TableStyle]
|
|
36
|
+
attr_reader :style
|
|
37
|
+
|
|
38
38
|
# The index of this chart in the workbooks charts collection
|
|
39
39
|
# @return [Integer]
|
|
40
40
|
def index
|
|
@@ -47,10 +47,11 @@ module Axlsx
|
|
|
47
47
|
"#{TABLE_PN % (index+1)}"
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
# The
|
|
50
|
+
# The relationship id for this table.
|
|
51
|
+
# @see Relationship#Id
|
|
51
52
|
# @return [String]
|
|
52
53
|
def rId
|
|
53
|
-
|
|
54
|
+
@sheet.relationships.for(self).Id
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
# The name of the Table.
|
|
@@ -63,6 +64,12 @@ module Axlsx
|
|
|
63
64
|
end
|
|
64
65
|
end
|
|
65
66
|
|
|
67
|
+
# TableStyleInfo for the table.
|
|
68
|
+
# initialization can be fed via the :style_info option
|
|
69
|
+
def table_style_info
|
|
70
|
+
@table_style_info ||= TableStyleInfo.new
|
|
71
|
+
end
|
|
72
|
+
|
|
66
73
|
# Serializes the object
|
|
67
74
|
# @param [String] str
|
|
68
75
|
# @return [String]
|
|
@@ -76,8 +83,7 @@ module Axlsx
|
|
|
76
83
|
str << '<tableColumn id ="' << (index+1).to_s << '" name="' << cell.value << '"/>'
|
|
77
84
|
end
|
|
78
85
|
str << '</tableColumns>'
|
|
79
|
-
|
|
80
|
-
str << '<tableStyleInfo showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0" name="TableStyleMedium9" />'
|
|
86
|
+
table_style_info.to_xml_string(str)
|
|
81
87
|
str << '</table>'
|
|
82
88
|
end
|
|
83
89
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
|
|
3
|
+
# The table style info class manages style attributes for defined tables in
|
|
4
|
+
# a worksheet
|
|
5
|
+
class TableStyleInfo
|
|
6
|
+
include Axlsx::OptionsParser
|
|
7
|
+
include Axlsx::SerializedAttributes
|
|
8
|
+
include Axlsx::Accessors
|
|
9
|
+
# creates a new TableStyleInfo instance
|
|
10
|
+
# @param [Hash] options
|
|
11
|
+
# @option [Boolean] show_first_column indicates if the first column should
|
|
12
|
+
# be shown
|
|
13
|
+
# @option [Boolean] show_last_column indicates if the last column should
|
|
14
|
+
# be shown
|
|
15
|
+
# @option [Boolean] show_column_stripes indicates if column stripes should
|
|
16
|
+
# be shown
|
|
17
|
+
# @option [Boolean] show_row_stripes indicates if row stripes should be shown
|
|
18
|
+
# @option [String] name The name of the style to apply to your table.
|
|
19
|
+
# Only predefined styles are currently supported.
|
|
20
|
+
# @see Annex G. (normative) Predefined SpreadsheetML Style Definitions in part 1 of the specification.
|
|
21
|
+
def initialize(options = {})
|
|
22
|
+
initialize_defaults
|
|
23
|
+
@name = 'TableStyleMedium9'
|
|
24
|
+
parse_options options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# boolean attributes for this object
|
|
28
|
+
boolean_attr_accessor :show_first_column, :show_last_column, :show_row_stripes, :show_column_stripes
|
|
29
|
+
serializable_attributes :show_first_column, :show_last_column, :show_row_stripes, :show_column_stripes,
|
|
30
|
+
:name
|
|
31
|
+
|
|
32
|
+
# Initialize all the values to false as Excel requires them to
|
|
33
|
+
# explicitly be disabled or all will show.
|
|
34
|
+
def initialize_defaults
|
|
35
|
+
%w(show_first_column show_last_column show_row_stripes show_column_stripes).each do |attr|
|
|
36
|
+
self.send("#{attr}=", 0)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The name of the table style.
|
|
41
|
+
attr_accessor :name
|
|
42
|
+
|
|
43
|
+
# seralizes this object to an xml string
|
|
44
|
+
# @param [String] str the string to contact this objects serialization to.
|
|
45
|
+
def to_xml_string(str = '')
|
|
46
|
+
str << '<tableStyleInfo '
|
|
47
|
+
serialized_attributes str
|
|
48
|
+
str << '/>'
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -17,7 +17,7 @@ module Axlsx
|
|
|
17
17
|
# returns the relationships required by this collection
|
|
18
18
|
def relationships
|
|
19
19
|
return [] if empty?
|
|
20
|
-
map{ |table| Relationship.new(TABLE_R, "../#{table.pn}") }
|
|
20
|
+
map{ |table| Relationship.new(table, TABLE_R, "../#{table.pn}") }
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def to_xml_string(str = "")
|