axlsx 1.1.0 → 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 (214) hide show
  1. data/.yardopts +5 -2
  2. data/CHANGELOG.md +78 -0
  3. data/LICENSE +1 -1
  4. data/README.md +132 -331
  5. data/Rakefile +17 -5
  6. data/examples/basic_charts.rb +54 -0
  7. data/examples/chart_colors.rb +88 -0
  8. data/examples/conditional_formatting/example_conditional_formatting.rb +72 -0
  9. data/examples/conditional_formatting/getting_barred.rb +37 -0
  10. data/examples/conditional_formatting/hitting_the_high_notes.rb +37 -0
  11. data/examples/conditional_formatting/scaled_colors.rb +39 -0
  12. data/examples/conditional_formatting/stop_and_go.rb +37 -0
  13. data/examples/data_validation.rb +50 -0
  14. data/examples/example.rb +300 -152
  15. data/examples/example.xlsx +0 -0
  16. data/examples/example_streamed.xlsx +0 -0
  17. data/examples/extractive.pdf +0 -0
  18. data/examples/extractive.rb +45 -0
  19. data/examples/no-use_autowidth.xlsx +0 -0
  20. data/examples/sample.png +0 -0
  21. data/examples/scraping_html.rb +91 -0
  22. data/examples/shared_strings_example.xlsx +0 -0
  23. data/examples/sheet_protection.rb +10 -0
  24. data/examples/sheet_view.rb +34 -0
  25. data/examples/skydrive/real_example.rb +63 -0
  26. data/examples/two_cell_anchor_image.rb +11 -0
  27. data/lib/axlsx/content_type/content_type.rb +2 -0
  28. data/lib/axlsx/content_type/default.rb +30 -15
  29. data/lib/axlsx/content_type/override.rb +29 -14
  30. data/lib/axlsx/doc_props/app.rb +161 -104
  31. data/lib/axlsx/doc_props/core.rb +9 -5
  32. data/lib/axlsx/drawing/ax_data_source.rb +26 -0
  33. data/lib/axlsx/drawing/axis.rb +106 -35
  34. data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
  35. data/lib/axlsx/drawing/bar_series.rb +25 -7
  36. data/lib/axlsx/drawing/cat_axis.rb +50 -22
  37. data/lib/axlsx/drawing/chart.rb +69 -56
  38. data/lib/axlsx/drawing/d_lbls.rb +100 -0
  39. data/lib/axlsx/drawing/drawing.rb +28 -12
  40. data/lib/axlsx/drawing/graphic_frame.rb +2 -1
  41. data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
  42. data/lib/axlsx/drawing/line_series.rb +20 -4
  43. data/lib/axlsx/drawing/num_data.rb +52 -0
  44. data/lib/axlsx/drawing/num_data_source.rb +61 -0
  45. data/lib/axlsx/drawing/num_val.rb +32 -0
  46. data/lib/axlsx/drawing/pic.rb +44 -4
  47. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
  48. data/lib/axlsx/drawing/pie_series.rb +18 -4
  49. data/lib/axlsx/drawing/scatter_chart.rb +12 -18
  50. data/lib/axlsx/drawing/scatter_series.rb +28 -2
  51. data/lib/axlsx/drawing/ser_axis.rb +1 -1
  52. data/lib/axlsx/drawing/series.rb +1 -1
  53. data/lib/axlsx/drawing/str_data.rb +42 -0
  54. data/lib/axlsx/drawing/str_val.rb +33 -0
  55. data/lib/axlsx/drawing/title.rb +21 -9
  56. data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
  57. data/lib/axlsx/drawing/view_3D.rb +44 -31
  58. data/lib/axlsx/drawing/vml_drawing.rb +42 -0
  59. data/lib/axlsx/drawing/vml_shape.rb +125 -0
  60. data/lib/axlsx/package.rb +44 -16
  61. data/lib/axlsx/rels/relationship.rb +3 -3
  62. data/lib/axlsx/rels/relationships.rb +1 -11
  63. data/lib/axlsx/stylesheet/color.rb +0 -1
  64. data/lib/axlsx/stylesheet/dxf.rb +79 -0
  65. data/lib/axlsx/stylesheet/font.rb +2 -1
  66. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  67. data/lib/axlsx/stylesheet/styles.rb +143 -50
  68. data/lib/axlsx/stylesheet/table_style.rb +3 -3
  69. data/lib/axlsx/stylesheet/xf.rb +2 -0
  70. data/lib/axlsx/util/constants.rb +36 -0
  71. data/lib/axlsx/util/simple_typed_list.rb +15 -21
  72. data/lib/axlsx/util/validators.rb +122 -5
  73. data/lib/axlsx/version.rb +2 -7
  74. data/lib/axlsx/workbook/defined_name.rb +174 -0
  75. data/lib/axlsx/workbook/defined_names.rb +21 -0
  76. data/lib/axlsx/workbook/shared_strings_table.rb +12 -13
  77. data/lib/axlsx/workbook/workbook.rb +71 -13
  78. data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
  79. data/lib/axlsx/workbook/worksheet/cell.rb +45 -36
  80. data/lib/axlsx/workbook/worksheet/cfvo.rb +62 -0
  81. data/lib/axlsx/workbook/worksheet/col.rb +17 -1
  82. data/lib/axlsx/workbook/worksheet/color_scale.rb +76 -0
  83. data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
  84. data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
  85. data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
  86. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +82 -0
  87. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +216 -0
  88. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
  89. data/lib/axlsx/workbook/worksheet/data_bar.rb +97 -0
  90. data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
  91. data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
  92. data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
  93. data/lib/axlsx/workbook/worksheet/icon_set.rb +83 -0
  94. data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
  95. data/lib/axlsx/workbook/worksheet/page_setup.rb +113 -0
  96. data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
  97. data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
  98. data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
  99. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
  100. data/lib/axlsx/workbook/worksheet/row.rb +69 -12
  101. data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
  102. data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
  103. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
  104. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
  105. data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
  106. data/lib/axlsx/workbook/worksheet/table.rb +3 -3
  107. data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
  108. data/lib/axlsx/workbook/worksheet/worksheet.rb +379 -233
  109. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
  110. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
  111. data/lib/axlsx.rb +31 -16
  112. data/test/benchmark.rb +30 -38
  113. data/test/content_type/tc_content_type.rb +1 -6
  114. data/test/doc_props/tc_app.rb +31 -1
  115. data/test/doc_props/tc_core.rb +3 -1
  116. data/test/drawing/tc_axis.rb +46 -3
  117. data/test/drawing/tc_bar_3D_chart.rb +12 -12
  118. data/test/drawing/tc_bar_series.rb +17 -13
  119. data/test/drawing/tc_cat_axis.rb +3 -3
  120. data/test/drawing/tc_cat_axis_data.rb +23 -13
  121. data/test/drawing/tc_chart.rb +29 -11
  122. data/test/drawing/tc_d_lbls.rb +47 -0
  123. data/test/drawing/tc_data_source.rb +17 -0
  124. data/test/drawing/tc_drawing.rb +11 -5
  125. data/test/drawing/tc_hyperlink.rb +4 -5
  126. data/test/drawing/tc_line_series.rb +9 -11
  127. data/test/drawing/tc_named_axis_data.rb +27 -0
  128. data/test/drawing/tc_num_data.rb +31 -0
  129. data/test/drawing/tc_num_val.rb +29 -0
  130. data/test/drawing/tc_pic.rb +22 -2
  131. data/test/drawing/tc_pie_3D_chart.rb +4 -8
  132. data/test/drawing/tc_pie_series.rb +11 -13
  133. data/test/drawing/tc_scatter_chart.rb +6 -1
  134. data/test/drawing/tc_scatter_series.rb +6 -5
  135. data/test/drawing/tc_series.rb +1 -1
  136. data/test/drawing/tc_str_data.rb +18 -0
  137. data/test/drawing/tc_str_val.rb +21 -0
  138. data/test/drawing/tc_title.rb +16 -0
  139. data/test/drawing/tc_two_cell_anchor.rb +2 -3
  140. data/test/drawing/tc_view_3D.rb +18 -18
  141. data/test/drawing/tc_vml_drawing.rb +25 -0
  142. data/test/drawing/tc_vml_shape.rb +100 -0
  143. data/test/profile.rb +2 -1
  144. data/test/rels/tc_relationship.rb +1 -0
  145. data/test/stylesheet/tc_dxf.rb +81 -0
  146. data/test/stylesheet/tc_gradient_fill.rb +8 -0
  147. data/test/stylesheet/tc_pattern_fill.rb +7 -1
  148. data/test/stylesheet/tc_styles.rb +163 -3
  149. data/test/stylesheet/tc_table_style.rb +8 -0
  150. data/test/stylesheet/tc_table_style_element.rb +10 -1
  151. data/test/tc_helper.rb +1 -0
  152. data/test/tc_package.rb +93 -17
  153. data/test/util/tc_simple_typed_list.rb +13 -0
  154. data/test/util/tc_validators.rb +95 -9
  155. data/test/workbook/tc_defined_name.rb +41 -0
  156. data/test/workbook/tc_workbook.rb +5 -3
  157. data/test/workbook/worksheet/table/tc_table.rb +3 -11
  158. data/test/workbook/worksheet/tc_cell.rb +52 -18
  159. data/test/workbook/worksheet/tc_cfvo.rb +31 -0
  160. data/test/workbook/worksheet/tc_col.rb +9 -0
  161. data/test/workbook/worksheet/tc_color_scale.rb +29 -0
  162. data/test/workbook/worksheet/tc_comment.rb +57 -0
  163. data/test/workbook/worksheet/tc_comments.rb +57 -0
  164. data/test/workbook/worksheet/tc_conditional_formatting.rb +217 -0
  165. data/test/workbook/worksheet/tc_data_bar.rb +39 -0
  166. data/test/workbook/worksheet/tc_data_validation.rb +265 -0
  167. data/test/workbook/worksheet/tc_date_time_converter.rb +11 -5
  168. data/test/workbook/worksheet/tc_icon_set.rb +45 -0
  169. data/test/workbook/worksheet/tc_page_setup.rb +138 -0
  170. data/test/workbook/worksheet/tc_pane.rb +94 -0
  171. data/test/workbook/worksheet/tc_print_options.rb +72 -0
  172. data/test/workbook/worksheet/tc_protected_range.rb +17 -0
  173. data/test/workbook/worksheet/tc_row.rb +44 -13
  174. data/test/workbook/worksheet/tc_selection.rb +94 -0
  175. data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
  176. data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
  177. data/test/workbook/worksheet/tc_worksheet.rb +147 -50
  178. metadata +216 -148
  179. data/examples/example.csv +0 -1000
  180. data/examples/example.rb~ +0 -112
  181. data/lib/axlsx/drawing/cat_axis_data.rb +0 -34
  182. data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
  183. data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
  184. data/lib/axlsx/drawing/named_axis_data.rb +0 -36
  185. data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
  186. data/lib/axlsx/drawing/val_axis_data.rb +0 -27
  187. data/lib/axlsx/stylesheet/#num_fmt.rb# +0 -69
  188. data/lib/axlsx/util/cbf.rb +0 -333
  189. data/lib/axlsx/util/cfb.rb~ +0 -201
  190. data/lib/axlsx/util/ms_off_crypto.rb +0 -189
  191. data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
  192. data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
  193. data/lib/axlsx/util/parser.rb~ +0 -6
  194. data/lib/axlsx/util/storage.rb~ +0 -0
  195. data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
  196. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  197. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  198. data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
  199. data/lib/schema/dc.xsd~ +0 -118
  200. data/lib/schema/dcterms.xsd~ +0 -331
  201. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  202. data/test/#benchmark.txt# +0 -7
  203. data/test/#tc_helper.rb# +0 -3
  204. data/test/benchmark.rb~ +0 -0
  205. data/test/benchmark.txt +0 -6
  206. data/test/benchmark.txt~ +0 -6
  207. data/test/drawing/tc_val_axis_data.rb +0 -17
  208. data/test/example.csv +0 -1000
  209. data/test/example.xlsx +0 -0
  210. data/test/example_streamed.xlsx +0 -0
  211. data/test/tc_axlsx.rb~ +0 -0
  212. data/test/tc_helper.rb~ +0 -3
  213. data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
  214. data/test/workbook/worksheet/tc_col.rb~ +0 -10
