axlsx 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGELOG.md +18 -0
  2. data/README.md +323 -236
  3. data/Rakefile +6 -2
  4. data/examples/axlsx.xlsx +0 -0
  5. data/examples/example.csv +1000 -1000
  6. data/examples/example.xlsx +0 -0
  7. data/examples/example_streamed.xlsx +0 -0
  8. data/examples/no-use_autowidth.xlsx +0 -0
  9. data/examples/real_example.rb +63 -0
  10. data/examples/sample.png +0 -0
  11. data/examples/shared_strings_example.xlsx +0 -0
  12. data/lib/axlsx/drawing/scatter_chart.rb +18 -18
  13. data/lib/axlsx/stylesheet/color.rb +0 -1
  14. data/lib/axlsx/stylesheet/styles.rb +6 -4
  15. data/lib/axlsx/util/doc/_index.html +84 -0
  16. data/lib/axlsx/util/doc/class_list.html +47 -0
  17. data/lib/axlsx/util/doc/css/common.css +1 -0
  18. data/lib/axlsx/util/doc/css/full_list.css +55 -0
  19. data/lib/axlsx/util/doc/css/style.css +322 -0
  20. data/lib/axlsx/util/doc/file_list.html +46 -0
  21. data/lib/axlsx/util/doc/frames.html +13 -0
  22. data/lib/axlsx/util/doc/index.html +84 -0
  23. data/lib/axlsx/util/doc/js/app.js +205 -0
  24. data/lib/axlsx/util/doc/js/full_list.js +173 -0
  25. data/lib/axlsx/util/doc/js/jquery.js +16 -0
  26. data/lib/axlsx/util/doc/method_list.html +46 -0
  27. data/lib/axlsx/util/doc/top-level-namespace.html +95 -0
  28. data/{test/benchmark.rb~ → lib/axlsx/util/font_tables.rb~} +0 -0
  29. data/lib/axlsx/version.rb +1 -1
  30. data/lib/axlsx/workbook/shared_strings_table.rb +12 -13
  31. data/lib/axlsx/workbook/worksheet/cell.rb +10 -29
  32. data/lib/axlsx/workbook/worksheet/worksheet.rb +23 -21
  33. data/test/benchmark.rb +30 -38
  34. data/test/profile.rb +2 -1
  35. data/test/stylesheet/tc_styles.rb +16 -1
  36. data/test/workbook/worksheet/tc_cell.rb +22 -12
  37. data/test/workbook/worksheet/tc_date_time_converter.rb +11 -5
  38. data/test/workbook/worksheet/tc_worksheet.rb +9 -2
  39. metadata +63 -125
  40. data/examples/example.rb~ +0 -112
  41. data/lib/axlsx/stylesheet/#num_fmt.rb# +0 -69
  42. data/test/#benchmark.txt# +0 -7
  43. data/test/#tc_helper.rb# +0 -3
  44. data/test/benchmark.txt +0 -6
  45. data/test/benchmark.txt~ +0 -6
  46. data/test/example.csv +0 -1000
  47. data/test/example.xlsx +0 -0
  48. data/test/example_streamed.xlsx +0 -0
  49. data/test/tc_axlsx.rb~ +0 -0
  50. data/test/tc_helper.rb~ +0 -3
@@ -1,5 +1,23 @@
1
1
  CHANGELOG
2
2
  ---------
3
+
4
+ - ** March.5.12**: 1.0.18 release
5
+ https://github.com/randym/axlsx/compare/1.0.17...1.0.18
6
+ - bugfix custom borders are not properly applied when using styles.add_style
7
+ - interop worksheet names must be 31 characters or less or some versions of office complain about repairs
8
+ - added type support for :boolean and :date types cell values
9
+ - added support for fixed column widths
10
+ - added support for page_margins
11
+ - added << alias for add_row
12
+ - removed presetting of date1904 based on authoring platform. Now defaults to use 1900 epoch (date1904 = false)
13
+
14
+ - ** February.14.12**: 1.0.17 release
15
+ https://github.com/randym/axlsx/compare/1.0.16...1.0.17
16
+ - Added in support for serializing to StringIO
17
+ - Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers
18
+ - Added in support for fixed column_widths
19
+ - Removed unneeded dependencies on active-support and i18n
20
+
3
21
  - ** February.2.12**: 1.0.16 release
