axlsx 1.1.3 → 1.2.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.
Files changed (187) hide show
  1. data/.yardopts +5 -2
  2. data/CHANGELOG.md +60 -0
  3. data/LICENSE +1 -1
  4. data/README.md +115 -415
  5. data/Rakefile +11 -3
  6. data/examples/basic_charts.rb +54 -0
  7. data/examples/chart_colors.rb +88 -0
  8. data/examples/data_validation.rb +50 -0
  9. data/examples/example.rb +299 -155
  10. data/examples/example.xlsx +0 -0
  11. data/examples/example_streamed.xlsx +0 -0
  12. data/examples/extractive.pdf +0 -0
  13. data/examples/extractive.rb +45 -0
  14. data/examples/no-use_autowidth.xlsx +0 -0
  15. data/examples/scraping_html.rb +91 -0
  16. data/examples/shared_strings_example.xlsx +0 -0
  17. data/examples/sheet_protection.rb +10 -0
  18. data/examples/sheet_view.rb +34 -0
  19. data/examples/two_cell_anchor_image.rb +11 -0
  20. data/lib/axlsx/content_type/content_type.rb +2 -0
  21. data/lib/axlsx/content_type/default.rb +30 -15
  22. data/lib/axlsx/content_type/override.rb +29 -14
  23. data/lib/axlsx/doc_props/app.rb +161 -104
  24. data/lib/axlsx/doc_props/core.rb +9 -5
  25. data/lib/axlsx/drawing/ax_data_source.rb +26 -0
  26. data/lib/axlsx/drawing/axis.rb +92 -37
  27. data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
  28. data/lib/axlsx/drawing/bar_series.rb +25 -7
  29. data/lib/axlsx/drawing/cat_axis.rb +50 -22
  30. data/lib/axlsx/drawing/chart.rb +69 -56
  31. data/lib/axlsx/drawing/d_lbls.rb +100 -0
  32. data/lib/axlsx/drawing/drawing.rb +28 -12
  33. data/lib/axlsx/drawing/graphic_frame.rb +2 -1
  34. data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
  35. data/lib/axlsx/drawing/line_series.rb +20 -4
  36. data/lib/axlsx/drawing/num_data.rb +52 -0
  37. data/lib/axlsx/drawing/num_data_source.rb +61 -0
  38. data/lib/axlsx/drawing/num_val.rb +32 -0
  39. data/lib/axlsx/drawing/pic.rb +44 -4
  40. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
  41. data/lib/axlsx/drawing/pie_series.rb +18 -4
  42. data/lib/axlsx/drawing/scatter_chart.rb +2 -8
  43. data/lib/axlsx/drawing/scatter_series.rb +28 -2
  44. data/lib/axlsx/drawing/ser_axis.rb +1 -1
  45. data/lib/axlsx/drawing/series.rb +1 -1
  46. data/lib/axlsx/drawing/str_data.rb +42 -0
  47. data/lib/axlsx/drawing/str_val.rb +33 -0
  48. data/lib/axlsx/drawing/title.rb +21 -9
  49. data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
  50. data/lib/axlsx/drawing/view_3D.rb +44 -31
  51. data/lib/axlsx/drawing/vml_drawing.rb +42 -0
  52. data/lib/axlsx/drawing/vml_shape.rb +125 -0
  53. data/lib/axlsx/package.rb +44 -16
  54. data/lib/axlsx/rels/relationship.rb +3 -3
  55. data/lib/axlsx/rels/relationships.rb +1 -11
  56. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  57. data/lib/axlsx/stylesheet/styles.rb +1 -1
  58. data/lib/axlsx/stylesheet/table_style.rb +3 -3
  59. data/lib/axlsx/util/constants.rb +28 -0
  60. data/lib/axlsx/util/simple_typed_list.rb +15 -21
  61. data/lib/axlsx/util/validators.rb +81 -8
  62. data/lib/axlsx/version.rb +2 -7
  63. data/lib/axlsx/workbook/defined_name.rb +174 -0
  64. data/lib/axlsx/workbook/defined_names.rb +21 -0
  65. data/lib/axlsx/workbook/workbook.rb +65 -13
  66. data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
  67. data/lib/axlsx/workbook/worksheet/cell.rb +35 -7
  68. data/lib/axlsx/workbook/worksheet/col.rb +17 -1
  69. data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
  70. data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
  71. data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
  72. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
  73. data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
  74. data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
  75. data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
  76. data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
  77. data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
  78. data/lib/axlsx/workbook/worksheet/page_setup.rb +113 -0
  79. data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
  80. data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
  81. data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
  82. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
  83. data/lib/axlsx/workbook/worksheet/row.rb +67 -12
  84. data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
  85. data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
  86. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
  87. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
  88. data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
  89. data/lib/axlsx/workbook/worksheet/table.rb +3 -3
  90. data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
  91. data/lib/axlsx/workbook/worksheet/worksheet.rb +377 -255
  92. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
  93. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
  94. data/lib/axlsx.rb +30 -15
  95. data/test/content_type/tc_content_type.rb +1 -6
  96. data/test/doc_props/tc_app.rb +31 -1
  97. data/test/doc_props/tc_core.rb +3 -1
  98. data/test/drawing/tc_axis.rb +38 -3
  99. data/test/drawing/tc_bar_3D_chart.rb +12 -12
  100. data/test/drawing/tc_bar_series.rb +17 -13
  101. data/test/drawing/tc_cat_axis.rb +3 -3
  102. data/test/drawing/tc_cat_axis_data.rb +23 -13
  103. data/test/drawing/tc_chart.rb +29 -11
  104. data/test/drawing/tc_d_lbls.rb +47 -0
  105. data/test/drawing/tc_data_source.rb +17 -0
  106. data/test/drawing/tc_drawing.rb +11 -5
  107. data/test/drawing/tc_hyperlink.rb +4 -5
  108. data/test/drawing/tc_line_series.rb +9 -11
  109. data/test/drawing/tc_named_axis_data.rb +27 -0
  110. data/test/drawing/tc_num_data.rb +31 -0
  111. data/test/drawing/tc_num_val.rb +29 -0
  112. data/test/drawing/tc_pic.rb +22 -2
  113. data/test/drawing/tc_pie_3D_chart.rb +4 -8
  114. data/test/drawing/tc_pie_series.rb +11 -13
  115. data/test/drawing/tc_scatter_chart.rb +6 -1
  116. data/test/drawing/tc_scatter_series.rb +6 -5
  117. data/test/drawing/tc_series.rb +1 -1
  118. data/test/drawing/tc_str_data.rb +18 -0
  119. data/test/drawing/tc_str_val.rb +21 -0
  120. data/test/drawing/tc_title.rb +16 -0
  121. data/test/drawing/tc_two_cell_anchor.rb +2 -3
  122. data/test/drawing/tc_view_3D.rb +18 -18
  123. data/test/drawing/tc_vml_drawing.rb +25 -0
  124. data/test/drawing/tc_vml_shape.rb +100 -0
  125. data/test/rels/tc_relationship.rb +1 -0
  126. data/test/stylesheet/tc_gradient_fill.rb +8 -0
  127. data/test/stylesheet/tc_pattern_fill.rb +7 -1
  128. data/test/stylesheet/tc_styles.rb +3 -4
  129. data/test/stylesheet/tc_table_style.rb +8 -0
  130. data/test/stylesheet/tc_table_style_element.rb +10 -1
  131. data/test/tc_helper.rb +1 -0
  132. data/test/tc_package.rb +93 -17
  133. data/test/util/tc_simple_typed_list.rb +13 -0
  134. data/test/util/tc_validators.rb +95 -9
  135. data/test/workbook/tc_defined_name.rb +41 -0
  136. data/test/workbook/tc_workbook.rb +5 -3
  137. data/test/workbook/worksheet/table/tc_table.rb +3 -11
  138. data/test/workbook/worksheet/tc_cell.rb +30 -6
  139. data/test/workbook/worksheet/tc_col.rb +9 -0
  140. data/test/workbook/worksheet/tc_comment.rb +57 -0
  141. data/test/workbook/worksheet/tc_comments.rb +57 -0
  142. data/test/workbook/worksheet/tc_conditional_formatting.rb +44 -0
  143. data/test/workbook/worksheet/tc_data_bar.rb +1 -1
  144. data/test/workbook/worksheet/tc_data_validation.rb +265 -0
  145. data/test/workbook/worksheet/tc_page_setup.rb +138 -0
  146. data/test/workbook/worksheet/tc_pane.rb +94 -0
  147. data/test/workbook/worksheet/tc_print_options.rb +72 -0
  148. data/test/workbook/worksheet/tc_protected_range.rb +17 -0
  149. data/test/workbook/worksheet/tc_row.rb +36 -12
  150. data/test/workbook/worksheet/tc_selection.rb +94 -0
  151. data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
  152. data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
  153. data/test/workbook/worksheet/tc_worksheet.rb +138 -48
  154. metadata +164 -52
  155. data/examples/example.csv +0 -1000
  156. data/lib/axlsx/drawing/cat_axis_data.rb +0 -34
  157. data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
  158. data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
  159. data/lib/axlsx/drawing/named_axis_data.rb +0 -36
  160. data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
  161. data/lib/axlsx/drawing/val_axis_data.rb +0 -27
  162. data/lib/axlsx/util/cbf.rb +0 -333
  163. data/lib/axlsx/util/cfb.rb~ +0 -201
  164. data/lib/axlsx/util/font_tables.rb~ +0 -0
  165. data/lib/axlsx/util/ms_off_crypto.rb +0 -189
  166. data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
  167. data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
  168. data/lib/axlsx/util/parser.rb~ +0 -6
  169. data/lib/axlsx/util/storage.rb~ +0 -0
  170. data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
  171. data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
  172. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  173. data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
  174. data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
  175. data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
  176. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  177. data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
  178. data/lib/schema/dc.xsd~ +0 -118
  179. data/lib/schema/dcterms.xsd~ +0 -331
  180. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  181. data/test/drawing/tc_val_axis_data.rb +0 -17
  182. data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
  183. data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
  184. data/test/workbook/worksheet/tc_col.rb~ +0 -10
  185. data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
  186. data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
  187. data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  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