data/.yardopts CHANGED
@@ -1,5 +1,8 @@
1
1
  --protected
2
2
  --no-private
3
3
  --title "AXLSX"
4
- --files LICENSE
5
- --files CHANGELOG.md
4
+ --readme README.md
5
+ --markup markdown
6
+ --markup-provider kramdown
7
+ --files CHANGELOG.md, LICENSE
8
+ --list-undoc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,83 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **May.30.12**: 1.1.6 release
4
+ - data protection with passwords for sheets
5
+ - cell level input validators
6
+ - added support for two cell anchors for images
7
+ - test coverage now back up to 100%
8
+ - bugfix for merge cell sorting algorithm
9
+ - added fit_to method for page_setup to simplify managing witdh/height
10
+ - added ph (phonetics) and s (style) attributes for row.
11
+ - resolved all warnings generating from this gem.
12
+ - improved comment relationship management for multiple comments
13
+
14
+ - **May.13.12**: 1.1.5 release
15
+ - MOAR print options! You can now specify paper size, orientation,
16
+ fit to width, page margings and gridlines for printing.
17
+ - Support for adding comments to your worksheets
18
+ - bugfix for applying style to empty cells
19
+ - bugfix for parsing formula with multiple '='
20
+
21
+ - **May.3.12:**: 1.1.4 release
22
+ - MOAR examples
23
+ - added outline level for rows and columns
24
+ - rebuild of numeric and axis data sources for charts
25
+ - added delete to axis
26
+ - added tick and label mark skipping for cat axis in charts
27
+ - bugfix for table headers method
28
+ - sane(er) defaults for chart positioning
29
+ - bugfix in val_axis_data to properly serialize value axis data. Excel does not mind as it reads from the sheet, but nokogiri has a fit if the elements are empty.
30
+ - Added support for specifying the color of data series in charts.
31
+ - bugfix using add_cell on row mismanaged calls to update_column_info.
32
+
33
+ - ** April.25.12:**: 1.1.3 release
34
+ - Primarily because I am stupid.....Updates to readme to properly report version, add in missing docs and restructure example directory.
35
+
36
+ - ** April.25.12:**: 1.1.2 release
37
+ - Conditional Formatting completely implemented.
38
+ - refactoring / documentation for Style#add_style
39
+ - added in label rotation for chart axis labels
40
+ - bugfix to properly assign style and type info to cells when only partial information is provided in the types/style option
41
+
42
+ - ** April.18.12**: 1.1.1 release
43
+ - bugfix for autowidth calculations across multiple rows
44
+ - bugfix for dimension calculations with nil cells.
45
+ - REMOVED RMAGICK dependency WOOT!
46
+ - Update readme to show screenshot of gem output.
47
+ - Cleanup benchmark and add benchmark rake task
48
+
49
+ - ** April.3.12**: 1.1.0 release
50
+ - bugfix patch name_to_indecies to properly handle extended ranges.
51
+ - bugfix properly serialize chart title.
52
+ - 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!
53
+ - Added Fit to Page printing
54
+ - added support for turning off gridlines in charts.
55
+ - added support for turning off gridlines in worksheet.
56
+ - bugfix some apps like libraoffice require apply[x] attributes to be true. applyAlignment is now properly set.
57
+ - 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.
58
+ - added border style specification to styles#add_style. See the example in the readme.
59
+ - Support for tables added in - Note: Pre 2011 versions of Mac office do not support this feature and will warn.
60
+ - Support for splatter charts added
61
+ - Major (like 7x faster!) performance updates.
62
+ - Gem now supports for JRuby 1.6.7, as well as experimental support for Rubinius
63
+
64
+ - ** March.5.12**: 1.0.18 release
65
+ https://github.com/randym/axlsx/compare/1.0.17...1.0.18
66
+ - bugfix custom borders are not properly applied when using styles.add_style
67
+ - interop worksheet names must be 31 characters or less or some versions of office complain about repairs
68
+ - added type support for :boolean and :date types cell values
69
+ - added support for fixed column widths
70
+ - added support for page_margins
71
+ - added << alias for add_row
72
+ - removed presetting of date1904 based on authoring platform. Now defaults to use 1900 epoch (date1904 = false)
73
+
74
+ - ** February.14.12**: 1.0.17 release
75
+ https://github.com/randym/axlsx/compare/1.0.16...1.0.17
76
+ - Added in support for serializing to StringIO
77
+ - Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers
78
+ - Added in support for fixed column_widths
79
+ - Removed unneeded dependencies on active-support and i18n
80
+
3
81
  - ** February.2.12**: 1.0.16 release
