caxlsx 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +24 -5
- data/Rakefile +0 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +2 -5
- data/lib/axlsx/content_type/content_type.rb +0 -4
- data/lib/axlsx/content_type/default.rb +1 -5
- data/lib/axlsx/content_type/override.rb +0 -4
- data/lib/axlsx/doc_props/app.rb +1 -6
- data/lib/axlsx/doc_props/core.rb +1 -6
- data/lib/axlsx/drawing/area_chart.rb +3 -6
- data/lib/axlsx/drawing/area_series.rb +1 -4
- data/lib/axlsx/drawing/ax_data_source.rb +1 -6
- data/lib/axlsx/drawing/axes.rb +5 -6
- data/lib/axlsx/drawing/axis.rb +7 -12
- data/lib/axlsx/drawing/bar_3D_chart.rb +7 -10
- data/lib/axlsx/drawing/bar_chart.rb +6 -9
- data/lib/axlsx/drawing/bar_series.rb +2 -8
- data/lib/axlsx/drawing/bubble_chart.rb +2 -5
- data/lib/axlsx/drawing/bubble_series.rb +3 -6
- data/lib/axlsx/drawing/cat_axis.rb +2 -7
- data/lib/axlsx/drawing/chart.rb +7 -12
- data/lib/axlsx/drawing/d_lbls.rb +23 -22
- data/lib/axlsx/drawing/drawing.rb +4 -8
- data/lib/axlsx/drawing/graphic_frame.rb +0 -3
- data/lib/axlsx/drawing/hyperlink.rb +4 -7
- data/lib/axlsx/drawing/line_3D_chart.rb +10 -14
- data/lib/axlsx/drawing/line_chart.rb +3 -6
- data/lib/axlsx/drawing/line_series.rb +1 -4
- data/lib/axlsx/drawing/marker.rb +5 -9
- data/lib/axlsx/drawing/num_data.rb +4 -9
- data/lib/axlsx/drawing/num_data_source.rb +3 -7
- data/lib/axlsx/drawing/num_val.rb +2 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +4 -6
- data/lib/axlsx/drawing/pic.rb +46 -13
- data/lib/axlsx/drawing/picture_locking.rb +3 -6
- data/lib/axlsx/drawing/pie_3D_chart.rb +2 -7
- data/lib/axlsx/drawing/pie_series.rb +1 -6
- data/lib/axlsx/drawing/scaling.rb +2 -5
- data/lib/axlsx/drawing/scatter_chart.rb +2 -5
- data/lib/axlsx/drawing/scatter_series.rb +2 -5
- data/lib/axlsx/drawing/ser_axis.rb +2 -6
- data/lib/axlsx/drawing/series.rb +3 -5
- data/lib/axlsx/drawing/series_title.rb +0 -2
- data/lib/axlsx/drawing/str_data.rb +3 -8
- data/lib/axlsx/drawing/str_val.rb +2 -5
- data/lib/axlsx/drawing/title.rb +12 -15
- data/lib/axlsx/drawing/two_cell_anchor.rb +5 -7
- data/lib/axlsx/drawing/val_axis.rb +1 -4
- data/lib/axlsx/drawing/view_3D.rb +24 -24
- data/lib/axlsx/drawing/vml_drawing.rb +2 -5
- data/lib/axlsx/drawing/vml_shape.rb +4 -7
- data/lib/axlsx/package.rb +35 -36
- data/lib/axlsx/rels/relationship.rb +21 -24
- data/lib/axlsx/rels/relationships.rb +3 -6
- data/lib/axlsx/stylesheet/border.rb +1 -4
- data/lib/axlsx/stylesheet/border_pr.rb +3 -5
- data/lib/axlsx/stylesheet/cell_alignment.rb +2 -10
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -4
- data/lib/axlsx/stylesheet/cell_style.rb +3 -7
- data/lib/axlsx/stylesheet/color.rb +6 -5
- data/lib/axlsx/stylesheet/dxf.rb +2 -6
- data/lib/axlsx/stylesheet/fill.rb +0 -4
- data/lib/axlsx/stylesheet/font.rb +7 -6
- data/lib/axlsx/stylesheet/gradient_fill.rb +4 -6
- data/lib/axlsx/stylesheet/gradient_stop.rb +2 -3
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -4
- data/lib/axlsx/stylesheet/pattern_fill.rb +3 -5
- data/lib/axlsx/stylesheet/styles.rb +53 -45
- data/lib/axlsx/stylesheet/table_style.rb +5 -8
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -4
- data/lib/axlsx/stylesheet/table_styles.rb +3 -7
- data/lib/axlsx/stylesheet/xf.rb +3 -6
- data/lib/axlsx/util/accessors.rb +2 -4
- data/lib/axlsx/util/constants.rb +3 -5
- data/lib/axlsx/util/mime_type_utils.rb +13 -0
- data/lib/axlsx/util/options_parser.rb +1 -2
- data/lib/axlsx/util/serialized_attributes.rb +4 -5
- data/lib/axlsx/util/simple_typed_list.rb +18 -17
- data/lib/axlsx/util/storage.rb +32 -36
- data/lib/axlsx/util/validators.rb +7 -4
- data/lib/axlsx/util/zip_command.rb +0 -2
- data/lib/axlsx/version.rb +1 -2
- data/lib/axlsx/workbook/defined_name.rb +6 -5
- data/lib/axlsx/workbook/defined_names.rb +1 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +3 -6
- data/lib/axlsx/workbook/workbook.rb +96 -91
- data/lib/axlsx/workbook/workbook_view.rb +5 -10
- data/lib/axlsx/workbook/workbook_views.rb +1 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +9 -8
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +6 -6
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +13 -14
- data/lib/axlsx/workbook/worksheet/border_creator.rb +29 -26
- data/lib/axlsx/workbook/worksheet/break.rb +2 -5
- data/lib/axlsx/workbook/worksheet/cell.rb +46 -26
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +11 -11
- data/lib/axlsx/workbook/worksheet/cfvo.rb +2 -2
- data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -5
- data/lib/axlsx/workbook/worksheet/col.rb +4 -7
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +4 -5
- data/lib/axlsx/workbook/worksheet/color_scale.rb +10 -12
- data/lib/axlsx/workbook/worksheet/cols.rb +6 -6
- data/lib/axlsx/workbook/worksheet/comment.rb +4 -5
- data/lib/axlsx/workbook/worksheet/comments.rb +6 -10
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +4 -5
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +2 -6
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -4
- data/lib/axlsx/workbook/worksheet/data_bar.rb +20 -22
- data/lib/axlsx/workbook/worksheet/data_validation.rb +4 -5
- data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -5
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -3
- data/lib/axlsx/workbook/worksheet/dimension.rb +5 -4
- data/lib/axlsx/workbook/worksheet/header_footer.rb +0 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +2 -3
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +8 -8
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +0 -1
- data/lib/axlsx/workbook/worksheet/page_margins.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_setup.rb +117 -120
- data/lib/axlsx/workbook/worksheet/pane.rb +16 -17
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +8 -11
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -11
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +3 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +0 -1
- data/lib/axlsx/workbook/worksheet/protected_range.rb +4 -5
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +9 -9
- data/lib/axlsx/workbook/worksheet/rich_text.rb +4 -6
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +21 -5
- data/lib/axlsx/workbook/worksheet/row.rb +24 -15
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +3 -4
- data/lib/axlsx/workbook/worksheet/selection.rb +7 -9
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +5 -6
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +4 -6
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +18 -18
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +4 -4
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +12 -13
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +35 -42
- data/lib/axlsx/workbook/worksheet/table.rb +7 -9
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +4 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +63 -35
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -6
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +3 -2
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +5 -6
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +4 -4
- data/lib/axlsx.rb +23 -9
- data/lib/caxlsx.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b169fe36651a9f3937c0a0b11226ce2ebaf8527d1c358247a3fd0ea0ec581af
|
4
|
+
data.tar.gz: 5fccec296a8485fc58dd0705e356beb7bb9e539f56f6cff3aadf289b4c73740d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b1b16e2f613d33d67c18fbcb1690d40efe21557bc9e1629aa6dd8c2c88b04f31ef928f888b1d254bd0f35a399f62526c420609b1611163591f47d0b1dadd1ed
|
7
|
+
data.tar.gz: f421c3b215ea313e233487b7d50cb61d5041585301a456ec5c04304b3b425ba47be80e6c3b56fa1e2684c8ca894cb79eed85c10ab7acf4c602453170ba475b7e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,15 @@ CHANGELOG
|
|
2
2
|
---------
|
3
3
|
- **Unreleased**
|
4
4
|
|
5
|
+
- **April.12.23**: 3.4.0
|
6
|
+
- [PR #186](https://github.com/caxlsx/caxlsx/pull/186) - Add `escape_formulas` to global, workbook, worksheet, row and cell levels, and standardize behavior.
|
7
|
+
- [PR #186](https://github.com/caxlsx/caxlsx/pull/186) - `escape_formulas` should handle all [OWASP-designated formula prefixes](https://owasp.org/www-community/attacks/CSV_Injection).
|
8
|
+
- Fix bug when calling `worksheet.add_border("A1:B2", nil)`
|
9
|
+
- Change `BorderCreator#initialize` arguments handling
|
10
|
+
- Fix `add_border` to work with singluar cell refs
|
11
|
+
- [PR #196](https://github.com/caxlsx/caxlsx/pull/196) - Fix tab color reassignment
|
12
|
+
- Add support for remote image source in `Pic` using External Relationship (supported in Excel documents)
|
13
|
+
|
5
14
|
- **October.21.22**: 3.3.0
|
6
15
|
- [PR #168](https://github.com/caxlsx/caxlsx/pull/168) - Merge in the gem [`axlsx_styler`](https://github.com/axlsx-styler-gem/axlsx_styler)
|
7
16
|
- Add ability to both apply or append to existing styles after rows have been created using `worksheet.add_style`
|
data/README.md
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# Caxlsx (Community Continued Version)
|
2
2
|
[![Build Status](https://github.com/caxlsx/caxlsx/workflows/Test/badge.svg)](https://github.com/caxlsx/caxlsx/actions)
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/caxlsx.svg)](
|
4
|
-
![
|
5
|
-
![Downloads for 3.3.0 (latest)](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx/3.3.0?label=downloads%203.3.0)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/caxlsx.svg)](https://badge.fury.io/rb/caxlsx)
|
4
|
+
![downloads](https://img.shields.io/gem/dt/caxlsx?label=downloads)
|
6
5
|
|
7
6
|
## Notice: Community Axlsx Organization
|
8
7
|
|
9
8
|
To better maintain the Axlsx ecosystem, all related gems have been forked or moved to the following community organization:
|
10
9
|
|
11
|
-
|
10
|
+
https://github.com/caxlsx
|
12
11
|
|
13
12
|
[Join the Caxlsx Slack channel](https://join.slack.com/t/caxlsx/shared_invite/enQtOTI5OTM0MzI1Njk5LTBlMDQzNDk2YzkwODMxMmVkODMyYzJiZGU5NTQ3YTg5NTBlN2IwZTlmNTRjNzhiY2E0MDY2OTEyYmFlODI5NjA)
|
14
13
|
|
@@ -120,6 +119,26 @@ Currently the following additional gems are available:
|
|
120
119
|
- [activeadmin-caxlsx](https://github.com/caxlsx/activeadmin-caxlsx)
|
121
120
|
* An Active Admin plugin that includes DSL to create downloadable reports.
|
122
121
|
|
122
|
+
## Security
|
123
|
+
|
124
|
+
To prevent [Formula Injection](https://www.owasp.org/index.php/CSV_Injection) vulnerabilities, set the following in an initializer:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
Axlsx.escape_formulas = true
|
128
|
+
```
|
129
|
+
|
130
|
+
Then, set the following on each cell you'd like to add a formula:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
cell.escape_formulas = true
|
134
|
+
```
|
135
|
+
|
136
|
+
Refer to examples/escape_formula.md for how to set `escape_formulas` on the workbook, worksheet, row and/or cell level.
|
137
|
+
|
138
|
+
**Important:** The global setting `Axlsx.escape_formulas = true` will become the default in the next major release (Axlsx 4.0).
|
139
|
+
If you do not wish to set `Axlsx.escape_formulas = true` now, at a minimum, please set `Axlsx.escape_formulas = false` to
|
140
|
+
ensure continuity when upgrading.
|
141
|
+
|
123
142
|
## Known Software Interoperability Issues
|
124
143
|
|
125
144
|
As axslx implements the Office Open XML (ECMA-376 spec) much of the
|
@@ -160,6 +179,6 @@ See [CONTRIBUTING.md](https://github.com/caxlsx/caxlsx/blob/master/CONTRIBUTING.
|
|
160
179
|
|
161
180
|
Originally created by Randy Morgan - @randym
|
162
181
|
|
163
|
-
Forked in 2019, to enable the community to maintain the Axlsx ecosystem -
|
182
|
+
Forked in 2019, to enable the community to maintain the Axlsx ecosystem - https://github.com/caxlsx
|
164
183
|
|
165
184
|
Open source software is a community effort. None of this could have been done without the help of [our Contributors](https://github.com/caxlsx/caxlsx/graphs/contributors).
|
data/Rakefile
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# This class extracts the common parts from Default and Override
|
4
3
|
class AbstractContentType
|
5
|
-
|
6
4
|
include Axlsx::OptionsParser
|
7
5
|
|
8
6
|
# Initializes an abstract content type
|
9
7
|
# @see Default, Override
|
10
|
-
def initialize(options={})
|
11
|
-
|
8
|
+
def initialize(options = {})
|
9
|
+
parse_options options
|
12
10
|
end
|
13
11
|
|
14
12
|
# The type of content.
|
@@ -27,6 +25,5 @@ module Axlsx
|
|
27
25
|
str << Axlsx.instance_values_for(self).map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ')
|
28
26
|
str << '/>'
|
29
27
|
end
|
30
|
-
|
31
28
|
end
|
32
29
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
require 'axlsx/content_type/abstract_content_type.rb'
|
4
3
|
require 'axlsx/content_type/default.rb'
|
@@ -6,7 +5,6 @@ module Axlsx
|
|
6
5
|
|
7
6
|
# ContentTypes used in the package. This is automatically managed by the package package.
|
8
7
|
class ContentType < SimpleTypedList
|
9
|
-
|
10
8
|
def initialize
|
11
9
|
super [Override, Default]
|
12
10
|
end
|
@@ -20,7 +18,5 @@ module Axlsx
|
|
20
18
|
each { |type| type.to_xml_string(str) }
|
21
19
|
str << '</Types>'
|
22
20
|
end
|
23
|
-
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# An default content part. These parts are automatically created by for you based on the content of your package.
|
5
3
|
class Default < AbstractContentType
|
6
|
-
|
7
4
|
# The serialization node name for this class
|
8
5
|
NODE_NAME = 'Default'
|
9
6
|
|
@@ -17,9 +14,8 @@ module Axlsx
|
|
17
14
|
alias :Extension= :extension=
|
18
15
|
|
19
16
|
# Serializes this object to xml
|
20
|
-
def to_xml_string(str ='')
|
17
|
+
def to_xml_string(str = '')
|
21
18
|
super(NODE_NAME, str)
|
22
19
|
end
|
23
20
|
end
|
24
|
-
|
25
21
|
end
|
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
# encoding: UTF-8
|
3
1
|
module Axlsx
|
4
|
-
|
5
2
|
# An override content part. These parts are automatically created by for you based on the content of your package.
|
6
3
|
class Override < AbstractContentType
|
7
|
-
|
8
4
|
# Serialization node name for this object
|
9
5
|
NODE_NAME = 'Override'
|
10
6
|
|
data/lib/axlsx/doc_props/app.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# 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.
|
5
3
|
# @see shared-documentPropertiesExtended.xsd
|
6
4
|
# @note Support is not implemented for the following complex types:
|
@@ -10,7 +8,6 @@ module Axlsx
|
|
10
8
|
# HLinks (VectorVariant),
|
11
9
|
# DigSig (DigSigBlob)
|
12
10
|
class App
|
13
|
-
|
14
11
|
include Axlsx::OptionsParser
|
15
12
|
|
16
13
|
# Creates an App object
|
@@ -36,7 +33,7 @@ module Axlsx
|
|
36
33
|
# @option options [String] application
|
37
34
|
# @option options [String] app_version
|
38
35
|
# @option options [Integer] doc_security
|
39
|
-
def initialize(options={})
|
36
|
+
def initialize(options = {})
|
40
37
|
parse_options options
|
41
38
|
end
|
42
39
|
|
@@ -229,7 +226,5 @@ module Axlsx
|
|
229
226
|
end
|
230
227
|
str << '</Properties>'
|
231
228
|
end
|
232
|
-
|
233
229
|
end
|
234
|
-
|
235
230
|
end
|
data/lib/axlsx/doc_props/core.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The core object for the package.
|
5
3
|
# @note Packages manage their own core object.
|
6
4
|
# @see Package#core
|
7
5
|
class Core
|
8
|
-
|
9
6
|
# Creates a new Core object.
|
10
7
|
# @option options [String] creator
|
11
8
|
# @option options [Time] created
|
12
|
-
def initialize(options={})
|
9
|
+
def initialize(options = {})
|
13
10
|
@creator = options[:creator] || 'axlsx'
|
14
11
|
@created = options[:created]
|
15
12
|
end
|
@@ -33,7 +30,5 @@ module Axlsx
|
|
33
30
|
str << '<cp:revision>0</cp:revision>'
|
34
31
|
str << '</cp:coreProperties>'
|
35
32
|
end
|
36
|
-
|
37
33
|
end
|
38
|
-
|
39
34
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The AreaChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
|
5
3
|
# @example Creating a chart
|
6
4
|
# # This example creates a line in a single sheet.
|
@@ -20,7 +18,6 @@ module Axlsx
|
|
20
18
|
# @see Series
|
21
19
|
# @see Package#serialize
|
22
20
|
class AreaChart < Chart
|
23
|
-
|
24
21
|
# the category axis
|
25
22
|
# @return [CatAxis]
|
26
23
|
def cat_axis
|
@@ -35,7 +32,7 @@ module Axlsx
|
|
35
32
|
end
|
36
33
|
alias :valAxis :val_axis
|
37
34
|
|
38
|
-
|
35
|
+
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
39
36
|
# @return [Symbol]
|
40
37
|
attr_reader :grouping
|
41
38
|
|
@@ -45,7 +42,7 @@ module Axlsx
|
|
45
42
|
# @option options [Boolean] show_legend
|
46
43
|
# @option options [Symbol] grouping
|
47
44
|
# @see Chart
|
48
|
-
def initialize(frame, options={})
|
45
|
+
def initialize(frame, options = {})
|
49
46
|
@vary_colors = false
|
50
47
|
@grouping = :standard
|
51
48
|
super(frame, options)
|
@@ -66,7 +63,7 @@ module Axlsx
|
|
66
63
|
def node_name
|
67
64
|
path = self.class.to_s
|
68
65
|
if i = path.rindex('::')
|
69
|
-
path = path[(i+2)..-1]
|
66
|
+
path = path[(i + 2)..-1]
|
70
67
|
end
|
71
68
|
path[0] = path[0].chr.downcase
|
72
69
|
path
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# A AreaSeries defines the title, data and labels for line charts
|
4
3
|
# @note The recommended way to manage series is to use Chart#add_series
|
5
4
|
# @see Worksheet#add_chart
|
6
5
|
# @see Chart#add_series
|
7
6
|
class AreaSeries < Series
|
8
|
-
|
9
7
|
# The data for this series.
|
10
8
|
# @return [ValAxisData]
|
11
9
|
attr_reader :data
|
@@ -35,7 +33,7 @@ module Axlsx
|
|
35
33
|
# @option options [Array, SimpleTypedList] data
|
36
34
|
# @option options [Array, SimpleTypedList] labels
|
37
35
|
# @param [Chart] chart
|
38
|
-
def initialize(chart, options={})
|
36
|
+
def initialize(chart, options = {})
|
39
37
|
@show_marker = false
|
40
38
|
@marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
|
41
39
|
@smooth = false
|
@@ -105,6 +103,5 @@ module Axlsx
|
|
105
103
|
|
106
104
|
# assigns the labels for this series
|
107
105
|
def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
|
108
|
-
|
109
106
|
end
|
110
107
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# An axis data source that can contain referenced or literal strings or numbers
|
4
3
|
# @note only string data types are supported - mainly because we have not implemented a chart type that requires a numerical axis value
|
5
4
|
class AxDataSource < NumDataSource
|
6
|
-
|
7
5
|
# creates a new NumDataSource object
|
8
6
|
# @option options [Array] data An array of Cells or Numeric objects
|
9
7
|
# @option options [Symbol] tag_name see tag_name
|
10
|
-
def initialize(options={})
|
8
|
+
def initialize(options = {})
|
11
9
|
@tag_name = :cat
|
12
10
|
@data_type = StrData
|
13
11
|
@ref_tag_name = :strRef
|
@@ -19,8 +17,5 @@ module Axlsx
|
|
19
17
|
def self.allowed_tag_names
|
20
18
|
[:xVal, :cat]
|
21
19
|
end
|
22
|
-
|
23
20
|
end
|
24
|
-
|
25
21
|
end
|
26
|
-
|
data/lib/axlsx/drawing/axes.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# The Axes class creates and manages axis information and
|
4
3
|
# serialization for charts.
|
5
4
|
class Axes
|
6
|
-
|
7
5
|
# @param [Hash] options options used to generate axis each key
|
8
6
|
# should be an axis name like :val_axis and its value should be the
|
9
7
|
# class of the axis type to construct. The :cat_axis, if there is one,
|
10
8
|
# must come first (we assume a Ruby 1.9+ Hash or an OrderedHash).
|
11
|
-
def initialize(options={})
|
9
|
+
def initialize(options = {})
|
12
10
|
raise(ArgumentError, "CatAxis must come first") if options.keys.include?(:cat_axis) && options.keys.first != :cat_axis
|
11
|
+
|
13
12
|
options.each do |name, axis_class|
|
14
13
|
add_axis(name, axis_class)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
17
|
# [] provides assiciative access to a specic axis store in an axes
|
19
|
-
# instance.
|
18
|
+
# instance.
|
20
19
|
# @return [Axis]
|
21
20
|
def [](name)
|
22
21
|
axes.assoc(name)[1]
|
@@ -27,12 +26,12 @@ module Axlsx
|
|
27
26
|
# @param [Hash] options
|
28
27
|
# @option options ids
|
29
28
|
# If the ids option is specified only the axis identifier is
|
30
|
-
# serialized. Otherwise, each axis is serialized in full.
|
29
|
+
# serialized. Otherwise, each axis is serialized in full.
|
31
30
|
def to_xml_string(str = '', options = {})
|
32
31
|
if options[:ids]
|
33
32
|
# CatAxis must come first in the XML (for Microsoft Excel at least)
|
34
33
|
sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 }
|
35
|
-
sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') }
|
34
|
+
sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') }
|
36
35
|
else
|
37
36
|
axes.each { |axis| axis[1].to_xml_string(str) }
|
38
37
|
end
|
data/lib/axlsx/drawing/axis.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# the access class defines common properties and values for a chart axis.
|
5
3
|
class Axis
|
6
|
-
|
7
4
|
include Axlsx::OptionsParser
|
8
5
|
|
9
6
|
# Creates an Axis object
|
@@ -12,11 +9,11 @@ module Axlsx
|
|
12
9
|
# @option options [Symbol] crosses
|
13
10
|
# @option options [Symbol] tick_lbl_pos
|
14
11
|
# @raise [ArgumentError] If axi_id or cross_ax are not unsigned integers
|
15
|
-
def initialize(options={})
|
16
|
-
@id = rand(8
|
12
|
+
def initialize(options = {})
|
13
|
+
@id = rand(8**8)
|
17
14
|
@format_code = "General"
|
18
15
|
@delete = @label_rotation = 0
|
19
|
-
@scaling = Scaling.new(:orientation
|
16
|
+
@scaling = Scaling.new(:orientation => :minMax)
|
20
17
|
@title = @color = nil
|
21
18
|
self.ax_pos = :b
|
22
19
|
self.tick_lbl_pos = :nextTo
|
@@ -83,19 +80,19 @@ module Axlsx
|
|
83
80
|
# the title for the axis. This can be a cell or a fixed string.
|
84
81
|
attr_reader :title
|
85
82
|
|
86
|
-
# The color for this axis. This value is used when rendering the axis line in the chart.
|
83
|
+
# The color for this axis. This value is used when rendering the axis line in the chart.
|
87
84
|
# colors should be in 6 character rbg format
|
88
85
|
# @return [String] the rbg color assinged.
|
89
86
|
# @see color
|
90
87
|
def color=(color_rgb)
|
91
88
|
@color = color_rgb
|
92
89
|
end
|
93
|
-
|
90
|
+
|
94
91
|
# The crossing axis for this axis
|
95
92
|
# @param [Axis] axis
|
96
93
|
def cross_axis=(axis)
|
97
|
-
|
98
|
-
|
94
|
+
DataTypeValidator.validate "#{self.class}.cross_axis", [Axis], axis
|
95
|
+
@cross_axis = axis
|
99
96
|
end
|
100
97
|
|
101
98
|
# The position of the axis
|
@@ -184,7 +181,5 @@ module Axlsx
|
|
184
181
|
str << ('<c:crossAx val="' << @cross_axis.id.to_s << '"/>')
|
185
182
|
str << ('<c:crosses val="' << @crosses.to_s << '"/>')
|
186
183
|
end
|
187
|
-
|
188
184
|
end
|
189
|
-
|
190
185
|
end
|
@@ -1,13 +1,10 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The Bar3DChart is a three dimentional barchart (who would have guessed?) that you can add to your worksheet.
|
5
3
|
# @see Worksheet#add_chart
|
6
4
|
# @see Chart#add_series
|
7
5
|
# @see Package#serialize
|
8
6
|
# @see README for an example
|
9
7
|
class Bar3DChart < Chart
|
10
|
-
|
11
8
|
# the category axis
|
12
9
|
# @return [CatAxis]
|
13
10
|
def cat_axis
|
@@ -42,7 +39,7 @@ module Axlsx
|
|
42
39
|
end
|
43
40
|
alias :gapWidth :gap_width
|
44
41
|
|
45
|
-
#grouping for a column, line, or area chart.
|
42
|
+
# grouping for a column, line, or area chart.
|
46
43
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
47
44
|
# @return [Symbol]
|
48
45
|
def grouping
|
@@ -73,12 +70,12 @@ module Axlsx
|
|
73
70
|
# @option options [Integer] perspective
|
74
71
|
# @see Chart
|
75
72
|
# @see View3D
|
76
|
-
def initialize(frame, options={})
|
73
|
+
def initialize(frame, options = {})
|
77
74
|
@vary_colors = true
|
78
75
|
@gap_width, @gap_depth, @shape = nil, nil, nil
|
79
76
|
super(frame, options)
|
80
77
|
@series_type = BarSeries
|
81
|
-
@view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
|
78
|
+
@view_3D = View3D.new({ :r_ang_ax => 1 }.merge(options))
|
82
79
|
@d_lbls = nil
|
83
80
|
end
|
84
81
|
|
@@ -90,7 +87,7 @@ module Axlsx
|
|
90
87
|
end
|
91
88
|
alias :barDir= :bar_dir=
|
92
89
|
|
93
|
-
#grouping for a column, line, or area chart.
|
90
|
+
# grouping for a column, line, or area chart.
|
94
91
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
95
92
|
def grouping=(v)
|
96
93
|
RestrictionValidator.validate "Bar3DChart.grouping", [:percentStacked, :clustered, :standard, :stacked], v
|
@@ -100,14 +97,14 @@ module Axlsx
|
|
100
97
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
101
98
|
def gap_width=(v)
|
102
99
|
RangeValidator.validate "Bar3DChart.gap_width", 0, 500, v
|
103
|
-
@gap_width=(v)
|
100
|
+
@gap_width = (v)
|
104
101
|
end
|
105
102
|
alias :gapWidth= :gap_width=
|
106
103
|
|
107
104
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
108
105
|
def gap_depth=(v)
|
109
106
|
RangeValidator.validate "Bar3DChart.gap_depth", 0, 500, v
|
110
|
-
@gap_depth=(v)
|
107
|
+
@gap_depth = (v)
|
111
108
|
end
|
112
109
|
alias :gapDepth= :gap_depth=
|
113
110
|
|
@@ -142,7 +139,7 @@ module Axlsx
|
|
142
139
|
# category axes specified via axes[:val_axes] and axes[:cat_axis]
|
143
140
|
# @return [Axes]
|
144
141
|
def axes
|
145
|
-
|
142
|
+
@axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)
|
146
143
|
end
|
147
144
|
end
|
148
145
|
end
|
@@ -1,13 +1,10 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The BarChart is a two dimentional barchart that you can add to your worksheet.
|
5
3
|
# @see Worksheet#add_chart
|
6
4
|
# @see Chart#add_series
|
7
5
|
# @see Package#serialize
|
8
6
|
# @see README for an example
|
9
7
|
class BarChart < Chart
|
10
|
-
|
11
8
|
# the category axis
|
12
9
|
# @return [CatAxis]
|
13
10
|
def cat_axis
|
@@ -37,7 +34,7 @@ module Axlsx
|
|
37
34
|
end
|
38
35
|
alias :gapWidth :gap_width
|
39
36
|
|
40
|
-
#grouping for a column, line, or area chart.
|
37
|
+
# grouping for a column, line, or area chart.
|
41
38
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
42
39
|
# @return [Symbol]
|
43
40
|
def grouping
|
@@ -66,7 +63,7 @@ module Axlsx
|
|
66
63
|
# @option options [String] gap_width
|
67
64
|
# @option options [Symbol] shape
|
68
65
|
# @see Chart
|
69
|
-
def initialize(frame, options={})
|
66
|
+
def initialize(frame, options = {})
|
70
67
|
@vary_colors = true
|
71
68
|
@gap_width, @overlap, @shape = nil, nil, nil
|
72
69
|
super(frame, options)
|
@@ -82,7 +79,7 @@ module Axlsx
|
|
82
79
|
end
|
83
80
|
alias :barDir= :bar_dir=
|
84
81
|
|
85
|
-
#grouping for a column, line, or area chart.
|
82
|
+
# grouping for a column, line, or area chart.
|
86
83
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
87
84
|
def grouping=(v)
|
88
85
|
RestrictionValidator.validate "BarChart.grouping", [:percentStacked, :clustered, :standard, :stacked], v
|
@@ -92,13 +89,13 @@ module Axlsx
|
|
92
89
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
93
90
|
def gap_width=(v)
|
94
91
|
RangeValidator.validate "BarChart.gap_width", 0, 500, v
|
95
|
-
@gap_width=(v)
|
92
|
+
@gap_width = (v)
|
96
93
|
end
|
97
94
|
alias :gapWidth= :gap_width=
|
98
95
|
|
99
96
|
def overlap=(v)
|
100
97
|
RangeValidator.validate "BarChart.overlap", -100, 100, v
|
101
|
-
@overlap=(v)
|
98
|
+
@overlap = (v)
|
102
99
|
end
|
103
100
|
|
104
101
|
# The shape of the bars or columns
|
@@ -132,7 +129,7 @@ module Axlsx
|
|
132
129
|
# category axes specified via axes[:val_axes] and axes[:cat_axis]
|
133
130
|
# @return [Axes]
|
134
131
|
def axes
|
135
|
-
|
132
|
+
@axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis)
|
136
133
|
end
|
137
134
|
end
|
138
135
|
end
|
@@ -1,12 +1,9 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# A BarSeries defines the title, data and labels for bar charts
|
4
3
|
# @note The recommended way to manage series is to use Chart#add_series
|
5
4
|
# @see Worksheet#add_chart
|
6
5
|
# @see Chart#add_series
|
7
6
|
class BarSeries < Series
|
8
|
-
|
9
|
-
|
10
7
|
# The data for this series.
|
11
8
|
# @return [NumDataSource]
|
12
9
|
attr_reader :data
|
@@ -35,11 +32,11 @@ module Axlsx
|
|
35
32
|
# @option options [String] colors an array of colors to use when rendering each data point
|
36
33
|
# @option options [String] series_color a color to use when rendering series
|
37
34
|
# @param [Chart] chart
|
38
|
-
def initialize(chart, options={})
|
35
|
+
def initialize(chart, options = {})
|
39
36
|
@shape = :box
|
40
37
|
@colors = []
|
41
38
|
super(chart, options)
|
42
|
-
self.labels = AxDataSource.new({:data => options[:labels]}) unless options[:labels].nil?
|
39
|
+
self.labels = AxDataSource.new({ :data => options[:labels] }) unless options[:labels].nil?
|
43
40
|
self.data = NumDataSource.new(options) unless options[:data].nil?
|
44
41
|
end
|
45
42
|
|
@@ -61,7 +58,6 @@ module Axlsx
|
|
61
58
|
# @return [String]
|
62
59
|
def to_xml_string(str = '')
|
63
60
|
super(str) do
|
64
|
-
|
65
61
|
colors.each_with_index do |c, index|
|
66
62
|
str << '<c:dPt>'
|
67
63
|
str << ('<c:idx val="' << index.to_s << '"/>')
|
@@ -91,7 +87,5 @@ module Axlsx
|
|
91
87
|
|
92
88
|
# assigns the labels for this series
|
93
89
|
def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
|
94
|
-
|
95
90
|
end
|
96
|
-
|
97
91
|
end
|
@@ -1,12 +1,9 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The BubbleChart allows you to insert a bubble chart into your worksheet
|
5
3
|
# @see Worksheet#add_chart
|
6
4
|
# @see Chart#add_series
|
7
5
|
# @see README for an example
|
8
6
|
class BubbleChart < Chart
|
9
|
-
|
10
7
|
include Axlsx::OptionsParser
|
11
8
|
|
12
9
|
# the x value axis
|
@@ -24,10 +21,10 @@ module Axlsx
|
|
24
21
|
alias :yValAxis :y_val_axis
|
25
22
|
|
26
23
|
# Creates a new bubble chart
|
27
|
-
def initialize(frame, options={})
|
24
|
+
def initialize(frame, options = {})
|
28
25
|
@vary_colors = 0
|
29
26
|
|
30
|
-
|
27
|
+
super(frame, options)
|
31
28
|
@series_type = BubbleSeries
|
32
29
|
@d_lbls = nil
|
33
30
|
parse_options options
|
@@ -1,13 +1,10 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# A BubbleSeries defines the x/y position and bubble size of data in the chart
|
5
3
|
# @note The recommended way to manage series is to use Chart#add_series
|
6
4
|
# @see Worksheet#add_chart
|
7
5
|
# @see Chart#add_series
|
8
6
|
# @see examples/example.rb
|
9
7
|
class BubbleSeries < Series
|
10
|
-
|
11
8
|
# The x data for this series.
|
12
9
|
# @return [AxDataSource]
|
13
10
|
attr_reader :xData
|
@@ -26,12 +23,12 @@ module Axlsx
|
|
26
23
|
attr_reader :color
|
27
24
|
|
28
25
|
# Creates a new BubbleSeries
|
29
|
-
def initialize(chart, options={})
|
26
|
+
def initialize(chart, options = {})
|
30
27
|
@xData, @yData, @bubbleSize = nil
|
31
28
|
super(chart, options)
|
32
29
|
@xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
|
33
|
-
@yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
|
34
|
-
@bubbleSize = NumDataSource.new({:tag_name => :bubbleSize, :data => options[:bubbleSize]}) unless options[:bubbleSize].nil?
|
30
|
+
@yData = NumDataSource.new({ :tag_name => :yVal, :data => options[:yData] }) unless options[:yData].nil?
|
31
|
+
@bubbleSize = NumDataSource.new({ :tag_name => :bubbleSize, :data => options[:bubbleSize] }) unless options[:bubbleSize].nil?
|
35
32
|
end
|
36
33
|
|
37
34
|
# @see color
|