axlsx 1.0.16 → 1.1.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.
- data/.yardopts +1 -0
- data/CHANGELOG.md +18 -3
- data/README.md +189 -55
- data/examples/example.csv +1000 -0
- data/examples/example.rb +264 -142
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/lib/axlsx/content_type/content_type.rb +13 -12
- data/lib/axlsx/content_type/default.rb +10 -6
- data/lib/axlsx/content_type/override.rb +13 -8
- data/lib/axlsx/doc_props/app.rb +38 -41
- data/lib/axlsx/doc_props/core.rb +13 -17
- data/lib/axlsx/drawing/axis.rb +39 -19
- data/lib/axlsx/drawing/bar_3D_chart.rb +34 -32
- data/lib/axlsx/drawing/bar_series.rb +14 -14
- data/lib/axlsx/drawing/cat_axis.rb +16 -14
- data/lib/axlsx/drawing/cat_axis_data.rb +17 -18
- data/lib/axlsx/drawing/chart.rb +40 -41
- data/lib/axlsx/drawing/drawing.rb +16 -12
- data/lib/axlsx/drawing/graphic_frame.rb +22 -21
- data/lib/axlsx/drawing/hyperlink.rb +13 -12
- data/lib/axlsx/drawing/line_3D_chart.rb +31 -28
- data/lib/axlsx/drawing/line_series.rb +12 -11
- data/lib/axlsx/drawing/marker.rb +11 -8
- data/lib/axlsx/drawing/named_axis_data.rb +36 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +18 -16
- data/lib/axlsx/drawing/pic.rb +26 -38
- data/lib/axlsx/drawing/picture_locking.rb +22 -18
- data/lib/axlsx/drawing/pie_3D_chart.rb +11 -8
- data/lib/axlsx/drawing/pie_series.rb +16 -12
- data/lib/axlsx/drawing/scaling.rb +11 -10
- data/lib/axlsx/drawing/scatter_chart.rb +69 -0
- data/lib/axlsx/drawing/scatter_series.rb +39 -0
- data/lib/axlsx/drawing/ser_axis.rb +11 -10
- data/lib/axlsx/drawing/series.rb +16 -15
- data/lib/axlsx/drawing/series_title.rb +15 -14
- data/lib/axlsx/drawing/title.rb +27 -26
- data/lib/axlsx/drawing/two_cell_anchor.rb +19 -20
- data/lib/axlsx/drawing/val_axis.rb +9 -7
- data/lib/axlsx/drawing/val_axis_data.rb +18 -17
- data/lib/axlsx/drawing/view_3D.rb +23 -20
- data/lib/axlsx/package.rb +116 -51
- data/lib/axlsx/rels/relationship.rb +12 -8
- data/lib/axlsx/rels/relationships.rb +8 -1
- data/lib/axlsx/stylesheet/#num_fmt.rb# +69 -0
- data/lib/axlsx/stylesheet/border.rb +28 -23
- data/lib/axlsx/stylesheet/border_pr.rb +17 -15
- data/lib/axlsx/stylesheet/cell_alignment.rb +24 -21
- data/lib/axlsx/stylesheet/cell_protection.rb +11 -7
- data/lib/axlsx/stylesheet/cell_style.rb +9 -5
- data/lib/axlsx/stylesheet/color.rb +21 -14
- data/lib/axlsx/stylesheet/fill.rb +8 -5
- data/lib/axlsx/stylesheet/font.rb +22 -14
- data/lib/axlsx/stylesheet/gradient_fill.rb +20 -17
- data/lib/axlsx/stylesheet/gradient_stop.rb +10 -6
- data/lib/axlsx/stylesheet/num_fmt.rb +13 -6
- data/lib/axlsx/stylesheet/pattern_fill.rb +26 -10
- data/lib/axlsx/stylesheet/styles.rb +53 -41
- data/lib/axlsx/stylesheet/table_style.rb +10 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +11 -7
- data/lib/axlsx/stylesheet/table_styles.rb +12 -8
- data/lib/axlsx/stylesheet/xf.rb +30 -25
- data/lib/axlsx/util/cbf.rb +1 -0
- data/lib/axlsx/util/constants.rb +27 -14
- data/lib/axlsx/util/ms_off_crypto.rb +1 -1
- data/lib/axlsx/util/parser.rb +1 -0
- data/lib/axlsx/util/simple_typed_list.rb +20 -10
- data/lib/axlsx/util/storage.rb +1 -0
- data/lib/axlsx/util/validators.rb +23 -7
- data/lib/axlsx/version.rb +2 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +69 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +69 -0
- data/lib/axlsx/workbook/workbook.rb +81 -35
- data/lib/axlsx/workbook/worksheet/cell.rb +172 -117
- data/lib/axlsx/workbook/worksheet/col.rb +114 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +29 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +97 -0
- data/lib/axlsx/workbook/worksheet/row.rb +53 -21
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb +96 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +97 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +269 -121
- data/lib/axlsx.rb +41 -14
- data/lib/schema/dc.xsd +5 -5
- data/lib/schema/dcmitype.xsd +5 -3
- data/lib/schema/dcterms.xsd +15 -15
- data/lib/schema/opc-coreProperties.xsd +6 -2
- data/lib/schema/xml.xsd +7 -8
- data/test/#benchmark.txt# +7 -0
- data/test/#tc_helper.rb# +3 -0
- data/test/benchmark.rb +81 -0
- data/test/benchmark.rb~ +0 -0
- data/test/benchmark.txt +6 -0
- data/test/benchmark.txt~ +6 -0
- data/test/content_type/tc_content_type.rb +31 -31
- data/test/content_type/tc_default.rb +9 -22
- data/test/content_type/tc_override.rb +8 -21
- data/test/doc_props/tc_app.rb +2 -8
- data/test/doc_props/tc_core.rb +6 -7
- data/test/drawing/tc_axis.rb +7 -3
- data/test/drawing/tc_bar_3D_chart.rb +6 -7
- data/test/drawing/tc_bar_series.rb +4 -5
- data/test/drawing/tc_cat_axis.rb +2 -3
- data/test/drawing/tc_cat_axis_data.rb +2 -3
- data/test/drawing/tc_chart.rb +13 -14
- data/test/drawing/tc_drawing.rb +7 -8
- data/test/drawing/tc_graphic_frame.rb +3 -4
- data/test/drawing/tc_hyperlink.rb +2 -3
- data/test/drawing/tc_line_3d_chart.rb +5 -6
- data/test/drawing/tc_line_series.rb +3 -4
- data/test/drawing/tc_marker.rb +3 -4
- data/test/drawing/tc_one_cell_anchor.rb +6 -7
- data/test/drawing/tc_pic.rb +8 -9
- data/test/drawing/tc_picture_locking.rb +2 -3
- data/test/drawing/tc_pie_3D_chart.rb +5 -6
- data/test/drawing/tc_pie_series.rb +4 -5
- data/test/drawing/tc_scaling.rb +3 -4
- data/test/drawing/tc_scatter_chart.rb +43 -0
- data/test/drawing/tc_scatter_series.rb +20 -0
- data/test/drawing/tc_ser_axis.rb +2 -3
- data/test/drawing/tc_series.rb +4 -5
- data/test/drawing/tc_series_title.rb +4 -5
- data/test/drawing/tc_title.rb +4 -5
- data/test/drawing/tc_two_cell_anchor.rb +4 -5
- data/test/drawing/tc_val_axis.rb +2 -3
- data/test/drawing/tc_val_axis_data.rb +2 -3
- data/test/drawing/tc_view_3D.rb +6 -7
- data/test/example.csv +1000 -0
- data/test/example.xlsx +0 -0
- data/test/example_streamed.xlsx +0 -0
- data/test/profile.rb +33 -0
- data/test/rels/tc_relationship.rb +5 -6
- data/test/rels/tc_relationships.rb +4 -5
- data/test/stylesheet/tc_border.rb +3 -4
- data/test/stylesheet/tc_border_pr.rb +3 -4
- data/test/stylesheet/tc_cell_alignment.rb +10 -6
- data/test/stylesheet/tc_cell_protection.rb +2 -3
- data/test/stylesheet/tc_cell_style.rb +2 -3
- data/test/stylesheet/tc_color.rb +2 -3
- data/test/stylesheet/tc_fill.rb +1 -2
- data/test/stylesheet/tc_font.rb +12 -5
- data/test/stylesheet/tc_gradient_fill.rb +1 -2
- data/test/stylesheet/tc_gradient_stop.rb +1 -2
- data/test/stylesheet/tc_num_fmt.rb +1 -2
- data/test/stylesheet/tc_pattern_fill.rb +3 -4
- data/test/stylesheet/tc_styles.rb +16 -6
- data/test/stylesheet/tc_table_style.rb +2 -3
- data/test/stylesheet/tc_table_style_element.rb +2 -3
- data/test/stylesheet/tc_table_styles.rb +3 -4
- data/test/stylesheet/tc_xf.rb +16 -17
- data/test/tc_axlsx.rb +39 -0
- data/test/tc_axlsx.rb~ +0 -0
- data/test/tc_helper.rb +3 -0
- data/test/tc_helper.rb~ +3 -0
- data/test/tc_package.rb +43 -9
- data/test/util/tc_simple_typed_list.rb +8 -9
- data/test/util/tc_validators.rb +7 -8
- data/test/workbook/tc_shared_strings_table.rb +38 -0
- data/test/workbook/tc_workbook.rb +32 -6
- data/test/workbook/worksheet/table/tc_table.rb +71 -0
- data/test/workbook/worksheet/table/tc_table.rb~ +72 -0
- data/test/workbook/worksheet/tc_cell.rb +70 -13
- data/test/workbook/worksheet/tc_col.rb +59 -0
- data/test/workbook/worksheet/tc_col.rb~ +10 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +126 -0
- data/test/workbook/worksheet/tc_page_margins.rb +97 -0
- data/test/workbook/worksheet/tc_row.rb +54 -4
- data/test/workbook/worksheet/tc_worksheet.rb +191 -31
- metadata +162 -109
- data/test/drawing/tc_hyperlink.rb~ +0 -71
data/lib/axlsx/doc_props/app.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
module Axlsx
|
|
3
3
|
# App represents the app.xml document. The attributes for this object are primarily managed by the application the end user uses to edit the document. None of the attributes are required to serialize a valid xlsx object.
|
|
4
4
|
# @see shared-documentPropertiesExtended.xsd
|
|
@@ -17,7 +17,7 @@ module Axlsx
|
|
|
17
17
|
attr_reader :Manager
|
|
18
18
|
|
|
19
19
|
# @return [String] The name of the company generating the document.
|
|
20
|
-
attr_reader :Company
|
|
20
|
+
attr_reader :Company
|
|
21
21
|
|
|
22
22
|
# @return [Integer] The number of pages in the document.
|
|
23
23
|
attr_reader :Pages
|
|
@@ -43,7 +43,7 @@ module Axlsx
|
|
|
43
43
|
# @return [Integer] The number of slides that have notes.
|
|
44
44
|
attr_reader :Notes
|
|
45
45
|
|
|
46
|
-
# @return [Integer] The total amount of time spent editing.
|
|
46
|
+
# @return [Integer] The total amount of time spent editing.
|
|
47
47
|
attr_reader :TotalTime
|
|
48
48
|
|
|
49
49
|
# @return [Integer] The number of hidden slides.
|
|
@@ -60,11 +60,11 @@ module Axlsx
|
|
|
60
60
|
|
|
61
61
|
# @return [Integer] The number of characters in the document including spaces.
|
|
62
62
|
attr_reader :CharactersWithSpaces
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
# @return [Boolean] Indicates if the document is shared.
|
|
65
65
|
attr_reader :ShareDoc
|
|
66
66
|
|
|
67
|
-
# @return [String] The base for hyper links in the document.
|
|
67
|
+
# @return [String] The base for hyper links in the document.
|
|
68
68
|
attr_reader :HyperLinkBase
|
|
69
69
|
|
|
70
70
|
# @return [Boolean] Indicates that the hyper links in the document have been changed.
|
|
@@ -96,7 +96,7 @@ module Axlsx
|
|
|
96
96
|
# @option options [Boolean] ScaleCrop
|
|
97
97
|
# @option options [Boolean] LinksUpToDate
|
|
98
98
|
# @option options [Integer] CharactersWithSpaces
|
|
99
|
-
# @option options [Boolean] ShareDoc
|
|
99
|
+
# @option options [Boolean] ShareDoc
|
|
100
100
|
# @option options [String] HyperLinkBase
|
|
101
101
|
# @option options [String] HyperlinksChanged
|
|
102
102
|
# @option options [String] Application
|
|
@@ -109,70 +109,67 @@ module Axlsx
|
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
# Sets the Template property of your app.xml file
|
|
112
|
-
def Template=(v) Axlsx::validate_string v; @Template = v; end
|
|
112
|
+
def Template=(v) Axlsx::validate_string v; @Template = v; end
|
|
113
113
|
|
|
114
114
|
# Sets the Manager property of your app.xml file
|
|
115
|
-
def Manager=(v) Axlsx::validate_string v; @Manager = v; end
|
|
115
|
+
def Manager=(v) Axlsx::validate_string v; @Manager = v; end
|
|
116
116
|
|
|
117
117
|
# Sets the Company property of your app.xml file
|
|
118
|
-
def Company=(v) Axlsx::validate_string v; @Company = v; end
|
|
118
|
+
def Company=(v) Axlsx::validate_string v; @Company = v; end
|
|
119
119
|
|
|
120
120
|
# Sets the Pages property of your app.xml file
|
|
121
|
-
def Pages=(v) Axlsx::validate_int v; @Pages = v; end
|
|
121
|
+
def Pages=(v) Axlsx::validate_int v; @Pages = v; end
|
|
122
122
|
|
|
123
123
|
# Sets the Words property of your app.xml file
|
|
124
|
-
def Words=(v) Axlsx::validate_int v; @Words = v; end
|
|
124
|
+
def Words=(v) Axlsx::validate_int v; @Words = v; end
|
|
125
125
|
|
|
126
126
|
# Sets the Characters property of your app.xml file
|
|
127
|
-
def Characters=(v) Axlsx::validate_int v; @Characters = v; end
|
|
127
|
+
def Characters=(v) Axlsx::validate_int v; @Characters = v; end
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
# Sets the PresentationFormat property of your app.xml file
|
|
131
|
-
def PresentationFormat=(v) Axlsx::validate_string v; @PresentationFormat = v; end
|
|
131
|
+
def PresentationFormat=(v) Axlsx::validate_string v; @PresentationFormat = v; end
|
|
132
132
|
# Sets the Lines property of your app.xml file
|
|
133
|
-
def Lines=(v) Axlsx::validate_int v; @Lines = v; end
|
|
133
|
+
def Lines=(v) Axlsx::validate_int v; @Lines = v; end
|
|
134
134
|
# Sets the Paragraphs property of your app.xml file
|
|
135
|
-
def Paragraphs=(v) Axlsx::validate_int v; @Paragraphs = v; end
|
|
135
|
+
def Paragraphs=(v) Axlsx::validate_int v; @Paragraphs = v; end
|
|
136
136
|
# Sets the Slides property of your app.xml file
|
|
137
|
-
def Slides=(v) Axlsx::validate_int v; @Slides = v; end
|
|
137
|
+
def Slides=(v) Axlsx::validate_int v; @Slides = v; end
|
|
138
138
|
# Sets the Notes property of your app.xml file
|
|
139
|
-
def Notes=(v) Axlsx::validate_int v; @Notes = v; end
|
|
139
|
+
def Notes=(v) Axlsx::validate_int v; @Notes = v; end
|
|
140
140
|
# Sets the TotalTime property of your app.xml file
|
|
141
|
-
def TotalTime=(v) Axlsx::validate_int v; @TotalTime = v; end
|
|
141
|
+
def TotalTime=(v) Axlsx::validate_int v; @TotalTime = v; end
|
|
142
142
|
# Sets the HiddenSlides property of your app.xml file
|
|
143
|
-
def HiddenSlides=(v) Axlsx::validate_int v; @HiddenSlides = v; end
|
|
143
|
+
def HiddenSlides=(v) Axlsx::validate_int v; @HiddenSlides = v; end
|
|
144
144
|
# Sets the MMClips property of your app.xml file
|
|
145
|
-
def MMClips=(v) Axlsx::validate_int v; @MMClips = v; end
|
|
145
|
+
def MMClips=(v) Axlsx::validate_int v; @MMClips = v; end
|
|
146
146
|
# Sets the ScaleCrop property of your app.xml file
|
|
147
|
-
def ScaleCrop=(v) Axlsx::validate_boolean v; @ScaleCrop = v; end
|
|
147
|
+
def ScaleCrop=(v) Axlsx::validate_boolean v; @ScaleCrop = v; end
|
|
148
148
|
# Sets the LinksUpToDate property of your app.xml file
|
|
149
|
-
def LinksUpToDate=(v) Axlsx::validate_boolean v; @LinksUpToDate = v; end
|
|
149
|
+
def LinksUpToDate=(v) Axlsx::validate_boolean v; @LinksUpToDate = v; end
|
|
150
150
|
# Sets the CharactersWithSpaces property of your app.xml file
|
|
151
|
-
def CharactersWithSpaces=(v) Axlsx::validate_int v; @CharactersWithSpaces = v; end
|
|
151
|
+
def CharactersWithSpaces=(v) Axlsx::validate_int v; @CharactersWithSpaces = v; end
|
|
152
152
|
# Sets the ShareDoc property of your app.xml file
|
|
153
|
-
def ShareDoc=(v) Axlsx::validate_boolean v; @ShareDoc = v; end
|
|
153
|
+
def ShareDoc=(v) Axlsx::validate_boolean v; @ShareDoc = v; end
|
|
154
154
|
# Sets the HyperLinkBase property of your app.xml file
|
|
155
|
-
def HyperLinkBase=(v) Axlsx::validate_string v; @HyperLinkBase = v; end
|
|
155
|
+
def HyperLinkBase=(v) Axlsx::validate_string v; @HyperLinkBase = v; end
|
|
156
156
|
# Sets the HyperLinksChanged property of your app.xml file
|
|
157
|
-
def HyperlinksChanged=(v) Axlsx::validate_boolean v; @HyperlinksChanged = v; end
|
|
157
|
+
def HyperlinksChanged=(v) Axlsx::validate_boolean v; @HyperlinksChanged = v; end
|
|
158
158
|
# Sets the Application property of your app.xml file
|
|
159
|
-
def Application=(v) Axlsx::validate_string v; @Application = v; end
|
|
159
|
+
def Application=(v) Axlsx::validate_string v; @Application = v; end
|
|
160
160
|
# Sets the AppVersion property of your app.xml file
|
|
161
|
-
def AppVersion=(v) Axlsx::validate_string v; @AppVersion = v; end
|
|
161
|
+
def AppVersion=(v) Axlsx::validate_string v; @AppVersion = v; end
|
|
162
162
|
# Sets the DocSecurity property of your app.xml file
|
|
163
|
-
def DocSecurity=(v) Axlsx::validate_int v; @DocSecurity = v; end
|
|
164
|
-
|
|
165
|
-
#
|
|
166
|
-
# @return [String]
|
|
167
|
-
def
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
end
|
|
173
|
-
}
|
|
174
|
-
end
|
|
175
|
-
builder.to_xml(:save_with => 0)
|
|
163
|
+
def DocSecurity=(v) Axlsx::validate_int v; @DocSecurity = v; end
|
|
164
|
+
|
|
165
|
+
# Serialize the app.xml document
|
|
166
|
+
# @return [String]
|
|
167
|
+
def to_xml_string(str = '')
|
|
168
|
+
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
169
|
+
str << '<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">'
|
|
170
|
+
str << instance_values.map { |key, value| '<' << key.to_s << '>' << value.to_s << '</' << key.to_s << '>' }.join
|
|
171
|
+
str << '</Properties>'
|
|
176
172
|
end
|
|
173
|
+
|
|
177
174
|
end
|
|
178
175
|
end
|
data/lib/axlsx/doc_props/core.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# The core object for the package.
|
|
3
4
|
# @note Packages manage their own core object.
|
|
@@ -6,29 +7,24 @@ module Axlsx
|
|
|
6
7
|
# The author of the document. By default this is 'axlsx'
|
|
7
8
|
# @return [String]
|
|
8
9
|
attr_accessor :creator
|
|
9
|
-
|
|
10
|
+
|
|
10
11
|
# Creates a new Core object.
|
|
11
12
|
# @option options [String] creator
|
|
12
13
|
def initialize(options={})
|
|
13
|
-
@creator = options[:creator] || 'axlsx'
|
|
14
|
+
@creator = options[:creator] || 'axlsx'
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
#
|
|
17
|
+
# serializes the core.xml document
|
|
17
18
|
# @return [String]
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
xml['dcterms'].created Time.now.strftime('%Y-%m-%dT%H:%M:%S'), :'xsi:type'=>"dcterms:W3CDTF"
|
|
28
|
-
xml['cp'].revision 0
|
|
29
|
-
}
|
|
30
|
-
end
|
|
31
|
-
builder.to_xml(:save_with => 0)
|
|
19
|
+
def to_xml_string(str = '')
|
|
20
|
+
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
21
|
+
str << '<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" '
|
|
22
|
+
str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
|
|
23
|
+
str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
|
|
24
|
+
str << '<dc:creator>' << self.creator << '</dc:creator>'
|
|
25
|
+
str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << Time.now.strftime('%Y-%m-%dT%H:%M:%S') << '</dcterms:created>'
|
|
26
|
+
str << '<cp:revision>0</cp:revision>'
|
|
27
|
+
str << '</cp:coreProperties>'
|
|
32
28
|
end
|
|
33
29
|
end
|
|
34
30
|
end
|
data/lib/axlsx/drawing/axis.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# the access class defines common properties and values for a chart axis.
|
|
3
4
|
class Axis
|
|
4
5
|
|
|
5
|
-
# the id of the axis.
|
|
6
|
+
# the id of the axis.
|
|
6
7
|
# @return [Integer]
|
|
7
8
|
attr_reader :axId
|
|
8
9
|
|
|
@@ -14,7 +15,7 @@ module Axlsx
|
|
|
14
15
|
# @see Scaling
|
|
15
16
|
# @return [Scaling]
|
|
16
17
|
attr_reader :scaling
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
# The position of the axis
|
|
19
20
|
# must be one of [:l, :r, :t, :b]
|
|
20
21
|
# @return [Symbol]
|
|
@@ -33,7 +34,11 @@ module Axlsx
|
|
|
33
34
|
# specifies how the perpendicular axis is crossed
|
|
34
35
|
# must be one of [:autoZero, :min, :max]
|
|
35
36
|
# @return [Symbol]
|
|
36
|
-
attr_reader :crosses
|
|
37
|
+
attr_reader :crosses
|
|
38
|
+
|
|
39
|
+
# specifies if gridlines should be shown in the chart
|
|
40
|
+
# @return [Boolean]
|
|
41
|
+
attr_reader :gridlines
|
|
37
42
|
|
|
38
43
|
# Creates an Axis object
|
|
39
44
|
# @param [Integer] axId the id of this axis
|
|
@@ -48,11 +53,12 @@ module Axlsx
|
|
|
48
53
|
@axId = axId
|
|
49
54
|
@crossAx = crossAx
|
|
50
55
|
@format_code = "General"
|
|
51
|
-
@scaling = Scaling.new(:orientation=>:minMax)
|
|
56
|
+
@scaling = Scaling.new(:orientation=>:minMax)
|
|
52
57
|
self.axPos = :b
|
|
53
58
|
self.tickLblPos = :nextTo
|
|
54
59
|
self.format_code = "General"
|
|
55
60
|
self.crosses = :autoZero
|
|
61
|
+
self.gridlines = true
|
|
56
62
|
options.each do |o|
|
|
57
63
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
58
64
|
end
|
|
@@ -69,25 +75,39 @@ module Axlsx
|
|
|
69
75
|
# default :General
|
|
70
76
|
def format_code=(v) Axlsx::validate_string(v); @format_code = v; end
|
|
71
77
|
|
|
78
|
+
# Specify if gridlines should be shown for this axis
|
|
79
|
+
# default true
|
|
80
|
+
def gridlines=(v) Axlsx::validate_boolean(v); @gridlines = v; end
|
|
81
|
+
|
|
72
82
|
# specifies how the perpendicular axis is crossed
|
|
73
83
|
# must be one of [:autoZero, :min, :max]
|
|
74
84
|
def crosses=(v) RestrictionValidator.validate "#{self.class}.crosses", [:autoZero, :min, :max], v; @crosses = v; end
|
|
75
85
|
|
|
76
|
-
|
|
77
|
-
#
|
|
86
|
+
|
|
87
|
+
# Serializes the object
|
|
88
|
+
# @param [String] str
|
|
78
89
|
# @return [String]
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
@scaling.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
def to_xml_string(str = '')
|
|
91
|
+
str << '<c:axId val="' << @axId.to_s << '"/>'
|
|
92
|
+
@scaling.to_xml_string str
|
|
93
|
+
str << '<c:delete val="0"/>'
|
|
94
|
+
str << '<c:axPos val="' << @axPos.to_s << '"/>'
|
|
95
|
+
str << '<c:majorGridlines>'
|
|
96
|
+
if self.gridlines == false
|
|
97
|
+
str << '<c:spPr>'
|
|
98
|
+
str << '<a:ln>'
|
|
99
|
+
str << '<a:noFill/>'
|
|
100
|
+
str << '</a:ln>'
|
|
101
|
+
str << '</c:spPr>'
|
|
102
|
+
end
|
|
103
|
+
str << '</c:majorGridlines>'
|
|
104
|
+
str << '<c:numFmt formatCode="' << @format_code << '" sourceLinked="1"/>'
|
|
105
|
+
str << '<c:majorTickMark val="none"/>'
|
|
106
|
+
str << '<c:minorTickMark val="none"/>'
|
|
107
|
+
str << '<c:tickLblPos val="' << @tickLblPos.to_s << '"/>'
|
|
108
|
+
str << '<c:crossAx val="' << @crossAx.to_s << '"/>'
|
|
109
|
+
str << '<c:crosses val="' << @crosses.to_s << '"/>'
|
|
110
|
+
end
|
|
111
|
+
|
|
92
112
|
end
|
|
93
113
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
|
|
3
4
|
# The Bar3DChart is a three dimentional barchart (who would have guessed?) that you can add to your worksheet.
|
|
@@ -40,7 +41,7 @@ module Axlsx
|
|
|
40
41
|
|
|
41
42
|
# validation regex for gap amount percent
|
|
42
43
|
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
|
|
43
|
-
|
|
44
|
+
|
|
44
45
|
# Creates a new bar chart object
|
|
45
46
|
# @param [GraphicFrame] frame The workbook that owns this chart.
|
|
46
47
|
# @option options [Cell, String] title
|
|
@@ -66,14 +67,14 @@ module Axlsx
|
|
|
66
67
|
@valAxId = rand(8 ** 8)
|
|
67
68
|
@catAxis = CatAxis.new(@catAxId, @valAxId)
|
|
68
69
|
@valAxis = ValAxis.new(@valAxId, @catAxId, :tickLblPos => :low)
|
|
69
|
-
super(frame, options)
|
|
70
|
+
super(frame, options)
|
|
70
71
|
@series_type = BarSeries
|
|
71
72
|
@view3D = View3D.new({:rAngAx=>1}.merge(options))
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
# The direction of the bars in the chart
|
|
75
76
|
# must be one of [:bar, :col]
|
|
76
|
-
def barDir=(v)
|
|
77
|
+
def barDir=(v)
|
|
77
78
|
RestrictionValidator.validate "Bar3DChart.barDir", [:bar, :col], v
|
|
78
79
|
@barDir = v
|
|
79
80
|
end
|
|
@@ -99,38 +100,39 @@ module Axlsx
|
|
|
99
100
|
|
|
100
101
|
# The shabe of the bars or columns
|
|
101
102
|
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
|
|
102
|
-
def shape=(v)
|
|
103
|
+
def shape=(v)
|
|
103
104
|
RestrictionValidator.validate "Bar3DChart.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v
|
|
104
105
|
@shape = v
|
|
105
106
|
end
|
|
106
|
-
|
|
107
|
-
# Serializes the
|
|
107
|
+
|
|
108
|
+
# Serializes the object
|
|
109
|
+
# @param [String] str
|
|
108
110
|
# @return [String]
|
|
109
|
-
def
|
|
110
|
-
super() do |
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
@catAxis.
|
|
132
|
-
@valAxis.
|
|
111
|
+
def to_xml_string(str = '')
|
|
112
|
+
super(str) do |str_inner|
|
|
113
|
+
str_inner << '<c:bar3DChart>'
|
|
114
|
+
str_inner << '<c:barDir val="' << barDir.to_s << '"/>'
|
|
115
|
+
str_inner << '<c:grouping val="' << grouping.to_s << '"/>'
|
|
116
|
+
str_inner << '<c:varyColors val="1"/>'
|
|
117
|
+
@series.each { |ser| ser.to_xml_string(str_inner) }
|
|
118
|
+
str_inner << '<c:dLbls>'
|
|
119
|
+
str_inner << '<c:showLegendKey val="0"/>'
|
|
120
|
+
str_inner << '<c:showVal val="0"/>'
|
|
121
|
+
str_inner << '<c:showCatName val="0"/>'
|
|
122
|
+
str_inner << '<c:showSerName val="0"/>'
|
|
123
|
+
str_inner << '<c:showPercent val="0"/>'
|
|
124
|
+
str_inner << '<c:showBubbleSize val="0"/>'
|
|
125
|
+
str_inner << '</c:dLbls>'
|
|
126
|
+
str_inner << '<c:gapWidth val="' << @gapWidth.to_s << '"/>' unless @gapWidth.nil?
|
|
127
|
+
str_inner << '<c:gapDepth val="' << @gapDepth.to_s << '"/>' unless @gapDepth.nil?
|
|
128
|
+
str_inner << '<c:shape val="' << @shape.to_s << '"/>' unless @shape.nil?
|
|
129
|
+
str_inner << '<c:axId val="' << @catAxId.to_s << '"/>'
|
|
130
|
+
str_inner << '<c:axId val="' << @valAxId.to_s << '"/>'
|
|
131
|
+
str_inner << '<c:axId val="0"/>'
|
|
132
|
+
str_inner << '</c:bar3DChart>'
|
|
133
|
+
@catAxis.to_xml_string str_inner
|
|
134
|
+
@valAxis.to_xml_string str_inner
|
|
133
135
|
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
136
138
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# A BarSeries defines the title, data and labels for bar charts
|
|
3
4
|
# @note The recommended way to manage series is to use Chart#add_series
|
|
@@ -5,8 +6,8 @@ module Axlsx
|
|
|
5
6
|
# @see Chart#add_series
|
|
6
7
|
class BarSeries < Series
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
# The data for this series.
|
|
9
|
+
|
|
10
|
+
# The data for this series.
|
|
10
11
|
# @return [Array, SimpleTypedList]
|
|
11
12
|
attr_reader :data
|
|
12
13
|
|
|
@@ -30,28 +31,27 @@ module Axlsx
|
|
|
30
31
|
super(chart, options)
|
|
31
32
|
self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
|
|
32
33
|
self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
|
|
33
|
-
end
|
|
34
|
+
end
|
|
34
35
|
|
|
35
36
|
# The shabe of the bars or columns
|
|
36
37
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
|
37
|
-
def shape=(v)
|
|
38
|
+
def shape=(v)
|
|
38
39
|
RestrictionValidator.validate "BarSeries.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v
|
|
39
40
|
@shape = v
|
|
40
41
|
end
|
|
41
42
|
|
|
42
|
-
# Serializes the
|
|
43
|
-
# @param [
|
|
43
|
+
# Serializes the object
|
|
44
|
+
# @param [String] str
|
|
44
45
|
# @return [String]
|
|
45
|
-
def
|
|
46
|
-
super(
|
|
47
|
-
@labels.
|
|
48
|
-
@data.
|
|
49
|
-
|
|
50
|
-
end
|
|
46
|
+
def to_xml_string(str = '')
|
|
47
|
+
super(str) do |str_inner|
|
|
48
|
+
@labels.to_xml_string(str_inner) unless @labels.nil?
|
|
49
|
+
@data.to_xml_string(str_inner) unless @data.nil?
|
|
50
|
+
str_inner << '<shape val="' << @shape.to_s << '"/>'
|
|
51
|
+
end
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
private
|
|
54
|
+
private
|
|
55
55
|
|
|
56
56
|
# assigns the data for this series
|
|
57
57
|
def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
#A CatAxis object defines a chart category axis
|
|
3
4
|
class CatAxis < Axis
|
|
@@ -9,7 +10,7 @@ module Axlsx
|
|
|
9
10
|
# specifies how the perpendicular axis is crossed
|
|
10
11
|
# must be one of [:ctr, :l, :r]
|
|
11
12
|
# @return [Symbol]
|
|
12
|
-
attr_reader :lblAlgn
|
|
13
|
+
attr_reader :lblAlgn
|
|
13
14
|
|
|
14
15
|
# The offset of the labels
|
|
15
16
|
# must be between a string between 0 and 1000
|
|
@@ -19,7 +20,7 @@ module Axlsx
|
|
|
19
20
|
# regex for validating label offset
|
|
20
21
|
LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)%/
|
|
21
22
|
|
|
22
|
-
# Creates a new CatAxis object
|
|
23
|
+
# Creates a new CatAxis object
|
|
23
24
|
# @param [Integer] axId the id of this axis. Inherited
|
|
24
25
|
# @param [Integer] crossAx the id of the perpendicular axis. Inherited
|
|
25
26
|
# @option options [Symbol] axPos. Inherited
|
|
@@ -27,13 +28,13 @@ module Axlsx
|
|
|
27
28
|
# @option options [Symbol] crosses. Inherited
|
|
28
29
|
# @option options [Boolean] auto
|
|
29
30
|
# @option options [Symbol] lblAlgn
|
|
30
|
-
# @option options [Integer] lblOffset
|
|
31
|
+
# @option options [Integer] lblOffset
|
|
31
32
|
def initialize(axId, crossAx, options={})
|
|
32
33
|
self.auto = 1
|
|
33
34
|
self.lblAlgn = :ctr
|
|
34
35
|
self.lblOffset = "100%"
|
|
35
36
|
super(axId, crossAx, options)
|
|
36
|
-
end
|
|
37
|
+
end
|
|
37
38
|
|
|
38
39
|
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
|
|
39
40
|
def auto=(v) Axlsx::validate_boolean(v); @auto = v; end
|
|
@@ -46,18 +47,19 @@ module Axlsx
|
|
|
46
47
|
# must be between a string between 0 and 1000
|
|
47
48
|
def lblOffset=(v) RegexValidator.validate "#{self.class}.lblOffset", LBL_OFFSET_REGEX, v; @lblOffset = v; end
|
|
48
49
|
|
|
49
|
-
# Serializes the
|
|
50
|
-
# @param [
|
|
50
|
+
# Serializes the object
|
|
51
|
+
# @param [String] str
|
|
51
52
|
# @return [String]
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
def to_xml_string(str = '')
|
|
54
|
+
str << '<c:catAx>'
|
|
55
|
+
super(str)
|
|
56
|
+
str << '<c:auto val="' << @auto.to_s << '"/>'
|
|
57
|
+
str << '<c:lblAlgn val="' << @lblAlgn.to_s << '"/>'
|
|
58
|
+
str << '<c:lblOffset val="' << @lblOffset.to_s << '"/>'
|
|
59
|
+
str << '</c:catAx>'
|
|
59
60
|
end
|
|
61
|
+
|
|
60
62
|
end
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
|
|
63
65
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# The CatAxisData class serializes the category axis data for a chart
|
|
3
4
|
class CatAxisData < SimpleTypedList
|
|
@@ -10,26 +11,24 @@ module Axlsx
|
|
|
10
11
|
data.each { |i| @list << i } if data.is_a?(SimpleTypedList)
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
# Serializes the
|
|
14
|
-
# @param [
|
|
14
|
+
# Serializes the object
|
|
15
|
+
# @param [String] str
|
|
15
16
|
# @return [String]
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
17
|
+
def to_xml_string(str = '')
|
|
18
|
+
str << '<c:cat>'
|
|
19
|
+
str << '<c:strRef>'
|
|
20
|
+
str << '<c:f>' << Axlsx::cell_range(@list) << '</c:f>'
|
|
21
|
+
str << '<c:strCache>'
|
|
22
|
+
str << '<c:ptCount val="' << size.to_s << '"/>'
|
|
23
|
+
each_with_index do |item, index|
|
|
24
|
+
v = item.is_a?(Cell) ? item.value.to_s : item
|
|
25
|
+
str << '<c:pt idx="' << index.to_s << '"><c:v>' << v << '</c:v></c:pt>'
|
|
26
|
+
end
|
|
27
|
+
str << '</c:strCache>'
|
|
28
|
+
str << '</c:strRef>'
|
|
29
|
+
str << '</c:cat>'
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
end
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
end
|