4
82
  https://github.com/randym/axlsx/compare/1.0.15...1.0.16
5
83
  - Bug fix for schema file locations when validating in rails
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Randy Morgan
1
+ Copyright (c) 2011, 2012 Randy Morgan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -1,50 +1,67 @@
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
- **IRC**: [irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
6
+ **IRC**:[irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
6
7
 
7
- **Git**: [http://github.com/randym/axlsx](http://github.com/randym/axlsx)
8
+ **Git**:[http://github.com/randym/axlsx](http://github.com/randym/axlsx)
8
9
 
9
- **Twitter**: [https://twitter.com/#!/morgan_randy](https://twitter.com/#!/morgan_randy) release announcements and news will be published here
10
+ **Twitter**: [https://twitter.com/#!/morgan_randy](https://twitter.com/#!/morgan_randy)
10
11
 
11
- **Author**: Randy Morgan
12
+ **Google Group**: [https://groups.google.com/forum/?fromgroups#!forum/axlsx](https://groups.google.com/forum/?fromgroups#!forum/axlsx)
13
+
14
+ **Author**: Randy Morgan
12
15
 
13
16
  **Copyright**: 2011 - 2012
14
17
 
15
- **License**: MIT License
18
+ **License**: MIT License
16
19
 
17
- **Latest Version**: 1.1.0
20
+ **Latest Version**: 1.2.0
18
21
 
19
22
  **Ruby Version**: 1.8.7, 1.9.2, 1.9.3
20
23
 
21
- **JRuby Version**: 1.6.7
24
+ **JRuby Version**: 1.6.7 1.8 and 1.9 modes
25
+
26
+ **Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.
27
+
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)
22
45
 
23
- **Release Date**: April 3st 2012
46
+ The examples directory contains a number of more specific examples as
47
+ well.
24
48
 
25
49
  Synopsis
26
50
  --------
27
51
 
28
52
  Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
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.
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.
30
54
 
31
- If you are working in rails, or with active record see:
32
- http://github.com/randym/acts_as_xlsx
33
-
34
- There are guides for using axlsx and acts_as_xlsx here:
35
- [http://axlsx.blogspot.com](http://axlsx.blogspot.com)
55
+ ![Screen 1](https://github.com/randym/axlsx/raw/master/examples/sample.png)
36
56
 
37
- Help Wanted
38
- -----------
39
57
 
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
58
 
42
59
  Feature List
43
60
  ------------
44
61
 
45
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.
46
63
 
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.
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.
48
65
 
49
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.
50
67
 
@@ -60,17 +77,25 @@ Feature List
60
77
 
61
78
  **9. Cell level style overrides for default and customized style objects
62
79
 
63
- **10. Support for formulas
80
+ **10. Support for formulas, merging, row and column outlining as well as
81
+ cell level input data validation.
64
82
 
65
- **11. Support for cell merging via worksheet.merged_cells
66
-
67
- **12. Auto filtering tables with worksheet.auto_filter
83
+ **12. Auto filtering tables with worksheet.auto_filter as well as support for Tables
68
84
 
69
85
  **13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
70
86
 
71
87
  **14. Output to file or StringIO
72
88
 
73
- **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.
74
99
 
75
100
  Installing
76
101
  ----------
@@ -79,294 +104,40 @@ To install Axlsx, use the following command:
79
104
 
80
105
  $ gem install axlsx
81
106
 
82
- #Usage
107
+ #Examples
83
108
  ------
84
109
 
85
- require 'axlsx'
86
-
87
- p = Axlsx::Package.new
88
- wb = p.workbook
89
-
90
- ##A Simple Workbook
91
-
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
96
-
97
- ##Using Custom Styles and Row Heights
98
-
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
-
108
- ##Using Custom Formatting and date1904
109
-
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
121
-
122
- ##Add an Image
123
-
124
- wb.add_worksheet(:name => "Images") do |sheet|
125
- img = File.expand_path('examples/image1.jpeg')
126
- sheet.add_image(:image_src => img, :noSelect => true, :noMove => true) do |image|
127
- image.width=720
128
- image.height=666
129
- image.start_at 2, 2
130
- end
131
- end
132
-
133
- ##Add an Image with a hyperlink
134
-
135
- wb.add_worksheet(:name => "Image with Hyperlink") do |sheet|
136
- img = File.expand_path('examples/image1.jpeg')
137
- sheet.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink=>"http://axlsx.blogspot.com") do |image|
138
- image.width=720
139
- image.height=666
140
- image.hyperlink.tooltip = "Labeled Link"
141
- image.start_at 2, 2
142
- end
143
- end
144
-
145
- ##Asian Language Support
146
-
147
- wb.add_worksheet(:name => "Unicode Support") do |sheet|
148
- sheet.add_row ["日本語"]
149
- sheet.add_row ["华语/華語"]
150
- sheet.add_row ["한국어/조선말"]
151
- end
152
-
153
- ##Styling Columns
154
-
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
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
-
180
- ##Styling Rows
181
-
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
194
-
195
- ##Styling Cell Overrides
196
-
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
205
-
206
- ##Using formula
207
-
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
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
-
220
- ##Merging Cells.
221
-
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
232
-
233
- ##Generating A Bar Chart
234
-
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
243
-
244
- ##Generating A Pie Chart
245
-
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
253
-
254
- ##Data over time
255
-
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
269
-
270
- ##Generating A Line Chart
271
-
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
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
297
-
298
- ##Auto Filter
299
-
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
308
-
309
- ##Specifying Column Widths
310
-
311
- wb.add_worksheet(:name => "custom column widths") do |sheet|
312
- sheet.add_row ["I use auto_fit and am very wide", "I use a custom width and am narrow"]
313
- sheet.column_widths nil, 3
314
- end
315
-
316
- ##Specify Page Margins for printing
317
-
318
- margins = {:left => 3, :right => 3, :top => 1.2, :bottom => 1.2, :header => 0.7, :footer => 0.7}
319
- wb.add_worksheet(:name => "print margins", :page_margins => margins) do |sheet|
320
- sheet.add_row["this sheet uses customized page margins for printing"]
321
- end
322
-
323
- ##Fit to page printing
324
-
325
- wb.add_worksheet(:name => "fit to page") do |sheet|
326
- sheet.add_row ['this all goes on one page']
327
- sheet.fit_to_page = true
328
- end
329
-
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.
330
112
 
331
- ##Hide Gridlines in worksheet
113
+ Here's a teaser that kicks about 2% of what the gem can do.
332
114
 
333
- wb.add_worksheet(:name => "No Gridlines") do |sheet|
334
- sheet.add_row ["This", "Sheet", "Hides", "Gridlines"]
335
- sheet.show_gridlines = false
115
+ ```ruby
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']
336
122
  end
123
+ end
124
+ p.serialize('simple.xlsx')
125
+ end
126
+ ```
337
127
 
338
- ##Validate and Serialize
128
+ Please see the [examples](https://github.com/randym/axlsx/tree/master/examples/example.rb) for more.
339
129
 
340
- p.validate.each { |e| puts e.message }
341
- p.serialize("example.xlsx")
342
-
343
- # alternatively, serialize to StringIO
344
- s = p.to_stream()
345
- File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
346
-
347
- ##Using Shared Strings
348
-
349
- p.use_shared_strings = true
350
- p.serialize("shared_strings_example.xlsx")
351
-
352
- ##Disabling Autowidth
353
-
354
- p = Axlsx::Package.new
355
- p.use_autowidth = false
356
- wb = p.workbook
357
- wb.add_worksheet(:name => "No Magick") do | sheet |
358
- sheet.add_row ['oh look! no autowidth - and no magick loaded in your process']
359
- end
360
- p.validate.each { |e| puts e.message }
361
- p.serialize("no-use_autowidth.xlsx")
130
+ {include:file:examples/example.rb}
362
131
 
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.
363
133
 
364
134
  #Documentation
365
135
  --------------
366
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:
367
137
 
368
- gem install yard
369
- yard server -g
138
+ gem install yard
139
+
140
+ yard server -g
370
141
 
371
142
  #Specs
372
143
  ------
@@ -374,43 +145,63 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
374
145
 
375
146
  #Change log
376
147
  ---------
377
- - ** April.3.12**: 1.1.0 release
378
- - bugfix patch name_to_indecies to properly handle extended ranges.
379
- - bugfix properly serialize chart title.
380
- - lower rake minimum requirement for 1.8.7 apps that don't want to move on to 0.9 NOTE this will be reverted for 2.0.0 with workbook parsing!
381
- - Added Fit to Page printing
382
- - added support for turning off gridlines in charts.
383
- - added support for turning off gridlines in worksheet.
384
- - bugfix some apps like libraoffice require apply[x] attributes to be true. applyAlignment is now properly set.
385
- - added option use_autowidth. When this is false RMagick will not be loaded or used in the stack. However it is still a requirement in the gem.
386
- - added border style specification to styles#add_style. See the example in the readme.
387
- - Support for tables added in - Note: Pre 2011 versions of Mac office do not support this feature and will warn.
388
- - Support for splatter charts added
389
- - Major (like 7x faster!) performance updates.
390
- - Gem now supports for JRuby 1.6.7, as well as expirimental support for Rubinius
391
-
392
- - ** March.5.12**: 1.0.18 release
393
- https://github.com/randym/axlsx/compare/1.0.17...1.0.18
394
- - bugfix custom borders are not properly applied when using styles.add_style
395
- - interop worksheet names must be 31 characters or less or some versions of office complain about repairs
396
- - added type support for :boolean and :date types cell values
397
- - added support for fixed column widths
398
- - added support for page_margins
399
- - added << alias for add_row
400
- - removed presetting of date1904 based on authoring platform. Now defaults to use 1900 epoch (date1904 = false)
401
-
402
- - ** February.14.12**: 1.0.17 release
403
- https://github.com/randym/axlsx/compare/1.0.16...1.0.17
404
- - Added in support for serializing to StringIO
405
- - Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers
406
- - Added in support for fixed column_widths
407
- - Removed unneeded dependencies on active-support and i18n
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
408
175
 
176
+ Please see the {file:CHANGELOG.md} document for past release information.
409
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
410
198
 
411
- Please see the {file:CHANGELOG.md} document for past release information.
412
199
 
413
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
+
414
205
  --------
415
206
  [ochko](https://github.com/ochko) - for performance fixes, kicking the crap out of axlsx and helping to maintain my general sanity.
416
207
 
@@ -428,8 +219,18 @@ Please see the {file:CHANGELOG.md} document for past release information.
428
219
 
429
220
  [joekain](https://github.com/joekain) - for keeping our references working even in the double digits!
430
221
 
222
+ [moskrin](https://github.com/moskrin) - for keeping border creation on the edge.
223
+
224
+ [scpike](https://github.com/scpike) - for keeping numbers fixed even when they are rational and a super clean implementation of conditional formatting.
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
+
431
232
  #Copyright and License
432
233
  ----------
433
234
 
434
235
  Axlsx &copy; 2011-2012 by [Randy Morgan](mailto:digial.ipseity@gmail.com). Axlsx is
435
- licensed under the MIT license. Please see the {file:LICENSE} document for more information.
236
+ licensed under the MIT license. Please see the LICENSE document for more information.