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/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
CHANGELOG
|
|
2
2
|
---------
|
|
3
|
+
- ** February.2.12**: 1.0.16 release
|
|
4
|
+
https://github.com/randym/axlsx/compare/1.0.15...1.0.16
|
|
5
|
+
- Bug fix for schema file locations when validating in rails
|
|
6
|
+
- Added hyperlink to images
|
|
7
|
+
- date1904 now automatically set in BSD and mac environments
|
|
8
|
+
- removed whitespace/indentation from xml outputs
|
|
9
|
+
- col_style now skips rows that do not contain cells at the column index
|
|
10
|
+
|
|
11
|
+
- **January.6.12**: 1.0.15 release
|
|
12
|
+
https://github.com/randym/axlsx/compare/1.0.14...1.0.15
|
|
13
|
+
- Bug fix add_style specified number formats must be explicity applied for libraOffice
|
|
14
|
+
- performance improvements from ochko when creating cells with options.
|
|
15
|
+
- Bug fix setting types=>[:n] when adding a row incorrectly determines the cell type to be string as the value is null during creation.
|
|
16
|
+
- Release in preparation for password protection merge
|
|
17
|
+
|
|
3
18
|
- **December.14.11**: 1.0.14 release
|
|
4
19
|
- Added support for merging cells
|
|
5
20
|
- Added support for auto filters
|
|
@@ -8,7 +23,7 @@ CHANGELOG
|
|
|
8
23
|
- Updated examples to output to a single workbook with multiple sheets
|
|
9
24
|
- Added access to app and core package objects so you can set the creator and other properties of the package
|
|
10
25
|
- The beginning of password protected xlsx files - roadmapped for January release.
|
|
11
|
-
|
|
26
|
+
|
|
12
27
|
- **December.8.11**: 1.0.13 release
|
|
13
28
|
- Fixing .gemspec errors that caused gem to miss the lib directory. Sorry about that.
|
|
14
29
|
|
|
@@ -55,7 +70,7 @@ CHANGELOG
|
|
|
55
70
|
##October.22.11: 1.0.6 release
|
|
56
71
|
- Bumping version to include docs. Bug in gemspec pointing to incorrect directory.
|
|
57
72
|
|
|
58
|
-
##October.22.11: 1.05
|
|
73
|
+
##October.22.11: 1.05
|
|
59
74
|
- Added support for line charts
|
|
60
75
|
- Updated examples and readme
|
|
61
76
|
- Updated series title to be a real title ** NOTE ** If you are accessing titles directly you will need to update text assignation.
|
|
@@ -63,7 +78,7 @@ CHANGELOG
|
|
|
63
78
|
chart.series.first.title.text = 'Your Title'
|
|
64
79
|
With this change you can assign a cell for the series title
|
|
65
80
|
chart.series.title = sheet.rows.first.cells.first
|
|
66
|
-
If you are using the recommended
|
|
81
|
+
If you are using the recommended
|
|
67
82
|
chart.add_series :data=>[], :labels=>[], :title
|
|
68
83
|
You do not have to change anything.
|
|
69
84
|
- BugFix: shape attribute for bar chart is now properly serialized
|
data/README.md
CHANGED
|
@@ -2,24 +2,34 @@ Axlsx: Office Open XML Spreadsheet Generation
|
|
|
2
2
|
====================================
|
|
3
3
|
[](http://travis-ci.org/randym/axlsx/)
|
|
4
4
|
|
|
5
|
-
**IRC**: [irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
|
|
6
|
-
**Git**: [http://github.com/randym/axlsx](http://github.com/randym/axlsx)
|
|
7
|
-
**Author**: Randy Morgan
|
|
8
|
-
**Copyright**: 2011
|
|
9
|
-
**License**: MIT License
|
|
10
|
-
**Latest Version**: 1.0.16
|
|
11
|
-
**Ruby Version**: 1.8.7, 1.9.2, 1.9.3
|
|
5
|
+
**IRC**: [irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
|
|
12
6
|
|
|
13
|
-
**
|
|
7
|
+
**Git**: [http://github.com/randym/axlsx](http://github.com/randym/axlsx)
|
|
8
|
+
|
|
9
|
+
**Twitter**: [https://twitter.com/#!/morgan_randy](https://twitter.com/#!/morgan_randy) release announcements and news will be published here
|
|
10
|
+
|
|
11
|
+
**Author**: Randy Morgan
|
|
12
|
+
|
|
13
|
+
**Copyright**: 2011 - 2012
|
|
14
|
+
|
|
15
|
+
**License**: MIT License
|
|
16
|
+
|
|
17
|
+
**Latest Version**: 1.1.0
|
|
18
|
+
|
|
19
|
+
**Ruby Version**: 1.8.7, 1.9.2, 1.9.3
|
|
20
|
+
|
|
21
|
+
**JRuby Version**: 1.6.7
|
|
22
|
+
|
|
23
|
+
**Release Date**: April 3st 2012
|
|
14
24
|
|
|
15
25
|
Synopsis
|
|
16
26
|
--------
|
|
17
27
|
|
|
18
28
|
Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
|
|
19
|
-
With Axlsx you can create excel worksheets with charts, images, automated column
|
|
29
|
+
With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, 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.
|
|
20
30
|
|
|
21
31
|
If you are working in rails, or with active record see:
|
|
22
|
-
http://github.com/randym/acts_as_xlsx
|
|
32
|
+
http://github.com/randym/acts_as_xlsx
|
|
23
33
|
|
|
24
34
|
There are guides for using axlsx and acts_as_xlsx here:
|
|
25
35
|
[http://axlsx.blogspot.com](http://axlsx.blogspot.com)
|
|
@@ -27,28 +37,28 @@ There are guides for using axlsx and acts_as_xlsx here:
|
|
|
27
37
|
Help Wanted
|
|
28
38
|
-----------
|
|
29
39
|
|
|
30
|
-
I'd really like to get rid of the
|
|
40
|
+
I'd really like to get rid of the dependency on RMagick in this gem. RMagic is being used to calculate the column widths in a worksheet based on the content the user specified. If there happens to be anyone out there with the background and c skills to write an extension that can determine the width of a single character rendered with a specific font at a specific font size please give me a shout.
|
|
31
41
|
|
|
32
42
|
Feature List
|
|
33
43
|
------------
|
|
34
|
-
|
|
35
|
-
**1. Author xlsx documents: Axlsx is made to let you easily and quickly generate
|
|
44
|
+
|
|
45
|
+
**1. Author xlsx documents: Axlsx is made to let you easily and quickly generate professional xlsx based reports that can be validated before serialization.
|
|
36
46
|
|
|
37
47
|
**2. Generate 3D Pie, Line and Bar Charts: With Axlsx chart generation and management is as easy as a few lines of code. You can build charts based off data in your worksheet or generate charts without any data in your sheet at all.
|
|
38
|
-
|
|
48
|
+
|
|
39
49
|
**3. Custom Styles: With guaranteed document validity, you can style borders, alignment, fills, fonts, and number formats in a single line of code. Those styles can be applied to an entire row, or a single cell anywhere in your workbook.
|
|
40
50
|
|
|
41
|
-
**4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String
|
|
51
|
+
**4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String, Date, Time and Boolean types are automatically identified and serialized to your spreadsheet.
|
|
42
52
|
|
|
43
|
-
**5. Automatic column widths: Axlsx will automatically determine the appropriate width for your columns based on the content in the worksheet.
|
|
53
|
+
**5. Automatic and fixed column widths: Axlsx will automatically determine the appropriate width for your columns based on the content in the worksheet, or use any value you specify for the really funky stuff.
|
|
44
54
|
|
|
45
|
-
**6. Support for automatically formatted 1904 and 1900
|
|
55
|
+
**6. Support for automatically formatted 1904 and 1900 epochs configurable in the workbook.
|
|
46
56
|
|
|
47
57
|
**7. Add jpg, gif and png images to worksheets with hyperlinks
|
|
48
58
|
|
|
49
|
-
**8.
|
|
59
|
+
**8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheet1!A3:B4" style references
|
|
50
60
|
|
|
51
|
-
**9. Cell level style overrides for default and customized style
|
|
61
|
+
**9. Cell level style overrides for default and customized style objects
|
|
52
62
|
|
|
53
63
|
**10. Support for formulas
|
|
54
64
|
|
|
@@ -56,13 +66,19 @@ Feature List
|
|
|
56
66
|
|
|
57
67
|
**12. Auto filtering tables with worksheet.auto_filter
|
|
58
68
|
|
|
69
|
+
**13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
|
|
70
|
+
|
|
71
|
+
**14. Output to file or StringIO
|
|
72
|
+
|
|
73
|
+
**15. Support for page margins
|
|
74
|
+
|
|
59
75
|
Installing
|
|
60
76
|
----------
|
|
61
77
|
|
|
62
78
|
To install Axlsx, use the following command:
|
|
63
79
|
|
|
64
80
|
$ gem install axlsx
|
|
65
|
-
|
|
81
|
+
|
|
66
82
|
#Usage
|
|
67
83
|
------
|
|
68
84
|
|
|
@@ -78,18 +94,19 @@ To install Axlsx, use the following command:
|
|
|
78
94
|
sheet.add_row [1, 2, 3]
|
|
79
95
|
end
|
|
80
96
|
|
|
81
|
-
##Using Custom Styles
|
|
97
|
+
##Using Custom Styles and Row Heights
|
|
82
98
|
|
|
83
99
|
wb.styles do |s|
|
|
84
100
|
black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
|
|
85
101
|
blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
|
|
86
102
|
wb.add_worksheet(:name => "Custom Styles") do |sheet|
|
|
87
103
|
sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
|
|
88
|
-
sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
|
|
104
|
+
sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER, :height => 20
|
|
89
105
|
end
|
|
90
106
|
end
|
|
91
107
|
|
|
92
108
|
##Using Custom Formatting and date1904
|
|
109
|
+
|
|
93
110
|
require 'date'
|
|
94
111
|
wb.styles do |s|
|
|
95
112
|
date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
|
|
@@ -105,25 +122,25 @@ To install Axlsx, use the following command:
|
|
|
105
122
|
##Add an Image
|
|
106
123
|
|
|
107
124
|
wb.add_worksheet(:name => "Images") do |sheet|
|
|
108
|
-
img = File.expand_path('examples/image1.jpeg')
|
|
125
|
+
img = File.expand_path('examples/image1.jpeg')
|
|
109
126
|
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
|
|
110
127
|
image.width=720
|
|
111
128
|
image.height=666
|
|
112
129
|
image.start_at 2, 2
|
|
113
130
|
end
|
|
114
|
-
end
|
|
131
|
+
end
|
|
115
132
|
|
|
116
133
|
##Add an Image with a hyperlink
|
|
117
134
|
|
|
118
135
|
wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
|
|
119
|
-
img = File.expand_path('examples/image1.jpeg')
|
|
136
|
+
img = File.expand_path('examples/image1.jpeg')
|
|
120
137
|
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
|
121
138
|
image.width=720
|
|
122
139
|
image.height=666
|
|
123
140
|
image.hyperlink.tooltip = "Labeled Link"
|
|
124
141
|
image.start_at 2, 2
|
|
125
142
|
end
|
|
126
|
-
end
|
|
143
|
+
end
|
|
127
144
|
|
|
128
145
|
##Asian Language Support
|
|
129
146
|
|
|
@@ -131,7 +148,7 @@ To install Axlsx, use the following command:
|
|
|
131
148
|
sheet.add_row ["日本語"]
|
|
132
149
|
sheet.add_row ["华语/華語"]
|
|
133
150
|
sheet.add_row ["한국어/조선말"]
|
|
134
|
-
end
|
|
151
|
+
end
|
|
135
152
|
|
|
136
153
|
##Styling Columns
|
|
137
154
|
|
|
@@ -146,6 +163,20 @@ To install Axlsx, use the following command:
|
|
|
146
163
|
end
|
|
147
164
|
end
|
|
148
165
|
|
|
166
|
+
##Hiding Columns
|
|
167
|
+
|
|
168
|
+
wb.styles do |s|
|
|
169
|
+
percent = s.add_style :num_fmt => 9
|
|
170
|
+
wb.add_worksheet(:name => "Hidden Column") do |sheet|
|
|
171
|
+
sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
|
|
172
|
+
sheet.add_row [1, 2, 0.3, 4]
|
|
173
|
+
sheet.add_row [1, 2, 0.2, 4]
|
|
174
|
+
sheet.add_row [1, 2, 0.1, 4]
|
|
175
|
+
sheet.col_style 2, percent, :row_offset => 1
|
|
176
|
+
sheet.column_info[1].hidden = true
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
149
180
|
##Styling Rows
|
|
150
181
|
|
|
151
182
|
wb.styles do |s|
|
|
@@ -170,7 +201,7 @@ To install Axlsx, use the following command:
|
|
|
170
201
|
# cell level style overrides via sheet range
|
|
171
202
|
sheet["A1:D1"].each { |c| c.color = "FF0000"}
|
|
172
203
|
sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
|
173
|
-
end
|
|
204
|
+
end
|
|
174
205
|
|
|
175
206
|
##Using formula
|
|
176
207
|
|
|
@@ -179,6 +210,13 @@ To install Axlsx, use the following command:
|
|
|
179
210
|
sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
|
|
180
211
|
end
|
|
181
212
|
|
|
213
|
+
##Automatic cell types
|
|
214
|
+
|
|
215
|
+
wb.add_worksheet(:name => "Automatic cell types") do |sheet|
|
|
216
|
+
sheet.add_row ["Date", "Time", "String", "Boolean", "Float", "Integer"]
|
|
217
|
+
sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1]
|
|
218
|
+
end
|
|
219
|
+
|
|
182
220
|
##Merging Cells.
|
|
183
221
|
|
|
184
222
|
wb.add_worksheet(:name => 'Merging Cells') do |sheet|
|
|
@@ -190,7 +228,7 @@ To install Axlsx, use the following command:
|
|
|
190
228
|
sheet.merge_cells("A4:C4")
|
|
191
229
|
sheet["A1:D1"].each { |c| c.color = "FF0000"}
|
|
192
230
|
sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
|
193
|
-
end
|
|
231
|
+
end
|
|
194
232
|
|
|
195
233
|
##Generating A Bar Chart
|
|
196
234
|
|
|
@@ -201,7 +239,7 @@ To install Axlsx, use the following command:
|
|
|
201
239
|
sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
|
|
202
240
|
chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
|
|
203
241
|
end
|
|
204
|
-
end
|
|
242
|
+
end
|
|
205
243
|
|
|
206
244
|
##Generating A Pie Chart
|
|
207
245
|
|
|
@@ -211,7 +249,7 @@ To install Axlsx, use the following command:
|
|
|
211
249
|
sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
|
|
212
250
|
chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
|
|
213
251
|
end
|
|
214
|
-
end
|
|
252
|
+
end
|
|
215
253
|
|
|
216
254
|
##Data over time
|
|
217
255
|
|
|
@@ -225,9 +263,9 @@ To install Axlsx, use the following command:
|
|
|
225
263
|
sheet.add_chart(Axlsx::Bar3DChart) do |chart|
|
|
226
264
|
chart.start_at "B7"
|
|
227
265
|
chart.end_at "H27"
|
|
228
|
-
chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
|
|
229
|
-
end
|
|
230
|
-
end
|
|
266
|
+
chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
|
|
267
|
+
end
|
|
268
|
+
end
|
|
231
269
|
|
|
232
270
|
##Generating A Line Chart
|
|
233
271
|
|
|
@@ -238,9 +276,24 @@ To install Axlsx, use the following command:
|
|
|
238
276
|
chart.start_at 0, 2
|
|
239
277
|
chart.end_at 10, 15
|
|
240
278
|
chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
|
|
241
|
-
chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
|
|
242
|
-
end
|
|
243
|
-
end
|
|
279
|
+
chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
##Generating A Scatter Chart
|
|
284
|
+
|
|
285
|
+
wb.add_worksheet(:name => "Scatter Chart") do |sheet|
|
|
286
|
+
sheet.add_row ["First", 1, 5, 7, 9]
|
|
287
|
+
sheet.add_row ["", 1, 25, 49, 81]
|
|
288
|
+
sheet.add_row ["Second", 5, 2, 14, 9]
|
|
289
|
+
sheet.add_row ["", 5, 10, 15, 20]
|
|
290
|
+
sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart|
|
|
291
|
+
chart.start_at 0, 4
|
|
292
|
+
chart.end_at 10, 19
|
|
293
|
+
chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"]
|
|
294
|
+
chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"]
|
|
295
|
+
end
|
|
296
|
+
end
|
|
244
297
|
|
|
245
298
|
##Auto Filter
|
|
246
299
|
|
|
@@ -251,13 +304,62 @@ To install Axlsx, use the following command:
|
|
|
251
304
|
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
|
|
252
305
|
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
|
|
253
306
|
sheet.auto_filter = "A2:D5"
|
|
254
|
-
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
##Specifying Column Widths
|
|
310
|
+
|
|
311
|
+
wb.add_worksheet(:name => "custom column widths") do |sheet|
|
|
312
|
+
sheet.add_row ["I use auto_fit and am very wide", "I use a custom width and am narrow"]
|
|
313
|
+
sheet.column_widths nil, 3
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
##Specify Page Margins for printing
|
|
317
|
+
|
|
318
|
+
margins = {:left => 3, :right => 3, :top => 1.2, :bottom => 1.2, :header => 0.7, :footer => 0.7}
|
|
319
|
+
wb.add_worksheet(:name => "print margins", :page_margins => margins) do |sheet|
|
|
320
|
+
sheet.add_row["this sheet uses customized page margins for printing"]
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
##Fit to page printing
|
|
324
|
+
|
|
325
|
+
wb.add_worksheet(:name => "fit to page") do |sheet|
|
|
326
|
+
sheet.add_row ['this all goes on one page']
|
|
327
|
+
sheet.fit_to_page = true
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
##Hide Gridlines in worksheet
|
|
332
|
+
|
|
333
|
+
wb.add_worksheet(:name => "No Gridlines") do |sheet|
|
|
334
|
+
sheet.add_row ["This", "Sheet", "Hides", "Gridlines"]
|
|
335
|
+
sheet.show_gridlines = false
|
|
336
|
+
end
|
|
255
337
|
|
|
256
338
|
##Validate and Serialize
|
|
257
339
|
|
|
258
340
|
p.validate.each { |e| puts e.message }
|
|
259
341
|
p.serialize("example.xlsx")
|
|
260
342
|
|
|
343
|
+
# alternatively, serialize to StringIO
|
|
344
|
+
s = p.to_stream()
|
|
345
|
+
File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
|
|
346
|
+
|
|
347
|
+
##Using Shared Strings
|
|
348
|
+
|
|
349
|
+
p.use_shared_strings = true
|
|
350
|
+
p.serialize("shared_strings_example.xlsx")
|
|
351
|
+
|
|
352
|
+
##Disabling Autowidth
|
|
353
|
+
|
|
354
|
+
p = Axlsx::Package.new
|
|
355
|
+
p.use_autowidth = false
|
|
356
|
+
wb = p.workbook
|
|
357
|
+
wb.add_worksheet(:name => "No Magick") do | sheet |
|
|
358
|
+
sheet.add_row ['oh look! no autowidth - and no magick loaded in your process']
|
|
359
|
+
end
|
|
360
|
+
p.validate.each { |e| puts e.message }
|
|
361
|
+
p.serialize("no-use_autowidth.xlsx")
|
|
362
|
+
|
|
261
363
|
|
|
262
364
|
#Documentation
|
|
263
365
|
--------------
|
|
@@ -269,23 +371,43 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
|
|
|
269
371
|
#Specs
|
|
270
372
|
------
|
|
271
373
|
This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
|
|
272
|
-
|
|
273
|
-
#
|
|
374
|
+
|
|
375
|
+
#Change log
|
|
274
376
|
---------
|
|
275
|
-
- **
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
-
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
|
|
282
|
-
-
|
|
283
|
-
-
|
|
284
|
-
-
|
|
285
|
-
-
|
|
286
|
-
-
|
|
287
|
-
|
|
288
|
-
|
|
377
|
+
- ** April.3.12**: 1.1.0 release
|
|
378
|
+
- bugfix patch name_to_indecies to properly handle extended ranges.
|
|
379
|
+
- bugfix properly serialize chart title.
|
|
380
|
+
- lower rake minimum requirement for 1.8.7 apps that don't want to move on to 0.9 NOTE this will be reverted for 2.0.0 with workbook parsing!
|
|
381
|
+
- Added Fit to Page printing
|
|
382
|
+
- added support for turning off gridlines in charts.
|
|
383
|
+
- added support for turning off gridlines in worksheet.
|
|
384
|
+
- bugfix some apps like libraoffice require apply[x] attributes to be true. applyAlignment is now properly set.
|
|
385
|
+
- added option use_autowidth. When this is false RMagick will not be loaded or used in the stack. However it is still a requirement in the gem.
|
|
386
|
+
- added border style specification to styles#add_style. See the example in the readme.
|
|
387
|
+
- Support for tables added in - Note: Pre 2011 versions of Mac office do not support this feature and will warn.
|
|
388
|
+
- Support for splatter charts added
|
|
389
|
+
- Major (like 7x faster!) performance updates.
|
|
390
|
+
- Gem now supports for JRuby 1.6.7, as well as expirimental support for Rubinius
|
|
391
|
+
|
|
392
|
+
- ** March.5.12**: 1.0.18 release
|
|
393
|
+
https://github.com/randym/axlsx/compare/1.0.17...1.0.18
|
|
394
|
+
- bugfix custom borders are not properly applied when using styles.add_style
|
|
395
|
+
- interop worksheet names must be 31 characters or less or some versions of office complain about repairs
|
|
396
|
+
- added type support for :boolean and :date types cell values
|
|
397
|
+
- added support for fixed column widths
|
|
398
|
+
- added support for page_margins
|
|
399
|
+
- added << alias for add_row
|
|
400
|
+
- removed presetting of date1904 based on authoring platform. Now defaults to use 1900 epoch (date1904 = false)
|
|
401
|
+
|
|
402
|
+
- ** February.14.12**: 1.0.17 release
|
|
403
|
+
https://github.com/randym/axlsx/compare/1.0.16...1.0.17
|
|
404
|
+
- Added in support for serializing to StringIO
|
|
405
|
+
- Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers
|
|
406
|
+
- Added in support for fixed column_widths
|
|
407
|
+
- Removed unneeded dependencies on active-support and i18n
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
289
411
|
Please see the {file:CHANGELOG.md} document for past release information.
|
|
290
412
|
|
|
291
413
|
#Thanks!
|
|
@@ -294,8 +416,20 @@ Please see the {file:CHANGELOG.md} document for past release information.
|
|
|
294
416
|
|
|
295
417
|
[kleine2](https://github.com/kleine2) - for generously donating in return for the image hyperlink feature.
|
|
296
418
|
|
|
419
|
+
[ffmike](https://github.com/ffmike) - for knocking down an over restrictive i18n dependency, massive patience and great communication skills.
|
|
420
|
+
|
|
421
|
+
[JonathanTron](https://github.com/JonathanTron) - for giving the gem some style, and making sure it applies.
|
|
422
|
+
|
|
423
|
+
[JosephHalter](https://github.com/JosephHalter) - for making sure we arrive at the right time on the right date.
|
|
424
|
+
|
|
425
|
+
[noniq](https://github.com/noniq) - for keeping true to the gem's style, and making sure what we put on paper does not get marginalized.
|
|
426
|
+
|
|
427
|
+
[jurriaan](https://github.com/jurriaan) - for showing there is more than one way to skin a cat, and work with rows while you are at it.
|
|
428
|
+
|
|
429
|
+
[joekain](https://github.com/joekain) - for keeping our references working even in the double digits!
|
|
430
|
+
|
|
297
431
|
#Copyright and License
|
|
298
432
|
----------
|
|
299
433
|
|
|
300
|
-
Axlsx © 2011 by [Randy Morgan](mailto:digial.ipseity@gmail.com). Axlsx is
|
|
434
|
+
Axlsx © 2011-2012 by [Randy Morgan](mailto:digial.ipseity@gmail.com). Axlsx is
|
|
301
435
|
licensed under the MIT license. Please see the {file:LICENSE} document for more information.
|