axlsx 1.0.15 → 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 +40 -2
- data/README.md +223 -92
- data/examples/example.csv +1000 -0
- data/examples/example.rb +266 -132
- 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 +27 -12
- data/lib/axlsx/drawing/graphic_frame.rb +22 -21
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb +96 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +64 -0
- 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 +47 -33
- 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 +117 -52
- data/lib/axlsx/rels/relationship.rb +27 -8
- data/lib/axlsx/rels/relationships.rb +9 -2
- 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 +69 -33
- data/lib/axlsx/util/constants.rb +39 -20
- data/lib/axlsx/util/ms_off_crypto.rb +10 -10
- 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 -1
- data/lib/axlsx/util/validators.rb +23 -7
- data/lib/axlsx/version.rb +5 -2
- 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 +82 -26
- 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 +270 -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 +69 -0
- 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 +13 -8
- 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 +10 -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 +198 -31
- metadata +167 -111
- data/test/drawing/tc_line_series.tc~ +0 -34
- data/test/drawing/tc_picture_locking.rb~ +0 -77
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
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
|
+
|
|
18
|
+
- **December.14.11**: 1.0.14 release
|
|
19
|
+
- Added support for merging cells
|
|
20
|
+
- Added support for auto filters
|
|
21
|
+
- Improved auto width calculations
|
|
22
|
+
- Improved charts
|
|
23
|
+
- Updated examples to output to a single workbook with multiple sheets
|
|
24
|
+
- Added access to app and core package objects so you can set the creator and other properties of the package
|
|
25
|
+
- The beginning of password protected xlsx files - roadmapped for January release.
|
|
26
|
+
|
|
27
|
+
- **December.8.11**: 1.0.13 release
|
|
28
|
+
- Fixing .gemspec errors that caused gem to miss the lib directory. Sorry about that.
|
|
29
|
+
|
|
30
|
+
- **December.7.11**: 1.0.12 release
|
|
31
|
+
DO NOT USE THIS VERSION = THE GEM IS BROKEN
|
|
32
|
+
- changed dependency from 'zip' gem to 'rubyzip' and added conditional code to force binary encoding to resolve issue with excel 2011
|
|
33
|
+
- Patched bug in app.xml that would ignore user specified properties.
|
|
34
|
+
- **December.5.11**: 1.0.11 release
|
|
35
|
+
- Added [] methods to worksheet and workbook to provide name based access to cells.
|
|
36
|
+
- Added support for functions as cell values
|
|
37
|
+
- Updated color creation so that two character shorthand values can be used like 'FF' for 'FFFFFFFF' or 'D8' for 'FFD8D8D8'
|
|
38
|
+
- Examples for all this fun stuff added to the readme
|
|
39
|
+
- Clean up and support for 1.9.2 and travis integration
|
|
40
|
+
- Added support for string based cell referencing to chart start_at and end_at. That means you can now use :start_at=>"A1" when using worksheet.add_chart, or chart.start_at ="A1" in addition to passing a cell or the x, y coordinates.
|
|
3
41
|
|
|
4
42
|
- **October.30.11**: 1.0.10 release
|
|
5
43
|
- Updating gemspec to lower gem version requirements.
|
|
@@ -32,7 +70,7 @@ CHANGELOG
|
|
|
32
70
|
##October.22.11: 1.0.6 release
|
|
33
71
|
- Bumping version to include docs. Bug in gemspec pointing to incorrect directory.
|
|
34
72
|
|
|
35
|
-
##October.22.11: 1.05
|
|
73
|
+
##October.22.11: 1.05
|
|
36
74
|
- Added support for line charts
|
|
37
75
|
- Updated examples and readme
|
|
38
76
|
- Updated series title to be a real title ** NOTE ** If you are accessing titles directly you will need to update text assignation.
|
|
@@ -40,7 +78,7 @@ CHANGELOG
|
|
|
40
78
|
chart.series.first.title.text = 'Your Title'
|
|
41
79
|
With this change you can assign a cell for the series title
|
|
42
80
|
chart.series.title = sheet.rows.first.cells.first
|
|
43
|
-
If you are using the recommended
|
|
81
|
+
If you are using the recommended
|
|
44
82
|
chart.add_series :data=>[], :labels=>[], :title
|
|
45
83
|
You do not have to change anything.
|
|
46
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.15
|
|
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
|
-
**7. Add jpg, gif and png images to worksheets
|
|
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,29 +94,62 @@ 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
|
-
##Using Custom Formatting
|
|
108
|
+
##Using Custom Formatting and date1904
|
|
93
109
|
|
|
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)
|
|
96
113
|
padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
|
|
97
114
|
percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
|
|
115
|
+
wb.date1904 = true # required for generation on mac
|
|
98
116
|
wb.add_worksheet(:name => "Formatting Data") do |sheet|
|
|
99
117
|
sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
|
|
100
|
-
sheet.add_row [
|
|
118
|
+
sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
|
|
101
119
|
end
|
|
102
120
|
end
|
|
103
121
|
|
|
122
|
+
##Add an Image
|
|
123
|
+
|
|
124
|
+
wb.add_worksheet(:name => "Images") do |sheet|
|
|
125
|
+
img = File.expand_path('examples/image1.jpeg')
|
|
126
|
+
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
|
|
127
|
+
image.width=720
|
|
128
|
+
image.height=666
|
|
129
|
+
image.start_at 2, 2
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
##Add an Image with a hyperlink
|
|
134
|
+
|
|
135
|
+
wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
|
|
136
|
+
img = File.expand_path('examples/image1.jpeg')
|
|
137
|
+
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
|
138
|
+
image.width=720
|
|
139
|
+
image.height=666
|
|
140
|
+
image.hyperlink.tooltip = "Labeled Link"
|
|
141
|
+
image.start_at 2, 2
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
##Asian Language Support
|
|
146
|
+
|
|
147
|
+
wb.add_worksheet(:name => "Unicode Support") do |sheet|
|
|
148
|
+
sheet.add_row ["日本語"]
|
|
149
|
+
sheet.add_row ["华语/華語"]
|
|
150
|
+
sheet.add_row ["한국어/조선말"]
|
|
151
|
+
end
|
|
152
|
+
|
|
104
153
|
##Styling Columns
|
|
105
154
|
|
|
106
155
|
wb.styles do |s|
|
|
@@ -114,6 +163,20 @@ To install Axlsx, use the following command:
|
|
|
114
163
|
end
|
|
115
164
|
end
|
|
116
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
|
+
|
|
117
180
|
##Styling Rows
|
|
118
181
|
|
|
119
182
|
wb.styles do |s|
|
|
@@ -138,27 +201,7 @@ To install Axlsx, use the following command:
|
|
|
138
201
|
# cell level style overrides via sheet range
|
|
139
202
|
sheet["A1:D1"].each { |c| c.color = "FF0000"}
|
|
140
203
|
sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
##Add an Image
|
|
144
|
-
|
|
145
|
-
wb.add_worksheet(:name => "Images") do |sheet|
|
|
146
|
-
img = File.expand_path('examples/image1.jpeg')
|
|
147
|
-
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
|
|
148
|
-
image.width=720
|
|
149
|
-
image.height=666
|
|
150
|
-
image.start_at 2, 2
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
##Asian Language Support
|
|
155
|
-
|
|
156
|
-
wb.add_worksheet(:name => "Unicode Support") do |sheet|
|
|
157
|
-
sheet.add_row ["日本語"]
|
|
158
|
-
sheet.add_row ["华语/華語"]
|
|
159
|
-
sheet.add_row ["한국어/조선말"]
|
|
160
|
-
end
|
|
161
|
-
|
|
204
|
+
end
|
|
162
205
|
|
|
163
206
|
##Using formula
|
|
164
207
|
|
|
@@ -167,8 +210,14 @@ To install Axlsx, use the following command:
|
|
|
167
210
|
sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
|
|
168
211
|
end
|
|
169
212
|
|
|
213
|
+
##Automatic cell types
|
|
170
214
|
|
|
171
|
-
|
|
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
|
+
|
|
220
|
+
##Merging Cells.
|
|
172
221
|
|
|
173
222
|
wb.add_worksheet(:name => 'Merging Cells') do |sheet|
|
|
174
223
|
# cell level style overides when adding cells
|
|
@@ -179,7 +228,7 @@ To install Axlsx, use the following command:
|
|
|
179
228
|
sheet.merge_cells("A4:C4")
|
|
180
229
|
sheet["A1:D1"].each { |c| c.color = "FF0000"}
|
|
181
230
|
sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
|
182
|
-
end
|
|
231
|
+
end
|
|
183
232
|
|
|
184
233
|
##Generating A Bar Chart
|
|
185
234
|
|
|
@@ -190,7 +239,7 @@ To install Axlsx, use the following command:
|
|
|
190
239
|
sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
|
|
191
240
|
chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
|
|
192
241
|
end
|
|
193
|
-
end
|
|
242
|
+
end
|
|
194
243
|
|
|
195
244
|
##Generating A Pie Chart
|
|
196
245
|
|
|
@@ -200,7 +249,7 @@ To install Axlsx, use the following command:
|
|
|
200
249
|
sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
|
|
201
250
|
chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
|
|
202
251
|
end
|
|
203
|
-
end
|
|
252
|
+
end
|
|
204
253
|
|
|
205
254
|
##Data over time
|
|
206
255
|
|
|
@@ -214,9 +263,9 @@ To install Axlsx, use the following command:
|
|
|
214
263
|
sheet.add_chart(Axlsx::Bar3DChart) do |chart|
|
|
215
264
|
chart.start_at "B7"
|
|
216
265
|
chart.end_at "H27"
|
|
217
|
-
chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
|
|
218
|
-
end
|
|
219
|
-
end
|
|
266
|
+
chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
|
|
267
|
+
end
|
|
268
|
+
end
|
|
220
269
|
|
|
221
270
|
##Generating A Line Chart
|
|
222
271
|
|
|
@@ -227,9 +276,24 @@ To install Axlsx, use the following command:
|
|
|
227
276
|
chart.start_at 0, 2
|
|
228
277
|
chart.end_at 10, 15
|
|
229
278
|
chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
|
|
230
|
-
chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
|
|
231
|
-
end
|
|
232
|
-
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
|
|
233
297
|
|
|
234
298
|
##Auto Filter
|
|
235
299
|
|
|
@@ -240,13 +304,62 @@ To install Axlsx, use the following command:
|
|
|
240
304
|
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
|
|
241
305
|
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
|
|
242
306
|
sheet.auto_filter = "A2:D5"
|
|
243
|
-
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
|
|
244
337
|
|
|
245
338
|
##Validate and Serialize
|
|
246
339
|
|
|
247
340
|
p.validate.each { |e| puts e.message }
|
|
248
341
|
p.serialize("example.xlsx")
|
|
249
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
|
+
|
|
250
363
|
|
|
251
364
|
#Documentation
|
|
252
365
|
--------------
|
|
@@ -255,50 +368,68 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
|
|
|
255
368
|
gem install yard
|
|
256
369
|
yard server -g
|
|
257
370
|
|
|
258
|
-
|
|
259
371
|
#Specs
|
|
260
372
|
------
|
|
261
373
|
This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
|
|
262
|
-
|
|
263
|
-
#
|
|
374
|
+
|
|
375
|
+
#Change log
|
|
264
376
|
---------
|
|
265
|
-
- **
|
|
266
|
-
-
|
|
267
|
-
-
|
|
268
|
-
-
|
|
269
|
-
-
|
|
270
|
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
-
|
|
276
|
-
-
|
|
277
|
-
-
|
|
278
|
-
-
|
|
279
|
-
|
|
280
|
-
- **
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
+
|
|
295
411
|
Please see the {file:CHANGELOG.md} document for past release information.
|
|
296
412
|
|
|
297
413
|
#Thanks!
|
|
298
414
|
--------
|
|
299
|
-
ochko
|
|
415
|
+
[ochko](https://github.com/ochko) - for performance fixes, kicking the crap out of axlsx and helping to maintain my general sanity.
|
|
416
|
+
|
|
417
|
+
[kleine2](https://github.com/kleine2) - for generously donating in return for the image hyperlink feature.
|
|
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
|
+
|
|
300
431
|
#Copyright and License
|
|
301
432
|
----------
|
|
302
433
|
|
|
303
|
-
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
|
|
304
435
|
licensed under the MIT license. Please see the {file:LICENSE} document for more information.
|