+ [![Click here to lend your support to: axlsx and make a donation at www.pledgie.com !](http://www.pledgie.com/campaigns/17814.png?skin_name=chrome)](http://www.pledgie.com/campaigns/17814)
4
5
 
5
6
  **IRC**:[irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
6
7
 
@@ -16,7 +17,7 @@ Axlsx: Office Open XML Spreadsheet Generation
16
17
 
17
18
  **License**: MIT License
18
19
 
19
- **Latest Version**: 1.1.3
20
+ **Latest Version**: 1.2.0
20
21
 
21
22
  **Ruby Version**: 1.8.7, 1.9.2, 1.9.3
22
23
 
@@ -24,21 +25,35 @@ Axlsx: Office Open XML Spreadsheet Generation
24
25
 
25
26
  **Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.
26
27
 
27
- **Release Date**: April 25th 2012
28
+ **Release Date**: August 5th 2012
29
+
30
+ If you are working in rails, or with active record see:
31
+ * http://github.com/randym/acts_as_xlsx
32
+ acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
33
+
34
+ ```ruby
35
+ Posts.where(created_at > Time.now-30.days).to_xlsx
36
+ ```
37
+
38
+ ** and **
39
+
40
+ * http://github.com/straydogstudio/axlsx_rails
41
+ Axlsx_Rails provides an Axlsx renderer so you can move all your spreadsheet code from your controller into view files. Partials are supported so you can organize any code into reusable chunks (e.g. cover sheets, common styling, etc.) You can use it with acts_as_xlsx, placing the to_xlsx call in a view and add ':package => xlsx_package' to the parameter list. Now you can keep your controllers thin!
42
+
43
+ There are guides for using axlsx and acts_as_xlsx here:
44
+ [http://axlsx.blog.randym.net](http://axlsx.blog.randym.net)
45
+
46
+ The examples directory contains a number of more specific examples as
47
+ well.
28
48
 
29
49
  Synopsis
30
50
  --------
31
51
 
32
52
  Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
33
- 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.
53
+ With Axlsx you can create excel worksheets with charts, images (with links), automated and fixed column widths, customized styles, functions, tables, conditional formatting, print options, comments, merged cells, auto filters, file and stream serialization as well as full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification.
34
54
 
35
55
  ![Screen 1](https://github.com/randym/axlsx/raw/master/examples/sample.png)
36
56
 
37
- If you are working in rails, or with active record see:
38
- http://github.com/randym/acts_as_xlsx
39
-
40
- There are guides for using axlsx and acts_as_xlsx here:
41
- [http://axlsx.blogspot.com](http://axlsx.blogspot.com)
42
57
 
43
58
 
44
59
  Feature List
@@ -46,7 +61,7 @@ Feature List
46
61
 
47
62
  **1. Author xlsx documents: Axlsx is made to let you easily and quickly generate professional xlsx based reports that can be validated before serialization.
48
63
 
49
- **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.
64
+ **2. Generate 3D Pie, Line, Scatter 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. Customize gridlines, label rotation and series colors as well.
50
65
 
51
66
  **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.
52
67
 
@@ -62,17 +77,25 @@ Feature List
62
77
 
63
78
  **9. Cell level style overrides for default and customized style objects
64
79
 
65
- **10. Support for formulas
66
-
67
- **11. Support for cell merging via worksheet.merged_cells
80
+ **10. Support for formulas, merging, row and column outlining as well as
81
+ cell level input data validation.
68
82
 
69
- **12. Auto filtering tables with worksheet.auto_filter
83
+ **12. Auto filtering tables with worksheet.auto_filter as well as support for Tables
70
84
 
71
85
  **13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
72
86
 
73
87
  **14. Output to file or StringIO
74
88
 
75
- **15. Support for page margins
89
+ **15. Support for page margins and print options
90
+
91
+ **16. Support for password and non password based sheet protection.
92
+
93
+ **17. First stage interoperability support for GoogleDocs, LibreOffice,
94
+ and Numbers
95
+
96
+ **18. Support for defined names, which gives you repeated header rows for printing.
97
+
98
+ **19. Data labels for charts as well as series color customization.
76
99
 
77
100
  Installing
78
101
  ----------
@@ -81,433 +104,104 @@ To install Axlsx, use the following command:
81
104
 
82
105
  $ gem install axlsx
83
106
 
84
- #Usage
107
+ #Examples
85
108
  ------
86
109
 
87
- ```ruby
88
- require 'axlsx'
89
-
90
- p = Axlsx::Package.new
91
- wb = p.workbook
92
- ```
93
-
94
- #A Simple Workbook
95
-
96
- ```ruby
97
- wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
98
- sheet.add_row ["First Column", "Second", "Third"]
99
- sheet.add_row [1, 2, 3]
100
- end
101
- ```
102
-
103
- #Using Custom Styles
104
-
105
- ```ruby
106
- wb.styles do |s|
107
- black_cell = s.add_style :bg_color => "00", :fg_color => "FF", :sz => 14, :alignment => { :horizontal=> :center }
108
- blue_cell = s.add_style :bg_color => "0000FF", :fg_color => "FF", :sz => 20, :alignment => { :horizontal=> :center }
109
- wb.add_worksheet(:name => "Custom Styles") do |sheet|
110
- sheet.add_row ["Text Autowidth", "Second", "Third"], :style => [black_cell, blue_cell, black_cell]
111
- sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
112
- end
113
- end
114
- ```
115
-
116
- #Using Custom Border Styles
117
-
118
- ```ruby
119
- wb.styles do |s|
120
- red_border = s.add_style :border => { :style => :thin, :color =>"FFFF0000" }
121
- blue_border = s.add_style :border => { :style => :thin, :color =>"FF0000FF" }
122
-
123
- wb.add_worksheet(:name => "Custom Borders") do |sheet|
124
- sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border
125
- sheet.add_row [1, 2, 3], :style => blue_border
126
- end
127
- end
128
- ```
129
-
130
-
131
- ##Using Custom Formatting and date1904
132
-
133
- ```ruby
134
- require 'date'
135
- wb.styles do |s|
136
- date = s.add_style(:format_code => "yyyy-mm-dd", :border => Axlsx::STYLE_THIN_BORDER)
137
- padded = s.add_style(:format_code => "00#", :border => Axlsx::STYLE_THIN_BORDER)
138
- percent = s.add_style(:format_code => "0000%", :border => Axlsx::STYLE_THIN_BORDER)
139
- # wb.date1904 = true # Use the 1904 date system (Used by Excel for Mac < 2011)
140
- wb.add_worksheet(:name => "Formatting Data") do |sheet|
141
- sheet.add_row ["Custom Formatted Date", "Percent Formatted Float", "Padded Numbers"], :style => Axlsx::STYLE_THIN_BORDER
142
- sheet.add_row [Date::strptime('2012-01-19','%Y-%m-%d'), 0.2, 32], :style => [date, percent, padded]
143
- end
144
- end
145
- ```
146
-
147
-
148
- ##Add an Image
149
-
150
- ```ruby
151
- wb.add_worksheet(:name => "Images") do |sheet|
152
- img = File.expand_path('../image1.jpeg', __FILE__)
153
- sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
154
- image.width=720
155
- image.height=666
156
- image.start_at 2, 2
157
- end
158
- end
159
- ```
160
-
161
- ##Add an Image with a hyperlink
162
-
163
- ```ruby
164
- wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
165
- img = File.expand_path('../image1.jpeg', __FILE__)
166
- sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
167
- image.width=720
168
- image.height=666
169
- image.hyperlink.tooltip = "Labeled Link"
170
- image.start_at 2, 2
171
- end
172
- end
173
- ```
174
-
175
- ##Asian Language Support
176
-
177
- ```ruby
178
- wb.add_worksheet(:name => "日本語でのシート名") do |sheet|
179
- sheet.add_row ["日本語"]
180
- sheet.add_row ["华语/華語"]
181
- sheet.add_row ["한국어/조선말"]
182
- end
183
- ```
184
-
185
- ##Styling Columns
186
-
187
- ```ruby
188
- wb.styles do |s|
189
- percent = s.add_style :num_fmt => 9
190
- wb.add_worksheet(:name => "Styling Columns") do |sheet|
191
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
192
- sheet.add_row [1, 2, 0.3, 4]
193
- sheet.add_row [1, 2, 0.2, 4]
194
- sheet.add_row [1, 2, 0.1, 4]
195
- sheet.col_style 2, percent, :row_offset => 1
196
- end
197
- end
198
- ```
199
-
200
- ##Hiding Columns
201
-
202
- ```ruby
203
- wb.styles do |s|
204
- percent = s.add_style :num_fmt => 9
205
- wb.add_worksheet(:name => "Hidden Column") do |sheet|
206
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
207
- sheet.add_row [1, 2, 0.3, 4]
208
- sheet.add_row [1, 2, 0.2, 4]
209
- sheet.add_row [1, 2, 0.1, 4]
210
- sheet.col_style 2, percent, :row_offset => 1
211
- sheet.column_info[1].hidden = true
212
- end
213
- end
214
- ```
215
-
216
- ##Styling Rows
217
-
218
- ```ruby
219
- wb.styles do |s|
220
- head = s.add_style :bg_color => "00", :fg_color => "FF"
221
- percent = s.add_style :num_fmt => 9
222
- wb.add_worksheet(:name => "Styling Rows") do |sheet|
223
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
224
- sheet.add_row [1, 2, 0.3, 4]
225
- sheet.add_row [1, 2, 0.2, 4]
226
- sheet.add_row [1, 2, 0.1, 4]
227
- sheet.col_style 2, percent, :row_offset => 1
228
- sheet.row_style 0, head
229
- end
230
- end
231
- ```
232
-
233
- ##Styling Cell Overrides
234
-
235
- ```ruby
236
- wb.add_worksheet(:name => "Cell Level Style Overrides") do |sheet|
237
- # cell level style overides when adding cells
238
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4'], :sz => 16
239
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
240
- # cell level style overrides via sheet range
241
- sheet["A1:D1"].each { |c| c.color = "FF0000"}
242
- sheet['A1:D2'].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
243
- end
244
- ```
245
-
246
- ##Using formula
247
-
248
- ```ruby
249
- wb.add_worksheet(:name => "Using Formulas") do |sheet|
250
- sheet.add_row ['col 1', 'col 2', 'col 3', 'col 4']
251
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
252
- end
253
- ```
254
-
255
- ##Automatic cell types
256
-
257
- ```ruby
258
- wb.add_worksheet(:name => "Automatic cell types") do |sheet|
259
- sheet.add_row ["Date", "Time", "String", "Boolean", "Float", "Integer"]
260
- sheet.add_row [Date.today, Time.now, "value", true, 0.1, 1]
261
- end
262
- ```
263
-
264
- ##Merging Cells.
265
-
266
- ```ruby
267
- wb.add_worksheet(:name => 'Merging Cells') do |sheet|
268
- # cell level style overides when adding cells
269
- sheet.add_row ["col 1", "col 2", "col 3", "col 4"], :sz => 16
270
- sheet.add_row [1, 2, 3, "=SUM(A2:C2)"]
271
- sheet.add_row [2, 3, 4, "=SUM(A3:C3)"]
272
- sheet.add_row ["total", "", "", "=SUM(D2:D3)"]
273
- sheet.merge_cells("A4:C4")
274
- sheet["A1:D1"].each { |c| c.color = "FF0000"}
275
- sheet["A1:D4"].each { |c| c.style = Axlsx::STYLE_THIN_BORDER }
276
- end
277
- ```
278
-
279
- ##Generating A Bar Chart
280
-
281
- ```ruby
282
- wb.add_worksheet(:name => "Bar Chart") do |sheet|
283
- sheet.add_row ["A Simple Bar Chart"]
284
- sheet.add_row ["First", "Second", "Third"]
285
- sheet.add_row [1, 2, 3]
286
- sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
287
- chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
288
- chart.valAxis.label_rotation = -45
289
- chart.catAxis.label_rotation = 45
290
- end
291
- end
292
- ```
293
-
294
- ##Hide Gridlines in chart
295
-
296
- ```ruby
297
- wb.add_worksheet(:name => "Chart With No Gridlines") do |sheet|
298
- sheet.add_row ["A Simple Bar Chart"]
299
- sheet.add_row ["First", "Second", "Third"]
300
- sheet.add_row [1, 2, 3]
301
- sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A4", :end_at => "F17") do |chart|
302
- chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :title => sheet["A1"]
303
- chart.valAxis.gridlines = false
304
- chart.catAxis.gridlines = false
305
- end
306
- end
307
- ```
308
-
309
- ##Generating A Pie Chart
310
-
311
- ```ruby
312
- wb.add_worksheet(:name => "Pie Chart") do |sheet|
313
- sheet.add_row ["First", "Second", "Third", "Fourth"]
314
- sheet.add_row [1, 2, 3, "=PRODUCT(A2:C2)"]
315
- sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,2], :end_at => [5, 15], :title => "example 3: Pie Chart") do |chart|
316
- chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"]
317
- end
318
- end
319
- ```
320
-
321
- ##Data over time
322
-
323
- ```ruby
324
- wb.add_worksheet(:name=>'Charting Dates') do |sheet|
325
- # cell level style overides when adding cells
326
- sheet.add_row ['Date', 'Value'], :sz => 16
327
- sheet.add_row [Time.now - (7*60*60*24), 3]
328
- sheet.add_row [Time.now - (6*60*60*24), 7]
329
- sheet.add_row [Time.now - (5*60*60*24), 18]
330
- sheet.add_row [Time.now - (4*60*60*24), 1]
331
- sheet.add_chart(Axlsx::Bar3DChart) do |chart|
332
- chart.start_at "B7"
333
- chart.end_at "H27"
334
- chart.add_series(:data => sheet["B2:B5"], :labels => sheet["A2:A5"], :title => sheet["B1"])
335
- end
336
- end
337
- ```
110
+ The example listing is getting overly large to maintain here.
111
+ If you are using Yard, you will be able to see the examples in line below.
338
112
 
339
- ##Generating A Line Chart
113
+ Here's a teaser that kicks about 2% of what the gem can do.
340
114
 
341
115
  ```ruby
342
- wb.add_worksheet(:name => "Line Chart") do |sheet|
343
- sheet.add_row ["First", 1, 5, 7, 9]
344
- sheet.add_row ["Second", 5, 2, 14, 9]
345
- sheet.add_chart(Axlsx::Line3DChart, :title => "example 6: Line Chart", :rotX => 30, :rotY => 20) do |chart|
346
- chart.start_at 0, 2
347
- chart.end_at 10, 15
348
- chart.add_series :data => sheet["B1:E1"], :title => sheet["A1"]
349
- chart.add_series :data => sheet["B2:E2"], :title => sheet["A2"]
116
+ Axlsx::Package.new do |p|
117
+ p.workbook.add_worksheet(:name => "Pie Chart") do |sheet|
118
+ sheet.add_row ["Simple Pie Chart"]
119
+ %w(first second third).each { |label| sheet.add_row [label, rand(24)+1] }
120
+ sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,5], :end_at => [10, 20], :title => "example 3: Pie Chart") do |chart|
121
+ chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"], :colors => ['FF0000', '00FF00', '0000FF']
122
+ end
350
123
  end
124
+ p.serialize('simple.xlsx')
351
125
  end
352
126
  ```
353
127
 
354
- ##Generating A Scatter Chart
355
-
356
- ```ruby
357
- wb.add_worksheet(:name => "Scatter Chart") do |sheet|
358
- sheet.add_row ["First", 1, 5, 7, 9]
359
- sheet.add_row ["", 1, 25, 49, 81]
360
- sheet.add_row ["Second", 5, 2, 14, 9]
361
- sheet.add_row ["", 5, 10, 15, 20]
362
- sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart|
363
- chart.start_at 0, 4
364
- chart.end_at 10, 19
365
- chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"]
366
- chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"]
367
- end
368
- end
369
- ```
370
-
371
- ##Auto Filter
372
-
373
- ```ruby
374
- wb.add_worksheet(:name => "Auto Filter") do |sheet|
375
- sheet.add_row ["Build Matrix"]
376
- sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
377
- sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
378
- sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
379
- sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
380
- sheet.auto_filter = "A2:D5"
381
- end
382
- ```
383
-
384
- ##Tables
385
-
386
- ```ruby
387
- wb.add_worksheet(:name => "Table") do |sheet|
388
- sheet.add_row ["Build Matrix"]
389
- sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
390
- sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
391
- sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
392
- sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
393
- sheet.add_table "A2:D5", :name => 'Build Matrix'
394
- end
395
- ```
396
-
397
- ##Specifying Column Widths
398
-
399
- ```ruby
400
- wb.add_worksheet(:name => "custom column widths") do |sheet|
401
- sheet.add_row ["I use autowidth and am very wide", "I use a custom width and am narrow"]
402
- sheet.add_row ['abcdefg', 'This is a very long text and should flow into the right cell', nil, 'xxx' ]
403
- sheet.column_widths nil, 3, 5, nil
404
- end
405
- ```
406
-
407
- ##Fit to page printing
408
-
409
- ```ruby
410
- wb.add_worksheet(:name => "fit to page") do |sheet|
411
- sheet.add_row ['this all goes on one page']
412
- sheet.fit_to_page = true
413
- end
414
- ```
415
-
416
- ##Hide Gridlines in worksheet
417
-
418
- ```ruby
419
- wb.add_worksheet(:name => "No Gridlines") do |sheet|
420
- sheet.add_row ["This", "Sheet", "Hides", "Gridlines"]
421
- sheet.show_gridlines = false
422
- end
423
- ```
424
-
425
- ##Specify Page Margins for printing
426
-
427
- ```ruby
428
- margins = {:left => 3, :right => 3, :top => 1.2, :bottom => 1.2, :header => 0.7, :footer => 0.7}
429
- wb.add_worksheet(:name => "print margins", :page_margins => margins) do |sheet|
430
- sheet.add_row ["this sheet uses customized page margins for printing"]
431
- end
432
- ```
433
-
434
- ##Validate and Serialize
435
-
436
- ```ruby
437
- p.serialize("example.xlsx")
438
-
439
- s = p.to_stream()
440
- File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
441
- ```
442
-
443
- ##Using Shared Strings
444
-
445
- ```ruby
446
- p.use_shared_strings = true
447
- p.serialize("shared_strings_example.xlsx")
448
- ```
128
+ Please see the [examples](https://github.com/randym/axlsx/tree/master/examples/example.rb) for more.
449
129
 
450
- ##Disabling Autowidth
130
+ {include:file:examples/example.rb}
451
131
 
452
- ```ruby
453
- p = Axlsx::Package.new
454
- p.use_autowidth = false
455
- wb = p.workbook
456
- wb.add_worksheet(:name => "Manual Widths") do | sheet |
457
- sheet.add_row ['oh look! no autowidth']
458
- end
459
- p.validate.each { |e| puts e.message }
460
- p.serialize("no-use_autowidth.xlsx")
461
- ```
132
+ There is much, much more you can do with this gem. If you get stuck, grab me on IRC or submit an issue to GitHub. Chances are that it has already been implemented. If it hasn't - let's take a look at adding it in.
462
133
 
463
134
  #Documentation
464
135
  --------------
465
136
  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:
466
137
 
467
- ```bash
468
- gem install yard
469
- yard server -g
470
- ```
138
+ gem install yard
139
+
140
+ yard server -g
141
+
471
142
  #Specs
472
143
  ------
473
144
  This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
474
145
 
475
146
  #Change log
476
147
  ---------
477
- - ** April.25.12:*: 1.1.3 release
478
- - Primarily because I am stupid.....Updates to readme to properly report version, add in missing docs and restructure example directory.
479
-
480
- - ** April.25.12:*: 1.1.2 release
481
- - Conditional Formatting completely implemented.
482
- - refactoring / documentation for Style#add_style
483
- - added in label rotation for chart axis labels
484
- - bugfix to properly assign style and type info to cells when only partial information is provided in the types/style option
485
-
486
- - ** April.18.12**: 1.1.1 release
487
- - bugfix for autowidth calculations across multiple rows
488
- - bugfix for dimension calculations with nil cells.
489
- - REMOVED RMAGICK dependency WOOT!
490
- - Update readme to show screenshot of gem output.
491
- - Cleanup benchmark and add benchmark rake task
492
-
493
- - ** April.3.12**: 1.1.0 release
494
- - bugfix patch name_to_indecies to properly handle extended ranges.
495
- - bugfix properly serialize chart title.
496
- - 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!
497
- - Added Fit to Page printing
498
- - added support for turning off gridlines in charts.
499
- - added support for turning off gridlines in worksheet.
500
- - bugfix some apps like libraoffice require apply[x] attributes to be true. applyAlignment is now properly set.
501
- - 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.
502
- - added border style specification to styles#add_style. See the example in the readme.
503
- - Support for tables added in - Note: Pre 2011 versions of Mac office do not support this feature and will warn.
504
- - Support for splatter charts added
505
- - Major (like 7x faster!) performance updates.
506
- - Gem now supports for JRuby 1.6.7, as well as experimental support for Rubinius
148
+ - **August.5.12**: 1.2.0
149
+ - rebuilt worksheet serialization to clean up the code base a bit.
150
+ - added data labels for charts
151
+ - added table header printing for each sheet via defined_name. This
152
+ means that when you print your worksheet, the header rows show for every page
153
+ - **July.??.12**: 1.1.9 release
154
+ - lots of code clean up for worksheet
155
+ - added in data labels for pie charts, line charts and bar charts.
156
+ - bugfix chard with data in a sheet that has a space in the name are
157
+ now auto updating formula based values
158
+ - **July.14.12**: 1.1.8 release
159
+ - added html entity encoding for sheet names. This allows you to use
160
+ characters like '<' and '&' in your sheet names.
161
+ - new - first round google docs interoperability
162
+ - added filter to strip out control characters from cell data.
163
+ - added in interop requirements so that charts are properly exported
164
+ to PDF from Libra Office
165
+ - various readability improvements and work standardizing attribute
166
+ names to snake_case. Aliases are provided for backward compatiblity
167
+ - **June.11.12**: 1.1.7 release
168
+ - fix chart rendering issue when label offset is specified as a
169
+ percentage in serialization and ensure that formula are not stored
170
+ in value caches
171
+ - fix bug that causes repair warnings when using a text only title reference.
172
+ - Add title property to axis so you can lable the x/y/series axis for
173
+ charts.
174
+ - Add sheet views with panes
507
175
 
508
176
  Please see the {file:CHANGELOG.md} document for past release information.
509
177
 
178
+ # Known interoperability issues.
179
+ As axslx implements the Office Open XML (ECMA-376 spec) much of the
180
+ functionality is interoperable with other spreadsheet software. Below is
181
+ a listing of some known issues.
182
+
183
+ 1. Libra Office
184
+ - You must specify colors for your series. see examples/chart_colors.rb
185
+ for an example.
186
+ - You must use data in your sheet for charts. You cannot use hard coded
187
+ values.
188
+ - Chart axis and gridlines do not render. I have a feeling this is
189
+ related to themes, which axlsx does not implement at this time.
190
+
191
+ 2. Google Docs
192
+ - Images are known to not work with google docs
193
+ - border colors do not work
194
+
195
+ 3. Numbers
196
+ - you must set 'use_shared_strings' to true
197
+ - charts do not render
198
+
199
+
510
200
  #Thanks!
201
+
202
+ Open source software is a community effort. None of this could have been
203
+ done without the help of the people below.
204
+
511
205
  --------
512
206
  [ochko](https://github.com/ochko) - for performance fixes, kicking the crap out of axlsx and helping to maintain my general sanity.
513
207
 
@@ -529,6 +223,12 @@ Please see the {file:CHANGELOG.md} document for past release information.
529
223
 
530
224
  [scpike](https://github.com/scpike) - for keeping numbers fixed even when they are rational and a super clean implementation of conditional formatting.
531
225
 
226
+ [janhuehne](https://github.com/janhuehne) - for working out the decoder ring and adding in cell level validation, and providing a support for window panes.
227
+
228
+ [rfc2616](https://github.com/rfc2616) - for FINALLY working out the interop issues with google docs.
229
+
230
+ [straydogstudio](https://github.com/straydocstudio) - For making an AWESOME axlsx templating gem for rails.
231
+
532
232
  #Copyright and License
533
233
  ----------
534
234
 
data/Rakefile CHANGED
@@ -9,7 +9,9 @@ task :benchmark do
9
9
  end
10
10
 
11
11
  task :gendoc do
12
- system "yardoc"
12
+ #puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
13
+ system "yardoc"
14
+ system "yard stats --list-undoc"
13
15
  end
14
16
 
15
17
  task :test do
@@ -17,12 +19,18 @@ task :test do
17
19
  Rake::TestTask.new do |t|
18
20
  t.libs << 'test'
19
21
  t.test_files = FileList['test/**/tc_*.rb']
20
- t.verbose = true
22
+ t.verbose = false
23
+ t.warning = true
21
24
  end
22
25
  end
23
26
 
27
+ task :report do
28
+ require 'cover_me'
29
+ CoverMe.complete!
30
+ end
31
+
24
32
  task :release => :build do
25
33
  system "gem push axlsx-#{Axlsx::VERSION}.gem"
26
34
  end
27
35
 
28
- task :default => :test
36
+ task :default => :test