axlsx 1.0.17 → 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/CHANGELOG.md +11 -3
- data/README.md +159 -51
- data/examples/example.csv +1000 -0
- data/examples/example.rb +255 -150
- 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 +12 -12
- data/lib/axlsx/content_type/default.rb +9 -6
- data/lib/axlsx/content_type/override.rb +12 -8
- data/lib/axlsx/doc_props/app.rb +37 -40
- data/lib/axlsx/doc_props/core.rb +12 -17
- data/lib/axlsx/drawing/axis.rb +38 -19
- data/lib/axlsx/drawing/bar_3D_chart.rb +33 -32
- data/lib/axlsx/drawing/bar_series.rb +13 -14
- data/lib/axlsx/drawing/cat_axis.rb +15 -14
- data/lib/axlsx/drawing/cat_axis_data.rb +16 -18
- data/lib/axlsx/drawing/chart.rb +39 -40
- data/lib/axlsx/drawing/drawing.rb +15 -12
- data/lib/axlsx/drawing/graphic_frame.rb +21 -21
- data/lib/axlsx/drawing/hyperlink.rb +12 -11
- data/lib/axlsx/drawing/line_3D_chart.rb +30 -28
- data/lib/axlsx/drawing/line_series.rb +11 -11
- data/lib/axlsx/drawing/marker.rb +10 -8
- data/lib/axlsx/drawing/named_axis_data.rb +36 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +17 -16
- data/lib/axlsx/drawing/pic.rb +25 -37
- data/lib/axlsx/drawing/picture_locking.rb +21 -18
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -8
- data/lib/axlsx/drawing/pie_series.rb +15 -12
- data/lib/axlsx/drawing/scaling.rb +10 -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 +10 -10
- data/lib/axlsx/drawing/series.rb +15 -15
- data/lib/axlsx/drawing/series_title.rb +14 -14
- data/lib/axlsx/drawing/title.rb +26 -26
- data/lib/axlsx/drawing/two_cell_anchor.rb +18 -20
- data/lib/axlsx/drawing/val_axis.rb +8 -7
- data/lib/axlsx/drawing/val_axis_data.rb +17 -17
- data/lib/axlsx/drawing/view_3D.rb +22 -20
- data/lib/axlsx/package.rb +60 -43
- data/lib/axlsx/rels/relationship.rb +11 -8
- data/lib/axlsx/rels/relationships.rb +7 -1
- data/lib/axlsx/stylesheet/#num_fmt.rb# +69 -0
- data/lib/axlsx/stylesheet/border.rb +27 -23
- data/lib/axlsx/stylesheet/border_pr.rb +16 -15
- data/lib/axlsx/stylesheet/cell_alignment.rb +23 -21
- data/lib/axlsx/stylesheet/cell_protection.rb +10 -7
- data/lib/axlsx/stylesheet/cell_style.rb +8 -5
- data/lib/axlsx/stylesheet/color.rb +20 -14
- data/lib/axlsx/stylesheet/fill.rb +7 -5
- data/lib/axlsx/stylesheet/font.rb +21 -14
- data/lib/axlsx/stylesheet/gradient_fill.rb +19 -16
- data/lib/axlsx/stylesheet/gradient_stop.rb +9 -5
- data/lib/axlsx/stylesheet/num_fmt.rb +12 -6
- data/lib/axlsx/stylesheet/pattern_fill.rb +25 -10
- data/lib/axlsx/stylesheet/styles.rb +47 -35
- data/lib/axlsx/stylesheet/table_style.rb +9 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +10 -7
- data/lib/axlsx/stylesheet/table_styles.rb +11 -8
- data/lib/axlsx/stylesheet/xf.rb +29 -25
- data/lib/axlsx/util/constants.rb +20 -14
- data/lib/axlsx/util/simple_typed_list.rb +18 -9
- data/lib/axlsx/util/validators.rb +13 -6
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +19 -21
- data/lib/axlsx/workbook/workbook.rb +58 -34
- data/lib/axlsx/workbook/worksheet/cell.rb +149 -132
- 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 +40 -23
- 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 +243 -127
- data/lib/axlsx.rb +30 -9
- 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 +30 -32
- data/test/content_type/tc_default.rb +8 -23
- data/test/content_type/tc_override.rb +7 -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 +13 -10
- 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 +5 -6
- data/test/workbook/tc_workbook.rb +24 -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 +62 -18
- 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 +177 -34
- metadata +69 -41
- data/test/drawing/tc_hyperlink.rb~ +0 -71
- data/test/workbook/tc_shared_strings_table.rb~ +0 -8
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
- **January.6.12**: 1.0.15 release
|
|
4
12
|
https://github.com/randym/axlsx/compare/1.0.14...1.0.15
|
|
5
13
|
- Bug fix add_style specified number formats must be explicity applied for libraOffice
|
|
@@ -15,7 +23,7 @@ CHANGELOG
|
|
|
15
23
|
- Updated examples to output to a single workbook with multiple sheets
|
|
16
24
|
- Added access to app and core package objects so you can set the creator and other properties of the package
|
|
17
25
|
- The beginning of password protected xlsx files - roadmapped for January release.
|
|
18
|
-
|
|
26
|
+
|
|
19
27
|
- **December.8.11**: 1.0.13 release
|
|
20
28
|
- Fixing .gemspec errors that caused gem to miss the lib directory. Sorry about that.
|
|
21
29
|
|
|
@@ -62,7 +70,7 @@ CHANGELOG
|
|
|
62
70
|
##October.22.11: 1.0.6 release
|
|
63
71
|
- Bumping version to include docs. Bug in gemspec pointing to incorrect directory.
|
|
64
72
|
|
|
65
|
-
##October.22.11: 1.05
|
|
73
|
+
##October.22.11: 1.05
|
|
66
74
|
- Added support for line charts
|
|
67
75
|
- Updated examples and readme
|
|
68
76
|
- Updated series title to be a real title ** NOTE ** If you are accessing titles directly you will need to update text assignation.
|
|
@@ -70,7 +78,7 @@ CHANGELOG
|
|
|
70
78
|
chart.series.first.title.text = 'Your Title'
|
|
71
79
|
With this change you can assign a cell for the series title
|
|
72
80
|
chart.series.title = sheet.rows.first.cells.first
|
|
73
|
-
If you are using the recommended
|
|
81
|
+
If you are using the recommended
|
|
74
82
|
chart.add_series :data=>[], :labels=>[], :title
|
|
75
83
|
You do not have to change anything.
|
|
76
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.17
|
|
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 (with links), automated and fixed column widths,
|
|
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,26 +37,26 @@ 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
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. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "
|
|
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
61
|
**9. Cell level style overrides for default and customized style objects
|
|
52
62
|
|
|
@@ -60,13 +70,15 @@ Feature List
|
|
|
60
70
|
|
|
61
71
|
**14. Output to file or StringIO
|
|
62
72
|
|
|
73
|
+
**15. Support for page margins
|
|
74
|
+
|
|
63
75
|
Installing
|
|
64
76
|
----------
|
|
65
77
|
|
|
66
78
|
To install Axlsx, use the following command:
|
|
67
79
|
|
|
68
80
|
$ gem install axlsx
|
|
69
|
-
|
|
81
|
+
|
|
70
82
|
#Usage
|
|
71
83
|
------
|
|
72
84
|
|
|
@@ -82,14 +94,14 @@ To install Axlsx, use the following command:
|
|
|
82
94
|
sheet.add_row [1, 2, 3]
|
|
83
95
|
end
|
|
84
96
|
|
|
85
|
-
##Using Custom Styles
|
|
97
|
+
##Using Custom Styles and Row Heights
|
|
86
98
|
|
|
87
99
|
wb.styles do |s|
|
|
88
100
|
black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
|
|
89
101
|
blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
|
|
90
102
|
wb.add_worksheet(:name => "Custom Styles") do |sheet|
|
|
91
103
|
sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
|
|
92
|
-
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
|
|
93
105
|
end
|
|
94
106
|
end
|
|
95
107
|
|
|
@@ -110,25 +122,25 @@ To install Axlsx, use the following command:
|
|
|
110
122
|
##Add an Image
|
|
111
123
|
|
|
112
124
|
wb.add_worksheet(:name => "Images") do |sheet|
|
|
113
|
-
img = File.expand_path('examples/image1.jpeg')
|
|
125
|
+
img = File.expand_path('examples/image1.jpeg')
|
|
114
126
|
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
|
|
115
127
|
image.width=720
|
|
116
128
|
image.height=666
|
|
117
129
|
image.start_at 2, 2
|
|
118
130
|
end
|
|
119
|
-
end
|
|
131
|
+
end
|
|
120
132
|
|
|
121
133
|
##Add an Image with a hyperlink
|
|
122
134
|
|
|
123
135
|
wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
|
|
124
|
-
img = File.expand_path('examples/image1.jpeg')
|
|
136
|
+
img = File.expand_path('examples/image1.jpeg')
|
|
125
137
|
sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
|
|
126
138
|
image.width=720
|
|
127
139
|
image.height=666
|
|
128
140
|
image.hyperlink.tooltip = "Labeled Link"
|
|
129
141
|
image.start_at 2, 2
|
|
130
142
|
end
|
|
131
|
-
end
|
|
143
|
+
end
|
|
132
144
|
|
|
133
145
|
##Asian Language Support
|
|
134
146
|
|
|
@@ -136,7 +148,7 @@ To install Axlsx, use the following command:
|
|
|
136
148
|
sheet.add_row ["日本語"]
|
|
137
149
|
sheet.add_row ["华语/華語"]
|
|
138
150
|
sheet.add_row ["한국어/조선말"]
|
|
139
|
-
end
|
|
151
|
+
end
|
|
140
152
|
|
|
141
153
|
##Styling Columns
|
|
142
154
|
|
|
@@ -151,6 +163,20 @@ To install Axlsx, use the following command:
|
|
|
151
163
|
end
|
|
152
164
|
end
|
|
153
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
|
+
|
|
154
180
|
##Styling Rows
|
|
155
181
|
|
|
156
182
|
wb.styles do |s|
|
|
@@ -175,7 +201,7 @@ To install Axlsx, use the following command:
|
|
|
175
201
|
# cell level style overrides via sheet range
|
|
176
202
|
sheet["A1:D1"].each { |c| c.color = "FF0000"}
|
|
177
203
|
sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
|
178
|
-
end
|
|
204
|
+
end
|
|
179
205
|
|
|
180
206
|
##Using formula
|
|
181
207
|
|
|
@@ -184,6 +210,13 @@ To install Axlsx, use the following command:
|
|
|
184
210
|
sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
|
|
185
211
|
end
|
|
186
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
|
+
|
|
187
220
|
##Merging Cells.
|
|
188
221
|
|
|
189
222
|
wb.add_worksheet(:name => 'Merging Cells') do |sheet|
|
|
@@ -195,7 +228,7 @@ To install Axlsx, use the following command:
|
|
|
195
228
|
sheet.merge_cells("A4:C4")
|
|
196
229
|
sheet["A1:D1"].each { |c| c.color = "FF0000"}
|
|
197
230
|
sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
|
|
198
|
-
end
|
|
231
|
+
end
|
|
199
232
|
|
|
200
233
|
##Generating A Bar Chart
|
|
201
234
|
|
|
@@ -206,7 +239,7 @@ To install Axlsx, use the following command:
|
|
|
206
239
|
sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
|
|
207
240
|
chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
|
|
208
241
|
end
|
|
209
|
-
end
|
|
242
|
+
end
|
|
210
243
|
|
|
211
244
|
##Generating A Pie Chart
|
|
212
245
|
|
|
@@ -216,7 +249,7 @@ To install Axlsx, use the following command:
|
|
|
216
249
|
sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
|
|
217
250
|
chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
|
|
218
251
|
end
|
|
219
|
-
end
|
|
252
|
+
end
|
|
220
253
|
|
|
221
254
|
##Data over time
|
|
222
255
|
|
|
@@ -230,9 +263,9 @@ To install Axlsx, use the following command:
|
|
|
230
263
|
sheet.add_chart(Axlsx::Bar3DChart) do |chart|
|
|
231
264
|
chart.start_at "B7"
|
|
232
265
|
chart.end_at "H27"
|
|
233
|
-
chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
|
|
234
|
-
end
|
|
235
|
-
end
|
|
266
|
+
chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
|
|
267
|
+
end
|
|
268
|
+
end
|
|
236
269
|
|
|
237
270
|
##Generating A Line Chart
|
|
238
271
|
|
|
@@ -243,9 +276,24 @@ To install Axlsx, use the following command:
|
|
|
243
276
|
chart.start_at 0, 2
|
|
244
277
|
chart.end_at 10, 15
|
|
245
278
|
chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
|
|
246
|
-
chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
|
|
247
|
-
end
|
|
248
|
-
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
|
|
249
297
|
|
|
250
298
|
##Auto Filter
|
|
251
299
|
|
|
@@ -256,7 +304,7 @@ To install Axlsx, use the following command:
|
|
|
256
304
|
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
|
|
257
305
|
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
|
|
258
306
|
sheet.auto_filter = "A2:D5"
|
|
259
|
-
end
|
|
307
|
+
end
|
|
260
308
|
|
|
261
309
|
##Specifying Column Widths
|
|
262
310
|
|
|
@@ -265,12 +313,34 @@ To install Axlsx, use the following command:
|
|
|
265
313
|
sheet.column_widths nil, 3
|
|
266
314
|
end
|
|
267
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
|
|
337
|
+
|
|
268
338
|
##Validate and Serialize
|
|
269
339
|
|
|
270
340
|
p.validate.each { |e| puts e.message }
|
|
271
341
|
p.serialize("example.xlsx")
|
|
272
342
|
|
|
273
|
-
# alternatively,
|
|
343
|
+
# alternatively, serialize to StringIO
|
|
274
344
|
s = p.to_stream()
|
|
275
345
|
File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
|
|
276
346
|
|
|
@@ -279,6 +349,16 @@ To install Axlsx, use the following command:
|
|
|
279
349
|
p.use_shared_strings = true
|
|
280
350
|
p.serialize("shared_strings_example.xlsx")
|
|
281
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")
|
|
282
362
|
|
|
283
363
|
|
|
284
364
|
#Documentation
|
|
@@ -291,25 +371,43 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
|
|
|
291
371
|
#Specs
|
|
292
372
|
------
|
|
293
373
|
This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
|
|
294
|
-
|
|
295
|
-
#
|
|
374
|
+
|
|
375
|
+
#Change log
|
|
296
376
|
---------
|
|
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
|
+
|
|
297
402
|
- ** February.14.12**: 1.0.17 release
|
|
298
403
|
https://github.com/randym/axlsx/compare/1.0.16...1.0.17
|
|
299
404
|
- Added in support for serializing to StringIO
|
|
300
405
|
- Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers
|
|
301
406
|
- Added in support for fixed column_widths
|
|
302
|
-
- Removed
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- Bug fix for schema file locations when validating in rails
|
|
307
|
-
- Added hyperlink to images
|
|
308
|
-
- date1904 now automatically set in bsd and mac environments
|
|
309
|
-
- removed whitespace/indentation from xml outputs
|
|
310
|
-
- col_style now skips rows that do not contain cells at the column index
|
|
311
|
-
|
|
312
|
-
|
|
407
|
+
- Removed unneeded dependencies on active-support and i18n
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
313
411
|
Please see the {file:CHANGELOG.md} document for past release information.
|
|
314
412
|
|
|
315
413
|
#Thanks!
|
|
@@ -320,8 +418,18 @@ Please see the {file:CHANGELOG.md} document for past release information.
|
|
|
320
418
|
|
|
321
419
|
[ffmike](https://github.com/ffmike) - for knocking down an over restrictive i18n dependency, massive patience and great communication skills.
|
|
322
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
|
+
|
|
323
431
|
#Copyright and License
|
|
324
432
|
----------
|
|
325
433
|
|
|
326
|
-
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
|
|
327
435
|
licensed under the MIT license. Please see the {file:LICENSE} document for more information.
|