caxlsx 2.0.2 → 3.0.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 +5 -0
- data/README.md +41 -33
- data/Rakefile +9 -11
- data/examples/auto_filter.rb +10 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +18 -3
- data/examples/data_validation.rb +57 -40
- data/examples/example.rb +115 -7
- data/examples/merge_cells.rb +17 -0
- data/examples/no_grid_with_borders.rb +18 -0
- data/examples/pivot_test.rb +63 -0
- data/examples/split.rb +16 -0
- data/lib/axlsx.rb +34 -15
- data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +5 -5
- data/lib/axlsx/drawing/area_chart.rb +99 -0
- data/lib/axlsx/drawing/area_series.rb +110 -0
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +12 -9
- data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
- data/lib/axlsx/drawing/bar_chart.rb +143 -0
- data/lib/axlsx/drawing/bar_series.rb +9 -9
- data/lib/axlsx/drawing/bubble_chart.rb +59 -0
- data/lib/axlsx/drawing/bubble_series.rb +63 -0
- data/lib/axlsx/drawing/cat_axis.rb +5 -5
- data/lib/axlsx/drawing/chart.rb +52 -8
- data/lib/axlsx/drawing/d_lbls.rb +3 -3
- data/lib/axlsx/drawing/drawing.rb +6 -1
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +1 -3
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/line_chart.rb +10 -10
- data/lib/axlsx/drawing/line_series.rb +32 -3
- data/lib/axlsx/drawing/marker.rb +1 -1
- data/lib/axlsx/drawing/num_data.rb +4 -4
- data/lib/axlsx/drawing/num_data_source.rb +6 -6
- data/lib/axlsx/drawing/num_val.rb +3 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +3 -2
- data/lib/axlsx/drawing/pic.rb +25 -19
- data/lib/axlsx/drawing/picture_locking.rb +1 -3
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
- data/lib/axlsx/drawing/pie_series.rb +6 -6
- data/lib/axlsx/drawing/scaling.rb +6 -6
- data/lib/axlsx/drawing/scatter_chart.rb +10 -10
- data/lib/axlsx/drawing/scatter_series.rb +40 -7
- data/lib/axlsx/drawing/ser_axis.rb +2 -2
- data/lib/axlsx/drawing/series.rb +3 -3
- data/lib/axlsx/drawing/series_title.rb +2 -2
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +3 -1
- data/lib/axlsx/drawing/title.rb +22 -4
- data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
- data/lib/axlsx/drawing/val_axis.rb +1 -1
- data/lib/axlsx/drawing/view_3D.rb +2 -2
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +33 -31
- data/lib/axlsx/rels/relationship.rb +1 -1
- data/lib/axlsx/rels/relationships.rb +7 -4
- data/lib/axlsx/stylesheet/border_pr.rb +2 -2
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
- data/lib/axlsx/stylesheet/cell_style.rb +1 -3
- data/lib/axlsx/stylesheet/color.rb +1 -3
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +10 -3
- data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +7 -7
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/constants.rb +107 -99
- data/lib/axlsx/util/mime_type_utils.rb +11 -0
- data/lib/axlsx/util/options_parser.rb +2 -1
- data/lib/axlsx/util/parser.rb +4 -4
- data/lib/axlsx/util/serialized_attributes.rb +16 -6
- data/lib/axlsx/util/simple_typed_list.rb +28 -52
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/validators.rb +29 -17
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +11 -12
- data/lib/axlsx/workbook/defined_names.rb +2 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
- data/lib/axlsx/workbook/workbook.rb +36 -11
- data/lib/axlsx/workbook/workbook_view.rb +80 -0
- data/lib/axlsx/workbook/workbook_views.rb +22 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
- data/lib/axlsx/workbook/worksheet/break.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +136 -74
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +63 -43
- data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +4 -1
- data/lib/axlsx/workbook/worksheet/col.rb +7 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/cols.rb +5 -2
- data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
- data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
- data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
- data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +4 -2
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +33 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +44 -28
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +5 -2
- data/lib/axlsx/workbook/worksheet/rich_text.rb +55 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +250 -0
- data/lib/axlsx/workbook/worksheet/row.rb +40 -51
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +21 -3
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/table.rb +6 -6
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +4 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +64 -78
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +10 -10
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
- data/test/drawing/tc_area_chart.rb +39 -0
- data/test/drawing/tc_area_series.rb +71 -0
- data/test/drawing/tc_axis.rb +27 -0
- data/test/drawing/tc_bar_chart.rb +71 -0
- data/test/drawing/tc_bubble_chart.rb +44 -0
- data/test/drawing/tc_bubble_series.rb +21 -0
- data/test/drawing/tc_chart.rb +23 -10
- data/test/drawing/tc_data_source.rb +6 -0
- data/test/drawing/tc_drawing.rb +2 -2
- data/test/drawing/tc_line_chart.rb +5 -5
- data/test/drawing/tc_line_series.rb +47 -6
- data/test/drawing/tc_pic.rb +11 -15
- data/test/drawing/tc_scatter_series.rb +36 -1
- data/test/drawing/tc_str_val.rb +9 -0
- data/test/drawing/tc_title.rb +5 -0
- data/test/stylesheet/tc_styles.rb +2 -2
- data/test/tc_axlsx.rb +31 -0
- data/test/tc_helper.rb +2 -0
- data/test/tc_package.rb +19 -1
- data/test/util/tc_mime_type_utils.rb +13 -0
- data/test/util/tc_simple_typed_list.rb +2 -3
- data/test/util/tc_validators.rb +34 -10
- data/test/workbook/tc_defined_name.rb +12 -4
- data/test/workbook/tc_shared_strings_table.rb +16 -1
- data/test/workbook/tc_workbook.rb +38 -3
- data/test/workbook/tc_workbook_view.rb +50 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
- data/test/workbook/worksheet/tc_break.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +76 -8
- data/test/workbook/worksheet/tc_col.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +11 -11
- data/test/workbook/worksheet/tc_header_footer.rb +2 -2
- data/test/workbook/worksheet/tc_icon_set.rb +1 -1
- data/test/workbook/worksheet/tc_outline_pr.rb +19 -0
- data/test/workbook/worksheet/tc_page_setup.rb +3 -3
- data/test/workbook/worksheet/tc_pivot_table.rb +21 -6
- data/test/workbook/worksheet/tc_print_options.rb +1 -1
- data/test/workbook/worksheet/tc_rich_text.rb +44 -0
- data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
- data/test/workbook/worksheet/tc_row.rb +7 -2
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
- data/test/workbook/worksheet/tc_sheet_pr.rb +26 -4
- data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
- data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
- data/test/workbook/worksheet/tc_table.rb +2 -3
- data/test/workbook/worksheet/tc_worksheet.rb +99 -45
- metadata +89 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed41402c88039c2627ffba600babaf4891f260c120262d40a8ae2759ca9dca3
|
4
|
+
data.tar.gz: ed7540073afe8febc4435eb3bdf0503843e61ce3edb52c2df22fe79708727a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6562cf90cfbf0b9a42012ac225a586e0900486e44930ca5c8ee3e6c3f4c2d3f6d66b8566ac81854f48106bf78732e076ee5cf2771d1cc2ba6abf2cf22dc966e2
|
7
|
+
data.tar.gz: fd1af696b89b4d4a6594e6ef4eb55d98a3170dfa23d9b96bf06de13692b0957bf4c0a329014b2c9be9ca05337845e83bad0b5644c14ac7862eb26ab981f41f7b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **April.1.17**:3.0.0-pre
|
4
|
+
- Support for ruby versions limited to officially supported version
|
5
|
+
- Updates to dependency gems, especially nokogiri and ruby-zip
|
6
|
+
- Patch options parsing for two cell anchor
|
7
|
+
- Remove support for depreciated worksheet members
|
3
8
|
- **November.25.12**:1.3.4
|
4
9
|
- Support for headers and footers for worksheets
|
5
10
|
- bug fix: Properly escape hyperlink urls
|
data/README.md
CHANGED
@@ -1,38 +1,46 @@
|
|
1
|
+
Notice: Community Axlsx organization
|
2
|
+
===================================================
|
3
|
+
All Axlsx related gems have been forked or moved to a community organization: http://github.com/caxlsx
|
4
|
+
* Axlsx
|
5
|
+
* acts_as_axlsx
|
6
|
+
* axlsx_rails
|
7
|
+
* activeadmin-axlsx
|
8
|
+
|
9
|
+
The gems will be released as is as a starting point to allow releases of other gems that depend on these gems. Submit issues as usual.
|
10
|
+
|
11
|
+
Please consider helping develop and test these gems.
|
12
|
+
|
1
13
|
Axlsx: Office Open XML Spreadsheet Generation
|
2
14
|
====================================
|
3
|
-
[![Build Status](https://secure.travis-ci.org/randym/axlsx.
|
15
|
+
[![Build Status](https://secure.travis-ci.org/randym/axlsx.svg?branch=master)](http://travis-ci.org/randym/axlsx/)
|
4
16
|
|
5
|
-
If you are using axlsx for
|
17
|
+
If you are using axlsx for commercial purposes, or just want to show your
|
6
18
|
appreciation for the gem, please don't hesitate to make a donation.
|
7
19
|
|
8
|
-
[![Click here to lend your support to: axlsx and make a donation at www.pledgie.com !](http://www.pledgie.com/campaigns/17814.png?skin_name=chrome)](http://www.pledgie.com/campaigns/17814)
|
9
|
-
|
10
20
|
**IRC**:[irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
|
11
21
|
|
12
|
-
**Git**:[http://github.com/
|
13
|
-
|
14
|
-
**Twitter**: [https://twitter.com/#!/morgan_randy](https://twitter.com/#!/morgan_randy)
|
22
|
+
**Git**:[http://github.com/caxlsx/axlsx](http://github.com/randym/axlsx)
|
15
23
|
|
16
24
|
**Google Group**: [https://groups.google.com/forum/?fromgroups#!forum/axlsx](https://groups.google.com/forum/?fromgroups#!forum/axlsx)
|
17
25
|
|
18
26
|
**Author**: Randy Morgan
|
19
27
|
|
20
|
-
**Copyright**: 2011 -
|
28
|
+
**Copyright**: 2011 - 2017
|
21
29
|
|
22
30
|
**License**: MIT License
|
23
31
|
|
24
|
-
**Latest Version**:
|
32
|
+
**Latest Version**: 3.0.0
|
25
33
|
|
26
|
-
**Ruby Version**:
|
34
|
+
**Ruby Version**: 2.2.7, 2.3.4, 2.4.1
|
27
35
|
|
28
36
|
**JRuby Version**: 1.9 modes
|
29
37
|
|
30
|
-
**Rubinius Version**: rubinius
|
38
|
+
**Rubinius Version**: rubinius 3 * lower versions may run, this gem always tests against head.
|
31
39
|
|
32
40
|
**Release Date**: September 12th 2013
|
33
41
|
|
34
42
|
If you are working in rails, or with active record see:
|
35
|
-
[acts_as_xlsx](http://github.com/
|
43
|
+
[acts_as_xlsx](http://github.com/caxlsx/acts_as_xlsx)
|
36
44
|
|
37
45
|
acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
|
38
46
|
|
@@ -42,7 +50,7 @@ Posts.where(created_at > Time.now-30.days).to_xlsx
|
|
42
50
|
|
43
51
|
** and **
|
44
52
|
|
45
|
-
* http://github.com/
|
53
|
+
* http://github.com/caxlsx/axlsx_rails
|
46
54
|
Axlsx_Rails provides an Axlsx renderer so you can move all your spreadsheet code from your controller into view files. Partials are supported so you can organize any code into reusable chunks (e.g. cover sheets, common styling, etc.) You can use it with acts_as_xlsx, placing the to_xlsx call in a view and add ':package => xlsx_package' to the parameter list. Now you can keep your controllers thin!
|
47
55
|
|
48
56
|
There are guides for using axlsx and acts_as_xlsx here:
|
@@ -50,9 +58,9 @@ There are guides for using axlsx and acts_as_xlsx here:
|
|
50
58
|
|
51
59
|
If you are working with ActiveAdmin see:
|
52
60
|
|
53
|
-
[
|
61
|
+
[activeadmin-axlsx](http://github.com/caxlsx/activeadmin-axlsx)
|
54
62
|
|
55
|
-
It
|
63
|
+
It provides a plugin and dsl for generating downloadable reports.
|
56
64
|
|
57
65
|
The examples directory contains a number of more specific examples as
|
58
66
|
well.
|
@@ -63,7 +71,7 @@ Synopsis
|
|
63
71
|
Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
|
64
72
|
With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, tables, conditional formatting, print options, comments, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification.
|
65
73
|
|
66
|
-
![Screen 1](https://github.com/
|
74
|
+
![Screen 1](https://github.com/caxlsx/axlsx/raw/master/examples/sample.png)
|
67
75
|
|
68
76
|
|
69
77
|
|
@@ -142,7 +150,7 @@ Axlsx::Package.new do |p|
|
|
142
150
|
end
|
143
151
|
```
|
144
152
|
|
145
|
-
Please see the [examples](https://github.com/
|
153
|
+
Please see the [examples](https://github.com/caxlsx/axlsx/tree/master/examples/example.rb) for more.
|
146
154
|
|
147
155
|
{include:file:examples/example.rb}
|
148
156
|
|
@@ -153,7 +161,7 @@ There is much, much more you can do with this gem. If you get stuck, grab me on
|
|
153
161
|
|
154
162
|
This gem is 100% documented with YARD, an exceptional documentation library. To see documentation for this, and all the gems installed on your system use:
|
155
163
|
|
156
|
-
gem install yard
|
164
|
+
gem install yard kramdown
|
157
165
|
|
158
166
|
yard server -g
|
159
167
|
|
@@ -164,7 +172,10 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
|
|
164
172
|
|
165
173
|
#Change log
|
166
174
|
---------
|
167
|
-
|
175
|
+
- **
|
176
|
+
- Added Cell#name so you you can quickly create a defined name for a single cell in your workbook.
|
177
|
+
- Added full book view and sheet state management. This means you can specify how the workbook renders as well as manage sheet visibility.
|
178
|
+
- Added smoothing management for line charts series
|
168
179
|
- **September.12.13**:2.0.1
|
169
180
|
- Unpinned rubyzip version
|
170
181
|
- **September.12.13**:2.0.0
|
@@ -228,16 +239,15 @@ related to themes, which axlsx does not implement at this time.
|
|
228
239
|
- you must set 'use_shared_strings' to true. This is most
|
229
240
|
conveniently done just before rendering by calling Package.use_shared_strings = true prior to serialization.
|
230
241
|
|
231
|
-
```ruby
|
232
|
-
p = Axlsx::Package.new
|
233
|
-
p.workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
|
234
|
-
|
235
|
-
|
236
|
-
end
|
237
|
-
p.use_shared_strings = true
|
238
|
-
p.serialize('simple.xlsx')
|
239
|
-
```
|
240
|
-
|
242
|
+
```ruby
|
243
|
+
p = Axlsx::Package.new
|
244
|
+
p.workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
|
245
|
+
sheet.add_row ["First Column", "Second", "Third"]
|
246
|
+
sheet.add_row [1, 2, 3]
|
247
|
+
end
|
248
|
+
p.use_shared_strings = true
|
249
|
+
p.serialize('simple.xlsx')
|
250
|
+
```
|
241
251
|
- charts do not render
|
242
252
|
|
243
253
|
|
@@ -246,11 +256,9 @@ p.serialize('simple.xlsx')
|
|
246
256
|
Open source software is a community effort. None of this could have been
|
247
257
|
done without the help of these awesome folks.
|
248
258
|
|
249
|
-
[contributors](https://github.com/
|
259
|
+
[contributors](https://github.com/caxlsx/axlsx/graphs/contributors)
|
250
260
|
|
251
|
-
#
|
261
|
+
#License
|
252
262
|
----------
|
253
263
|
|
254
|
-
Axlsx © 2011-2013 by [Randy Morgan](mailto:digial.ipseity@gmail.com).
|
255
|
-
|
256
264
|
Axlsx is licensed under the MIT license. Please see the LICENSE document for more information.
|
data/Rakefile
CHANGED
@@ -9,19 +9,17 @@ task :benchmark do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
task :gendoc do
|
12
|
-
|
13
|
-
|
14
|
-
system "yard stats --list-undoc"
|
12
|
+
system "yardoc"
|
13
|
+
system "yard stats --list-undoc"
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
16
|
+
|
17
|
+
require 'rake/testtask'
|
18
|
+
Rake::TestTask.new do |t|
|
19
|
+
t.libs << 'test'
|
20
|
+
t.test_files = FileList['test/**/tc_*.rb']
|
21
|
+
t.verbose = false
|
22
|
+
t.warning = true
|
25
23
|
end
|
26
24
|
|
27
25
|
task :release => :build do
|
data/examples/auto_filter.rb
CHANGED
@@ -10,7 +10,16 @@ Axlsx::Package.new do |p|
|
|
10
10
|
sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
|
11
11
|
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
|
12
12
|
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
|
13
|
-
sheet.auto_filter = 'A2:D5'
|
13
|
+
sheet.auto_filter = 'A2:D5'
|
14
|
+
sheet.auto_filter.add_column 3, :filters, :filter_items => ['1.9.2']
|
15
|
+
end
|
16
|
+
p.workbook.add_worksheet(:name => "Table 2") do |sheet|
|
17
|
+
sheet.add_row ["Build Matrix"]
|
18
|
+
sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
|
19
|
+
sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
|
20
|
+
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
|
21
|
+
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
|
22
|
+
sheet.auto_filter = 'A2:D5'
|
14
23
|
sheet.auto_filter.add_column 3, :filters, :filter_items => ['1.9.2']
|
15
24
|
end
|
16
25
|
end.serialize('auto_filter.xlsx')
|
@@ -9,10 +9,11 @@ book = p.workbook
|
|
9
9
|
# define your regular styles
|
10
10
|
percent = book.styles.add_style(:format_code => "0.00%", :border => Axlsx::STYLE_THIN_BORDER)
|
11
11
|
money = book.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER)
|
12
|
+
status = book.styles.add_style(:border => Axlsx::STYLE_THIN_BORDER)
|
12
13
|
|
13
14
|
# define the style for conditional formatting
|
14
|
-
profitable = book.styles.add_style( :fg_color => "
|
15
|
-
unprofitable =
|
15
|
+
profitable = book.styles.add_style( :fg_color => "428751", :type => :dxf )
|
16
|
+
unprofitable = book.styles.add_style( :fg_color => "FF0000", :type => :dxf )
|
16
17
|
|
17
18
|
book.add_worksheet(:name => "Cell Is") do |ws|
|
18
19
|
|
@@ -28,7 +29,7 @@ book.add_worksheet(:name => "Cell Is") do |ws|
|
|
28
29
|
# Apply conditional formatting to range B3:B100 in the worksheet
|
29
30
|
ws.add_conditional_formatting("B3:B100", { :type => :cellIs, :operator => :greaterThan, :formula => "100000", :dxfId => profitable, :priority => 1 })
|
30
31
|
# Apply conditional using the between operator; NOTE: supply an array to :formula for between/notBetween
|
31
|
-
|
32
|
+
ws.add_conditional_formatting("C3:C100", { :type => :cellIs, :operator => :between, :formula => ["0.00%","100.00%"], :dxfId => unprofitable, :priority => 1 })
|
32
33
|
end
|
33
34
|
|
34
35
|
book.add_worksheet(:name => "Color Scale") do |ws|
|
@@ -71,4 +72,18 @@ book.add_worksheet(:name => "Icon Set") do |ws|
|
|
71
72
|
ws.add_conditional_formatting("B3:B100", { :type => :iconSet, :dxfId => profitable, :priority => 1, :icon_set => icon_set })
|
72
73
|
end
|
73
74
|
|
75
|
+
book.add_worksheet(:name => "Contains Text") do |ws|
|
76
|
+
ws.add_row ["Previous Year Quarterly Profits (JPY)"]
|
77
|
+
ws.add_row ["Quarter", "Profit", "% of Total", "Status"]
|
78
|
+
offset = 3
|
79
|
+
rows = 20
|
80
|
+
offset.upto(rows + offset) do |i|
|
81
|
+
ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})", (10000*((rows/2-i) * (rows/2-i))) > 100000 ? "PROFIT" : "LOSS"], :style=>[nil, money, percent, status]
|
82
|
+
end
|
83
|
+
|
84
|
+
# Apply conditional formatting to range D3:D100 in the worksheet
|
85
|
+
ws.add_conditional_formatting("D3:D100", { :type => :containsText, :operator => :equal, :text => "PROFIT", :dxfId => profitable, :priority => 1 })
|
86
|
+
ws.add_conditional_formatting("D3:D100", { :type => :containsText, :operator => :equal, :text => "LOSS", :dxfId => unprofitable, :priority => 1 })
|
87
|
+
end
|
88
|
+
|
74
89
|
p.serialize('example_conditional_formatting.xlsx')
|
data/examples/data_validation.rb
CHANGED
@@ -4,47 +4,64 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
|
4
4
|
require 'axlsx'
|
5
5
|
|
6
6
|
p = Axlsx::Package.new
|
7
|
-
p.workbook.add_worksheet do |ws|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:showErrorMessage => true,
|
14
|
-
:errorTitle => 'Wrong input',
|
15
|
-
:error => 'Only values between 5 and 10',
|
16
|
-
:errorStyle => :information,
|
17
|
-
:showInputMessage => true,
|
18
|
-
:promptTitle => 'Be carful!',
|
19
|
-
:prompt => 'Only values between 5 and 10'})
|
20
|
-
|
21
|
-
ws.add_data_validation("B10", {
|
22
|
-
:type => :textLength,
|
23
|
-
:operator => :greaterThan,
|
24
|
-
:formula1 => '10',
|
25
|
-
:showErrorMessage => true,
|
26
|
-
:errorTitle => 'Text is too long',
|
27
|
-
:error => 'Max text length is 10 characters',
|
28
|
-
:errorStyle => :stop,
|
29
|
-
:showInputMessage => true,
|
30
|
-
:promptTitle => 'Text length',
|
31
|
-
:prompt => 'Max text length is 10 characters'})
|
32
|
-
|
33
|
-
8.times do |i|
|
34
|
-
ws.add_row [nil, nil, i*2]
|
7
|
+
p.workbook.add_worksheet do |ws|
|
8
|
+
|
9
|
+
ws.add_row ["between", "lessThan", "bound list", "raw list"]
|
10
|
+
|
11
|
+
4.times do |i|
|
12
|
+
ws.add_row [nil, nil, nil, nil, (i+1) * 2]
|
35
13
|
end
|
36
|
-
|
37
|
-
ws.add_data_validation("
|
38
|
-
:type => :
|
39
|
-
:
|
14
|
+
|
15
|
+
ws.add_data_validation("A2:A5", {
|
16
|
+
:type => :whole,
|
17
|
+
:operator => :between,
|
18
|
+
:formula1 => '5',
|
19
|
+
:formula2 => '10',
|
20
|
+
:showErrorMessage => true,
|
21
|
+
:errorTitle => 'Wrong input',
|
22
|
+
:error => 'Only values between 5 and 10',
|
23
|
+
:errorStyle => :information,
|
24
|
+
:showInputMessage => true,
|
25
|
+
:promptTitle => 'Be careful!',
|
26
|
+
:prompt => %{We really want a value between 5 and 10,
|
27
|
+
but it is OK if you want to break the rules.
|
28
|
+
}})
|
29
|
+
|
30
|
+
ws.add_data_validation("B1:B5", {
|
31
|
+
:type => :textLength,
|
32
|
+
:operator => :lessThan,
|
33
|
+
:formula1 => '10',
|
34
|
+
:showErrorMessage => true,
|
35
|
+
:errorTitle => 'Text is too long',
|
36
|
+
:error => 'Max text length is 10 characters',
|
37
|
+
:errorStyle => :stop,
|
38
|
+
:showInputMessage => true,
|
39
|
+
:promptTitle => 'Text length',
|
40
|
+
:prompt => 'Max text length is 10 characters'})
|
41
|
+
|
42
|
+
ws.add_data_validation("C2:C5", {
|
43
|
+
:type => :list,
|
44
|
+
:formula1 => 'E2:E5',
|
45
|
+
:showDropDown => false,
|
46
|
+
:showErrorMessage => true,
|
47
|
+
:errorTitle => '',
|
48
|
+
:error => 'Only values from E2:E5',
|
49
|
+
:errorStyle => :stop,
|
50
|
+
:showInputMessage => true,
|
51
|
+
:promptTitle => '',
|
52
|
+
:prompt => 'Only values from E2:E5'})
|
53
|
+
|
54
|
+
ws.add_data_validation("D2:D5", {
|
55
|
+
:type => :list,
|
56
|
+
:formula1 => '"Red, Orange, NavyBlue"',
|
40
57
|
:showDropDown => false,
|
41
|
-
:showErrorMessage => true,
|
42
|
-
:errorTitle => '',
|
43
|
-
:error => '
|
44
|
-
:errorStyle => :stop,
|
45
|
-
:showInputMessage => true,
|
46
|
-
:
|
47
|
-
|
58
|
+
:showErrorMessage => true,
|
59
|
+
:errorTitle => '',
|
60
|
+
:error => 'Please use the dropdown selector to choose the value',
|
61
|
+
:errorStyle => :stop,
|
62
|
+
:showInputMessage => true,
|
63
|
+
:prompt => '& Choose the value from the dropdown'})
|
64
|
+
|
48
65
|
end
|
49
66
|
|
50
|
-
p.serialize 'data_validation.xlsx'
|
67
|
+
p.serialize 'data_validation.xlsx'
|
data/examples/example.rb
CHANGED
@@ -14,6 +14,7 @@ examples << :surrounding_border
|
|
14
14
|
examples << :deep_custom_borders
|
15
15
|
examples << :row_column_style
|
16
16
|
examples << :fixed_column_width
|
17
|
+
examples << :height
|
17
18
|
examples << :outline_level
|
18
19
|
examples << :merge_cells
|
19
20
|
examples << :images
|
@@ -21,6 +22,7 @@ examples << :format_dates
|
|
21
22
|
examples << :mbcs
|
22
23
|
examples << :formula
|
23
24
|
examples << :auto_filter
|
25
|
+
examples << :sheet_protection
|
24
26
|
examples << :data_types
|
25
27
|
examples << :override_data_types
|
26
28
|
examples << :hyperlinks
|
@@ -40,13 +42,17 @@ examples << :printing
|
|
40
42
|
examples << :header_footer
|
41
43
|
examples << :comments
|
42
44
|
examples << :panes
|
45
|
+
examples << :book_view
|
43
46
|
examples << :sheet_view
|
47
|
+
examples << :hiding_sheets
|
44
48
|
examples << :conditional_formatting
|
45
49
|
examples << :streaming
|
46
50
|
examples << :shared_strings
|
47
51
|
examples << :no_autowidth
|
48
52
|
examples << :cached_formula
|
49
53
|
examples << :page_breaks
|
54
|
+
examples << :rich_text
|
55
|
+
examples << :tab_color
|
50
56
|
|
51
57
|
p = Axlsx::Package.new
|
52
58
|
wb = p.workbook
|
@@ -207,6 +213,7 @@ if examples.include? :row_column_style
|
|
207
213
|
head = s.add_style :bg_color => "00", :fg_color => "FF"
|
208
214
|
percent = s.add_style :num_fmt => 9
|
209
215
|
wb.add_worksheet(:name => "Columns and Rows") do |sheet|
|
216
|
+
# Note: you must add rows to the document *BEFORE* applying column styles to them
|
210
217
|
sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4', 'col5']
|
211
218
|
sheet.add_row [1, 2, 0.3, 4, 5.0]
|
212
219
|
sheet.add_row [1, 2, 0.2, 4, 5.0]
|
@@ -243,6 +250,21 @@ if examples.include? :fixed_column_width
|
|
243
250
|
end
|
244
251
|
end
|
245
252
|
|
253
|
+
|
254
|
+
##Specifying Row height
|
255
|
+
|
256
|
+
#```ruby
|
257
|
+
if examples.include? :height
|
258
|
+
wb.styles do |s|
|
259
|
+
head = s.add_style :bg_color => "00", :fg_color => "FF"
|
260
|
+
wb.add_worksheet(:name => "fixed row height") do |sheet|
|
261
|
+
sheet.add_row ["This row will have a fixed height", "It will overwite the default row height"], :height => 30
|
262
|
+
sheet.add_row ["This row can have a different height too"], :height => 10, :style => head
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
|
246
268
|
#```ruby
|
247
269
|
if examples.include? :outline_level
|
248
270
|
wb.add_worksheet(name: 'outline_level') do |sheet|
|
@@ -279,13 +301,23 @@ if examples.include? :images
|
|
279
301
|
wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
|
280
302
|
img = File.expand_path('../image1.jpeg', __FILE__)
|
281
303
|
# specifying the :hyperlink option will add a hyper link to your image.
|
304
|
+
#
|
282
305
|
# @note - Numbers does not support this part of the specification.
|
306
|
+
|
283
307
|
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
284
308
|
image.width=720
|
285
309
|
image.height=666
|
286
310
|
image.hyperlink.tooltip = "Labeled Link"
|
287
|
-
image.start_at
|
311
|
+
image.start_at 0, 0
|
288
312
|
end
|
313
|
+
|
314
|
+
# position in block
|
315
|
+
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
316
|
+
image.start_at 22, 14
|
317
|
+
image.end_at 23, 17
|
318
|
+
end
|
319
|
+
# all in one go
|
320
|
+
sheet.add_image(:image_src => img, :start_at => [15, 33], :end_at => [20, 37], :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com")
|
289
321
|
end
|
290
322
|
end
|
291
323
|
#```
|
@@ -470,7 +502,7 @@ if examples.include? :line_chart
|
|
470
502
|
sheet.add_chart(Axlsx::LineChart, :title => "Simple Line Chart", :rotX => 30, :rotY => 20) do |chart|
|
471
503
|
chart.start_at 0, 21
|
472
504
|
chart.end_at 10, 41
|
473
|
-
chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"], :color => "FF0000"
|
505
|
+
chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"], :color => "FF0000", :show_marker => true, :smooth => true
|
474
506
|
chart.add_series :data => sheet["B3:B6"], :title => sheet["B2"], :color => "00FF00"
|
475
507
|
chart.catAxis.title = 'X Axis'
|
476
508
|
chart.valAxis.title = 'Y Axis'
|
@@ -554,6 +586,7 @@ if examples.include? :defined_name
|
|
554
586
|
wb.add_worksheet(:name => 'defined name') do |sheet|
|
555
587
|
sheet.add_row [1, 2, 17, '=FOOBAR']
|
556
588
|
wb.add_defined_name("'defined name'!$C1", :local_sheet_id => sheet.index, :name => 'FOOBAR')
|
589
|
+
wb.add_defined_name("'defined name'!$A$1:$C$1", :local_sheet_id => sheet.index, :name => '_xlnm.Print_Area')
|
557
590
|
end
|
558
591
|
end
|
559
592
|
|
@@ -561,10 +594,17 @@ end
|
|
561
594
|
if examples.include? :sheet_protection
|
562
595
|
unlocked = wb.styles.add_style :locked => false
|
563
596
|
wb.add_worksheet(:name => 'Sheet Protection') do |sheet|
|
564
|
-
sheet.sheet_protection
|
565
|
-
|
566
|
-
|
597
|
+
sheet.sheet_protection do |protection|
|
598
|
+
protection.password = 'fish'
|
599
|
+
protection.auto_filter = false
|
600
|
+
end
|
601
|
+
|
602
|
+
sheet.add_row [1, 2 ,3], :style => unlocked # These cells will be locked
|
603
|
+
sheet.add_row [4, 5, 6]
|
604
|
+
sheet.add_row [7, 8, 9]
|
605
|
+
sheet.auto_filter = "A1:C3"
|
567
606
|
end
|
607
|
+
|
568
608
|
end
|
569
609
|
|
570
610
|
##Specify page margins and other options for printing
|
@@ -644,12 +684,33 @@ if examples.include? :sheet_view
|
|
644
684
|
end
|
645
685
|
end
|
646
686
|
|
687
|
+
## Book Views
|
688
|
+
#
|
689
|
+
## Book views let you specify which sheet the show as active when the user opens the work book as well as a bunch of other
|
690
|
+
## tuning values for the UI @see Axlsx::WorkbookView
|
691
|
+
## ```ruby
|
692
|
+
if examples.include? :book_view
|
693
|
+
# when you open example.xml the second sheet is selected, and the horizontal scroll bar is much smaller showing more sheets
|
694
|
+
wb.add_view tab_ratio: 800, active_tab: 1
|
695
|
+
end
|
647
696
|
|
697
|
+
## Hiding Sheets
|
698
|
+
##
|
699
|
+
## Sheets can be hidden with the state attribute
|
700
|
+
if examples.include? :hiding_sheets
|
701
|
+
wb.add_worksheet name: 'hidden', state: :hidden do |sheet|
|
702
|
+
sheet.add_row ['you cant see me!']
|
703
|
+
end
|
704
|
+
wb.add_worksheet name: 'very hidden', state: :very_hidden do |sheet|
|
705
|
+
sheet.add_row ['you really cant see me!']
|
706
|
+
end
|
707
|
+
end
|
648
708
|
# conditional formatting
|
649
709
|
#
|
650
710
|
if examples.include? :conditional_formatting
|
651
711
|
percent = wb.styles.add_style(:format_code => "0.00%", :border => Axlsx::STYLE_THIN_BORDER)
|
652
712
|
money = wb.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER)
|
713
|
+
status = wb.styles.add_style(:border => Axlsx::STYLE_THIN_BORDER)
|
653
714
|
|
654
715
|
# define the style for conditional formatting
|
655
716
|
profitable = wb.styles.add_style( :fg_color => "FF428751", :type => :dxf )
|
@@ -713,6 +774,19 @@ if examples.include? :conditional_formatting
|
|
713
774
|
icon_set = Axlsx::IconSet.new
|
714
775
|
sheet.add_conditional_formatting("B3:B100", { :type => :iconSet, :dxfId => profitable, :priority => 1, :icon_set => icon_set })
|
715
776
|
end
|
777
|
+
|
778
|
+
wb.add_worksheet(:name => "Contains Text") do |sheet|
|
779
|
+
sheet.add_row ["Previous Year Quarterly Profits (JPY)"]
|
780
|
+
sheet.add_row ["Quarter", "Profit", "% of Total", "Status"]
|
781
|
+
offset = 3
|
782
|
+
rows = 20
|
783
|
+
offset.upto(rows + offset) do |i|
|
784
|
+
sheet.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})", (10000*((rows/2-i) * (rows/2-i))) > 100000 ? "PROFIT" : "LOSS"], :style=>[nil, money, percent, status]
|
785
|
+
end
|
786
|
+
# Apply conditional formatting to range D3:D100 in the worksheet to match words.
|
787
|
+
sheet.add_conditional_formatting("D3:D100", { :type => :containsText, :operator => :equal, :text => "PROFIT", :dxfId => profitable, :priority => 1 })
|
788
|
+
sheet.add_conditional_formatting("D3:D100", { :type => :containsText, :operator => :equal, :text => "LOSS", :dxfId => unprofitable, :priority => 1 })
|
789
|
+
end
|
716
790
|
end
|
717
791
|
|
718
792
|
# Page Breaks
|
@@ -763,8 +837,7 @@ if examples.include? :no_autowidth
|
|
763
837
|
end
|
764
838
|
#```
|
765
839
|
|
766
|
-
|
767
|
-
|
840
|
+
#```ruby
|
768
841
|
if examples.include? :cached_formula
|
769
842
|
p = Axlsx::Package.new
|
770
843
|
p.use_shared_strings = true
|
@@ -774,4 +847,39 @@ if examples.include? :cached_formula
|
|
774
847
|
end
|
775
848
|
p.serialize 'cached_formula.xlsx'
|
776
849
|
end
|
850
|
+
#```
|
851
|
+
|
852
|
+
#```ruby
|
853
|
+
if examples.include? :rich_text
|
854
|
+
p = Axlsx::Package.new
|
855
|
+
p.use_shared_strings = true
|
856
|
+
wb = p.workbook
|
857
|
+
wrap_text = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}} )
|
858
|
+
rt = Axlsx::RichText.new
|
859
|
+
rt.add_run('I\'m bold, ', :b => true)
|
860
|
+
rt.add_run('I\'m italic, ', :i => true)
|
861
|
+
rt.add_run('I\'m strike' + "\n", :strike => true)
|
862
|
+
rt.add_run('I\'m bold, italic and strike' + "\n", :b => true, :i => true, :strike => true)
|
863
|
+
rt.add_run('I\'m style-less :D')
|
864
|
+
wb.add_worksheet(:name => "RichText") do | sheet |
|
865
|
+
sheet.add_row [rt], :style => wrap_text
|
866
|
+
end
|
867
|
+
p.serialize 'rich_text.xlsx'
|
868
|
+
end
|
869
|
+
#```
|
870
|
+
|
871
|
+
##Change tab color of sheet
|
872
|
+
|
873
|
+
#```ruby
|
874
|
+
if examples.include? :tab_color
|
875
|
+
p = Axlsx::Package.new
|
876
|
+
p.use_shared_strings = true
|
877
|
+
wb = p.workbook
|
878
|
+
wb.add_worksheet(:name => "Change Tab Color") do |sheet|
|
879
|
+
sheet.add_row ["Check", "out", "the", "Tab Color", "below!"]
|
880
|
+
sheet.sheet_pr.tab_color = "FFFF6666"
|
881
|
+
end
|
882
|
+
p.serialize 'tab_color.xlsx'
|
883
|
+
end
|
884
|
+
##```
|
777
885
|
|