4
22
  https://github.com/randym/axlsx/compare/1.0.15...1.0.16
5
23
  - Bug fix for schema file locations when validating in rails
data/README.md CHANGED
@@ -2,25 +2,27 @@ Axlsx: Office Open XML Spreadsheet Generation
2
2
  ====================================
3
3
  [![Build Status](https://secure.travis-ci.org/randym/axlsx.png)](http://travis-ci.org/randym/axlsx/)
4
4
 
5
- **IRC**: [irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
5
+ **IRC**:[irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
6
6
 
7
- **Git**: [http://github.com/randym/axlsx](http://github.com/randym/axlsx)
7
+ **Git**:[http://github.com/randym/axlsx](http://github.com/randym/axlsx)
8
8
 
9
- **Twitter**: [https://twitter.com/#!/morgan_randy](https://twitter.com/#!/morgan_randy) release announcements and news will be published here
9
+ **Twitter**: [https://twitter.com/#!/morgan_randy](https://twitter.com/#!/morgan_randy)
10
10
 
11
- **Author**: Randy Morgan
11
+ **Google Group**: [https://groups.google.com/forum/?fromgroups#!forum/axlsx](https://groups.google.com/forum/?fromgroups#!forum/axlsx)
12
+
13
+ **Author**: Randy Morgan
12
14
 
13
15
  **Copyright**: 2011 - 2012
14
16
 
15
- **License**: MIT License
17
+ **License**: MIT License
16
18
 
17
- **Latest Version**: 1.1.0
19
+ **Latest Version**: 1.1.1
18
20
 
19
21
  **Ruby Version**: 1.8.7, 1.9.2, 1.9.3
20
22
 
21
23
  **JRuby Version**: 1.6.7
22
24
 
23
- **Release Date**: April 3st 2012
25
+ **Release Date**: April 18th 2012
24
26
 
25
27
  Synopsis
26
28
  --------
@@ -28,16 +30,14 @@ Synopsis
28
30
  Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
29
31
  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.
30
32
 
33
+ ![Screen 1](https://github.com/randym/axlsx/raw/master/examples/sample.png)
34
+
31
35
  If you are working in rails, or with active record see:
32
36
  http://github.com/randym/acts_as_xlsx
33
37
 
34
38
  There are guides for using axlsx and acts_as_xlsx here:
35
39
  [http://axlsx.blogspot.com](http://axlsx.blogspot.com)
36
40
 
37
- Help Wanted
38
- -----------
39
-
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.
41
41
 
42
42
  Feature List
43
43
  ------------
@@ -82,298 +82,402 @@ To install Axlsx, use the following command:
82
82
  #Usage
83
83
  ------
84
84
 
85
- require 'axlsx'
85
+ ```ruby
86
+ require 'axlsx'
87
+
88
+ p = Axlsx::Package.new
89
+ wb = p.workbook
90
+ ```
91
+
92
+ #A Simple Workbook
93
+
94
+ ```ruby
95
+ wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
96
+ sheet.add_row ["First Column", "Second", "Third"]
97
+ sheet.add_row [1, 2, 3]
98
+ end
99
+ ```
86
100
 
87
- p = Axlsx::Package.new
88
- wb = p.workbook
101
+ #Using Custom Styles
89
102
 
90
- ##A Simple Workbook
103
+ ```ruby
104
+ wb.styles do |s|
105
+ black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
106
+ blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
107
+ wb.add_worksheet(:name => "Custom Styles") do |sheet|
108
+ sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
109
+ sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
110
+ end
111
+ end
112
+ ```
91
113
 
92
- wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
93
- sheet.add_row ["First Column", "Second", "Third"]
94
- sheet.add_row [1, 2, 3]
95
- end
114
+ #Using Custom Border Styles
96
115
 
97
- ##Using Custom Styles and Row Heights
116
+ ```ruby
117
+ wb.styles do |s|
118
+ red_border = s.add_style :border => { :style => :thin, :color =>"FFFF0000" }
119
+ blue_border = s.add_style :border => { :style => :thin, :color =>"FF0000FF" }
120
+
121
+ wb.add_worksheet(:name => "Custom Borders") do |sheet|
122
+ sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border
123
+ sheet.add_row [1, 2, 3], :style => blue_border
124
+ end
125
+ end
126
+ ```
98
127
 
99
- wb.styles do |s|
100
- black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
101
- blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
102
- wb.add_worksheet(:name => "Custom Styles") do |sheet|
103
- sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
104
- sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER, :height => 20
105
- end
106
- end
107
128
 
108
129
  ##Using Custom Formatting and date1904
109
130
 
110
- require 'date'
111
- wb.styles do |s|
112
- date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
113
- padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
114
- percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
115
- wb.date1904 = true # required for generation on mac
116
- wb.add_worksheet(:name => "Formatting Data") do |sheet|
117
- sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
118
- sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
119
- end
120
- end
131
+ ```ruby
132
+ require 'date'
133
+ wb.styles do |s|
134
+ date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
135
+ padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
136
+ percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
137
+ # wb.date1904 = true # Use the 1904 date system (Used by Excel for Mac < 2011)
138
+ wb.add_worksheet(:name => "Formatting Data") do |sheet|
139
+ sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
140
+ sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
141
+ end
142
+ end
143
+ ```
144
+
121
145
 
122
146
  ##Add an Image
123
147
 
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
148
+ ```ruby
149
+ wb.add_worksheet(:name => "Images") do |sheet|
150
+ img = File.expand_path('../image1.jpeg', __FILE__)
151
+ sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
152
+ image.width=720
153
+ image.height=666
154
+ image.start_at 2, 2
155
+ end
156
+ end
157
+ ```
132
158
 
133
159
  ##Add an Image with a hyperlink
134
160
 
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
161
+ ```ruby
162
+ wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
163
+ img = File.expand_path('../image1.jpeg', __FILE__)
164
+ sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
165
+ image.width=720
166
+ image.height=666
167
+ image.hyperlink.tooltip = "Labeled Link"
168
+ image.start_at 2, 2
169
+ end
170
+ end
171
+ ```
144
172
 
145
173
  ##Asian Language Support
146
174
 
147
- wb.add_worksheet(:name => "Unicode Support") do |sheet|
148
- sheet.add_row ["日本語"]
149
- sheet.add_row ["华语/華語"]
150
- sheet.add_row ["한국어/조선말"]
151
- end
175
+ ```ruby
176
+ wb.add_worksheet(:name => "日本語でのシート名") do |sheet|
177
+ sheet.add_row ["日本語"]
178
+ sheet.add_row ["华语/華語"]
179
+ sheet.add_row ["한국어/조선말"]
180
+ end
181
+ ```
152
182
 
153
183
  ##Styling Columns
154
184
 
155
- wb.styles do |s|
156
- percent = s.add_style :num_fmt => 9
157
- wb.add_worksheet(:name => "Styling Columns") do |sheet|
158
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
159
- sheet.add_row [1, 2, 0.3, 4]
160
- sheet.add_row [1, 2, 0.2, 4]
161
- sheet.add_row [1, 2, 0.1, 4]
162
- sheet.col_style 2, percent, :row_offset => 1
163
- end
164
- end
185
+ ```ruby
186
+ wb.styles do |s|
187
+ percent = s.add_style :num_fmt => 9
188
+ wb.add_worksheet(:name => "Styling Columns") do |sheet|
189
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
190
+ sheet.add_row [1, 2, 0.3, 4]
191
+ sheet.add_row [1, 2, 0.2, 4]
192
+ sheet.add_row [1, 2, 0.1, 4]
193
+ sheet.col_style 2, percent, :row_offset => 1
194
+ end
195
+ end
196
+ ```
165
197
 
166
198
  ##Hiding Columns
167
199
 
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
200
+ ```ruby
201
+ wb.styles do |s|
202
+ percent = s.add_style :num_fmt => 9
203
+ wb.add_worksheet(:name => "Hidden Column") do |sheet|
204
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
205
+ sheet.add_row [1, 2, 0.3, 4]
206
+ sheet.add_row [1, 2, 0.2, 4]
207
+ sheet.add_row [1, 2, 0.1, 4]
208
+ sheet.col_style 2, percent, :row_offset => 1
209
+ sheet.column_info[1].hidden = true
210
+ end
211
+ end
212
+ ```
179
213
 
180
214
  ##Styling Rows
181
215
 
182
- wb.styles do |s|
183
- head = s.add_style :bg_color => "00", :fg_color => "FF"
184
- percent = s.add_style :num_fmt => 9
185
- wb.add_worksheet(:name => "Styling Rows") do |sheet|
186
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
187
- sheet.add_row [1, 2, 0.3, 4]
188
- sheet.add_row [1, 2, 0.2, 4]
189
- sheet.add_row [1, 2, 0.1, 4]
190
- sheet.col_style 2, percent, :row_offset => 1
191
- sheet.row_style 0, head
192
- end
193
- end
216
+ ```ruby
217
+ wb.styles do |s|
218
+ head = s.add_style :bg_color => "00", :fg_color => "FF"
219
+ percent = s.add_style :num_fmt => 9
220
+ wb.add_worksheet(:name => "Styling Rows") do |sheet|
221
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
222
+ sheet.add_row [1, 2, 0.3, 4]
223
+ sheet.add_row [1, 2, 0.2, 4]
224
+ sheet.add_row [1, 2, 0.1, 4]
225
+ sheet.col_style 2, percent, :row_offset => 1
226
+ sheet.row_style 0, head
227
+ end
228
+ end
229
+ ```
194
230
 
195
231
  ##Styling Cell Overrides
196
232
 
197
- wb.add_worksheet(:name => "Cell Level Style Overrides") do |sheet|
198
- # cell level style overides when adding cells
199
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4'], :sz => 16
200
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
201
- # cell level style overrides via sheet range
202
- sheet["A1:D1"].each { |c| c.color = "FF0000"}
203
- sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
204
- end
233
+ ```ruby
234
+ wb.add_worksheet(:name => "Cell Level Style Overrides") do |sheet|
235
+ # cell level style overides when adding cells
236
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4'], :sz => 16
237
+ sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
238
+ # cell level style overrides via sheet range
239
+ sheet["A1:D1"].each { |c| c.color = "FF0000"}
240
+ sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
241
+ end
242
+ ```
205
243
 
206
244
  ##Using formula
207
245
 
208
- wb.add_worksheet(:name => "Using Formulas") do |sheet|
209
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
210
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
211
- end
246
+ ```ruby
247
+ wb.add_worksheet(:name => "Using Formulas") do |sheet|
248
+ sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
249
+ sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
250
+ end
251
+ ```
212
252
 
213
253
  ##Automatic cell types
214
254
 
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
255
+ ```ruby
256
+ wb.add_worksheet(:name => "Automatic cell types") do |sheet|
257
+ sheet.add_row ["Date", "Time", "String", "Boolean", "Float", "Integer"]
258
+ sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1]
259
+ end
260
+ ```
219
261
 
220
262
  ##Merging Cells.
221
263
 
222
- wb.add_worksheet(:name => 'Merging Cells') do |sheet|
223
- # cell level style overides when adding cells
224
- sheet.add_row ["col 1", "col 2", "col 3", "col 4"], :sz => 16
225
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
226
- sheet.add_row [2, 3, 4, "=SUM(A3:C3)"]
227
- sheet.add_row ["total", "", "", "=SUM(D2:D3)"]
228
- sheet.merge_cells("A4:C4")
229
- sheet["A1:D1"].each { |c| c.color = "FF0000"}
230
- sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
231
- end
264
+ ```ruby
265
+ wb.add_worksheet(:name => 'Merging Cells') do |sheet|
266
+ # cell level style overides when adding cells
267
+ sheet.add_row ["col 1", "col 2", "col 3", "col 4"], :sz => 16
268
+ sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
269
+ sheet.add_row [2, 3, 4, "=SUM(A3:C3)"]
270
+ sheet.add_row ["total", "", "", "=SUM(D2:D3)"]
271
+ sheet.merge_cells("A4:C4")
272
+ sheet["A1:D1"].each { |c| c.color = "FF0000"}
273
+ sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
274
+ end
275
+ ```
232
276
 
233
277
  ##Generating A Bar Chart
234
278
 
235
- wb.add_worksheet(:name => "Bar Chart") do |sheet|
236
- sheet.add_row ["A Simple Bar Chart"]
237
- sheet.add_row ["First", "Second", "Third"]
238
- sheet.add_row [1, 2, 3]
239
- sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
240
- chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
241
- end
242
- end
279
+ ```ruby
280
+ wb.add_worksheet(:name => "Bar Chart") do |sheet|
281
+ sheet.add_row ["A Simple Bar Chart"]
282
+ sheet.add_row ["First", "Second", "Third"]
283
+ sheet.add_row [1, 2, 3]
284
+ sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
285
+ chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
286
+ end
287
+ end
288
+ ```
289
+
290
+ ##Hide Gridlines in chart
291
+
292
+ ```ruby
293
+ wb.add_worksheet(:name => "Chart With No Gridlines") do |sheet|
294
+ sheet.add_row ["A Simple Bar Chart"]
295
+ sheet.add_row ["First", "Second", "Third"]
296
+ sheet.add_row [1, 2, 3]
297
+ sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
298
+ chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
299
+ chart.valAxis.gridlines = false
300
+ chart.catAxis.gridlines = false
301
+ end
302
+ end
303
+ ```
243
304
 
244
305
  ##Generating A Pie Chart
245
306
 
246
- wb.add_worksheet(:name => "Pie Chart") do |sheet|
247
- sheet.add_row ["First", "Second", "Third", "Fourth"]
248
- sheet.add_row [1, 2, 3, "=PRODUCT(A2:C2)"]
249
- sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
250
- chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
251
- end
252
- end
307
+ ```ruby
308
+ wb.add_worksheet(:name => "Pie Chart") do |sheet|
309
+ sheet.add_row ["First", "Second", "Third", "Fourth"]
310
+ sheet.add_row [1, 2, 3, "=PRODUCT(A2:C2)"]
311
+ sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
312
+ chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
313
+ end
314
+ end
315
+ ```
253
316
 
254
317
  ##Data over time
255
318
 
256
- wb.add_worksheet(:name=>'Charting Dates') do |sheet|
257
- # cell level style overides when adding cells
258
- sheet.add_row ['Date', 'Value'], :sz => 16
259
- sheet.add_row [Time.now - (7*60*60*24), 3]
260
- sheet.add_row [Time.now - (6*60*60*24), 7]
261
- sheet.add_row [Time.now - (5*60*60*24), 18]
262
- sheet.add_row [Time.now - (4*60*60*24), 1]
263
- sheet.add_chart(Axlsx::Bar3DChart) do |chart|
264
- chart.start_at "B7"
265
- chart.end_at "H27"
266
- chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
267
- end
268
- end
319
+ ```ruby
320
+ wb.add_worksheet(:name=>'Charting Dates') do |sheet|
321
+ # cell level style overides when adding cells
322
+ sheet.add_row ['Date', 'Value'], :sz => 16
323
+ sheet.add_row [Time.now - (7*60*60*24), 3]
324
+ sheet.add_row [Time.now - (6*60*60*24), 7]
325
+ sheet.add_row [Time.now - (5*60*60*24), 18]
326
+ sheet.add_row [Time.now - (4*60*60*24), 1]
327
+ sheet.add_chart(Axlsx::Bar3DChart) do |chart|
328
+ chart.start_at "B7"
329
+ chart.end_at "H27"
330
+ chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
331
+ end
332
+ end
333
+ ```
269
334
 
270
335
  ##Generating A Line Chart
271
336
 
272
- wb.add_worksheet(:name => "Line Chart") do |sheet|
273
- sheet.add_row ["First", 1, 5, 7, 9]
274
- sheet.add_row ["Second", 5, 2, 14, 9]
275
- sheet.add_chart(Axlsx::Line3DChart, :title => "example 6: Line Chart", :rotX => 30, :rotY => 20) do |chart|
276
- chart.start_at 0, 2
277
- chart.end_at 10, 15
278
- chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
279
- chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
280
- end
281
- end
337
+ ```ruby
338
+ wb.add_worksheet(:name => "Line Chart") do |sheet|
339
+ sheet.add_row ["First", 1, 5, 7, 9]
340
+ sheet.add_row ["Second", 5, 2, 14, 9]
341
+ sheet.add_chart(Axlsx::Line3DChart, :title => "example 6: Line Chart", :rotX => 30, :rotY => 20) do |chart|
342
+ chart.start_at 0, 2
343
+ chart.end_at 10, 15
344
+ chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
345
+ chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
346
+ end
347
+ end
348
+ ```
282
349
 
283
350
  ##Generating A Scatter Chart
284
351
 
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
352
+ ```ruby
353
+ wb.add_worksheet(:name => "Scatter Chart") do |sheet|
354
+ sheet.add_row ["First", 1, 5, 7, 9]
355
+ sheet.add_row ["", 1, 25, 49, 81]
356
+ sheet.add_row ["Second", 5, 2, 14, 9]
357
+ sheet.add_row ["", 5, 10, 15, 20]
358
+ sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart|
359
+ chart.start_at 0, 4
360
+ chart.end_at 10, 19
361
+ chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"]
362
+ chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"]
363
+ end
364
+ end
365
+ ```
297
366
 
298
367
  ##Auto Filter
299
368
 
300
- wb.add_worksheet(:name => "Auto Filter") do |sheet|
301
- sheet.add_row ["Build Matrix"]
302
- sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
303
- sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
304
- sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
305
- sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
306
- sheet.auto_filter = "A2:D5"
307
- end
369
+ ```ruby
370
+ wb.add_worksheet(:name => "Auto Filter") do |sheet|
371
+ sheet.add_row ["Build Matrix"]
372
+ sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
373
+ sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
374
+ sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
375
+ sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
376
+ sheet.auto_filter = "A2:D5"
377
+ end
378
+ ```
379
+
380
+ ##Tables
381
+
382
+ ```ruby
383
+ wb.add_worksheet(:name => "Table") do |sheet|
384
+ sheet.add_row ["Build Matrix"]
385
+ sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
386
+ sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
387
+ sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
388
+ sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
389
+ sheet.add_table "A2:D5", :name => 'Build Matrix'
390
+ end
391
+ ```
308
392
 
309
393
  ##Specifying Column Widths
310
394
 
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
395
+ ```ruby
396
+ wb.add_worksheet(:name => "custom column widths") do |sheet|
397
+ sheet.add_row ["I use autowidth and am very wide", "I use a custom width and am narrow"]
398
+ sheet.add_row ['abcdefg', 'This is a very long text and should flow into the right cell', nil, 'xxx' ]
399
+ sheet.column_widths nil, 3, 5, nil
400
+ end
401
+ ```
322
402
 
323
403
  ##Fit to page printing
324
404
 
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
-
405
+ ```ruby
406
+ wb.add_worksheet(:name => "fit to page") do |sheet|
407
+ sheet.add_row ['this all goes on one page']
408
+ sheet.fit_to_page = true
409
+ end
410
+ ```
330
411
 
331
412
  ##Hide Gridlines in worksheet
332
413
 
333
- wb.add_worksheet(:name => "No Gridlines") do |sheet|
334
- sheet.add_row ["This", "Sheet", "Hides", "Gridlines"]
335
- sheet.show_gridlines = false
336
- end
414
+ ```ruby
415
+ wb.add_worksheet(:name => "No Gridlines") do |sheet|
416
+ sheet.add_row ["This", "Sheet", "Hides", "Gridlines"]
417
+ sheet.show_gridlines = false
418
+ end
419
+ ```
420
+
421
+ ##Specify Page Margins for printing
422
+
423
+ ```ruby
424
+ margins = {:left => 3, :right => 3, :top => 1.2, :bottom => 1.2, :header => 0.7, :footer => 0.7}
425
+ wb.add_worksheet(:name => "print margins", :page_margins => margins) do |sheet|
426
+ sheet.add_row ["this sheet uses customized page margins for printing"]
427
+ end
428
+ ```
337
429
 
338
430
  ##Validate and Serialize
339
431
 
340
- p.validate.each { |e| puts e.message }
341
- p.serialize("example.xlsx")
432
+ ```ruby
433
+ p.serialize("example.xlsx")
342
434
 
343
- # alternatively, serialize to StringIO
344
- s = p.to_stream()
345
- File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
435
+ s = p.to_stream()
436
+ File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
437
+ ```
346
438
 
347
439
  ##Using Shared Strings
348
440
 
349
- p.use_shared_strings = true
350
- p.serialize("shared_strings_example.xlsx")
441
+ ```ruby
442
+ p.use_shared_strings = true
443
+ p.serialize("shared_strings_example.xlsx")
444
+ ```
351
445
 
352
- ##Disabling Autowidth
353
446
 
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")
447
+ ##Disabling Autowidth
362
448
 
449
+ ```ruby
450
+ p = Axlsx::Package.new
451
+ p.use_autowidth = false
452
+ wb = p.workbook
453
+ wb.add_worksheet(:name => "No Magick") do | sheet |
454
+ sheet.add_row ['oh look! no autowidth - and no magick loaded in your process']
455
+ end
456
+ p.validate.each { |e| puts e.message }
457
+ p.serialize("no-use_autowidth.xlsx")
458
+ ```
363
459
 
364
460
  #Documentation
365
461
  --------------
366
462
  This gem is 100% documented with YARD, an exceptional documentation library. To see documentation for this, and all the gems installed on your system use:
367
463
 
368
- gem install yard
369
- yard server -g
370
-
464
+ ```bash
465
+ gem install yard
466
+ yard server -g
467
+ ```
371
468
  #Specs
372
469
  ------
373
470
  This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
374
471
 
375
472
  #Change log
376
473
  ---------
474
+ - ** April.18.12**: 1.1.1 release
475
+ - bugfix for autowidth calculations across multiple rows
476
+ - bugfix for dimension calculations with nil cells.
477
+ - REMOVED RMAGICK dependency WOOT!
478
+ - Update readme to show screenshot of gem output.
479
+ - Cleanup benchmark and add benchmark rake task
480
+
377
481
  - ** April.3.12**: 1.1.0 release
378
482
  - bugfix patch name_to_indecies to properly handle extended ranges.
379
483
  - bugfix properly serialize chart title.
@@ -389,25 +493,6 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
389
493
  - Major (like 7x faster!) performance updates.
390
494
  - Gem now supports for JRuby 1.6.7, as well as expirimental support for Rubinius
391
495
 
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
-
411
496
  Please see the {file:CHANGELOG.md} document for past release information.
412
497
 
413
498
  #Thanks!
@@ -428,6 +513,8 @@ Please see the {file:CHANGELOG.md} document for past release information.
428
513
 
429
514
  [joekain](https://github.com/joekain) - for keeping our references working even in the double digits!
430
515
 
516
+ [moskrin](https://github.com/moskrin) - for keeping border creation on the edge.
517
+
431
518
  #Copyright and License
432
519
  ----------
433
520