axlsx 1.2.0 → 2.0.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 (208) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +3 -2
  3. data/.yardopts_guide +19 -0
  4. data/CHANGELOG.md +64 -1
  5. data/README.md +105 -87
  6. data/Rakefile +0 -5
  7. data/examples/2010_comments.rb +17 -0
  8. data/examples/anchor_swapping.rb +28 -0
  9. data/examples/auto_filter.rb +16 -0
  10. data/examples/basic_charts.rb +4 -0
  11. data/examples/colored_links.rb +59 -0
  12. data/examples/conditional_formatting/example_conditional_formatting.rb +4 -2
  13. data/examples/example.rb +569 -258
  14. data/examples/ios_preview.rb +14 -0
  15. data/examples/page_setup.rb +11 -0
  16. data/examples/pivot_table.rb +39 -0
  17. data/examples/skydrive/real_example.rb +8 -8
  18. data/examples/styles.rb +66 -0
  19. data/examples/underline.rb +13 -0
  20. data/examples/wrap_text.rb +21 -0
  21. data/lib/axlsx/content_type/abstract_content_type.rb +32 -0
  22. data/lib/axlsx/content_type/content_type.rb +1 -1
  23. data/lib/axlsx/content_type/default.rb +6 -37
  24. data/lib/axlsx/content_type/override.rb +6 -38
  25. data/lib/axlsx/doc_props/app.rb +10 -7
  26. data/lib/axlsx/doc_props/core.rb +6 -1
  27. data/lib/axlsx/drawing/axes.rb +61 -0
  28. data/lib/axlsx/drawing/axis.rb +20 -17
  29. data/lib/axlsx/drawing/bar_3D_chart.rb +31 -22
  30. data/lib/axlsx/drawing/cat_axis.rb +2 -10
  31. data/lib/axlsx/drawing/chart.rb +33 -6
  32. data/lib/axlsx/drawing/d_lbls.rb +21 -31
  33. data/lib/axlsx/drawing/drawing.rb +11 -17
  34. data/lib/axlsx/drawing/graphic_frame.rb +3 -3
  35. data/lib/axlsx/drawing/hyperlink.rb +42 -36
  36. data/lib/axlsx/drawing/line_3D_chart.rb +28 -70
  37. data/lib/axlsx/drawing/line_chart.rb +99 -0
  38. data/lib/axlsx/drawing/line_series.rb +20 -2
  39. data/lib/axlsx/drawing/marker.rb +38 -18
  40. data/lib/axlsx/drawing/num_data.rb +6 -6
  41. data/lib/axlsx/drawing/num_data_source.rb +17 -16
  42. data/lib/axlsx/drawing/one_cell_anchor.rb +28 -21
  43. data/lib/axlsx/drawing/pic.rb +43 -45
  44. data/lib/axlsx/drawing/picture_locking.rb +12 -44
  45. data/lib/axlsx/drawing/pie_3D_chart.rb +2 -1
  46. data/lib/axlsx/drawing/scaling.rb +13 -13
  47. data/lib/axlsx/drawing/scatter_chart.rb +32 -21
  48. data/lib/axlsx/drawing/ser_axis.rb +15 -16
  49. data/lib/axlsx/drawing/series.rb +3 -6
  50. data/lib/axlsx/drawing/str_data.rb +3 -3
  51. data/lib/axlsx/drawing/str_val.rb +7 -8
  52. data/lib/axlsx/drawing/two_cell_anchor.rb +7 -27
  53. data/lib/axlsx/drawing/val_axis.rb +14 -13
  54. data/lib/axlsx/drawing/view_3D.rb +52 -38
  55. data/lib/axlsx/drawing/vml_shape.rb +20 -79
  56. data/lib/axlsx/package.rb +58 -28
  57. data/lib/axlsx/rels/relationship.rb +75 -9
  58. data/lib/axlsx/rels/relationships.rb +8 -1
  59. data/lib/axlsx/stylesheet/border.rb +29 -20
  60. data/lib/axlsx/stylesheet/border_pr.rb +5 -4
  61. data/lib/axlsx/stylesheet/cell_alignment.rb +55 -29
  62. data/lib/axlsx/stylesheet/cell_protection.rb +7 -4
  63. data/lib/axlsx/stylesheet/cell_style.rb +19 -14
  64. data/lib/axlsx/stylesheet/color.rb +20 -17
  65. data/lib/axlsx/stylesheet/dxf.rb +4 -4
  66. data/lib/axlsx/stylesheet/font.rb +22 -22
  67. data/lib/axlsx/stylesheet/gradient_fill.rb +45 -21
  68. data/lib/axlsx/stylesheet/num_fmt.rb +23 -14
  69. data/lib/axlsx/stylesheet/pattern_fill.rb +12 -21
  70. data/lib/axlsx/stylesheet/styles.rb +37 -22
  71. data/lib/axlsx/stylesheet/table_style.rb +17 -16
  72. data/lib/axlsx/stylesheet/table_style_element.rb +15 -11
  73. data/lib/axlsx/stylesheet/table_styles.rb +14 -11
  74. data/lib/axlsx/stylesheet/xf.rb +28 -26
  75. data/lib/axlsx/util/accessors.rb +64 -0
  76. data/lib/axlsx/util/constants.rb +127 -6
  77. data/lib/axlsx/util/options_parser.rb +15 -0
  78. data/lib/axlsx/util/serialized_attributes.rb +79 -0
  79. data/lib/axlsx/util/simple_typed_list.rb +50 -15
  80. data/lib/axlsx/util/validators.rb +51 -16
  81. data/lib/axlsx/version.rb +2 -2
  82. data/lib/axlsx/workbook/defined_name.rb +14 -59
  83. data/lib/axlsx/workbook/shared_strings_table.rb +13 -4
  84. data/lib/axlsx/workbook/workbook.rb +85 -6
  85. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
  86. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +94 -0
  87. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +246 -0
  88. data/lib/axlsx/workbook/worksheet/break.rb +37 -0
  89. data/lib/axlsx/workbook/worksheet/cell.rb +109 -107
  90. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +144 -0
  91. data/lib/axlsx/workbook/worksheet/cfvo.rb +15 -15
  92. data/lib/axlsx/workbook/worksheet/cfvos.rb +15 -0
  93. data/lib/axlsx/workbook/worksheet/col.rb +43 -29
  94. data/lib/axlsx/workbook/worksheet/col_breaks.rb +35 -0
  95. data/lib/axlsx/workbook/worksheet/color_scale.rb +62 -28
  96. data/lib/axlsx/workbook/worksheet/comment.rb +28 -37
  97. data/lib/axlsx/workbook/worksheet/comments.rb +3 -3
  98. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +11 -11
  99. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +31 -27
  100. data/lib/axlsx/workbook/worksheet/data_bar.rb +75 -41
  101. data/lib/axlsx/workbook/worksheet/data_validation.rb +61 -62
  102. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +6 -5
  103. data/lib/axlsx/workbook/worksheet/dimension.rb +0 -1
  104. data/lib/axlsx/workbook/worksheet/header_footer.rb +54 -0
  105. data/lib/axlsx/workbook/worksheet/icon_set.rb +20 -20
  106. data/lib/axlsx/workbook/worksheet/page_margins.rb +21 -19
  107. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +44 -0
  108. data/lib/axlsx/workbook/worksheet/page_setup.rb +152 -23
  109. data/lib/axlsx/workbook/worksheet/pane.rb +48 -51
  110. data/lib/axlsx/workbook/worksheet/pivot_table.rb +273 -0
  111. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +66 -0
  112. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +24 -0
  113. data/lib/axlsx/workbook/worksheet/print_options.rb +8 -30
  114. data/lib/axlsx/workbook/worksheet/protected_range.rb +16 -13
  115. data/lib/axlsx/workbook/worksheet/row.rb +59 -83
  116. data/lib/axlsx/workbook/worksheet/row_breaks.rb +33 -0
  117. data/lib/axlsx/workbook/worksheet/selection.rb +30 -38
  118. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +29 -0
  119. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +60 -0
  120. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +49 -4
  121. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +51 -155
  122. data/lib/axlsx/workbook/worksheet/sheet_view.rb +68 -234
  123. data/lib/axlsx/workbook/worksheet/table.rb +25 -19
  124. data/lib/axlsx/workbook/worksheet/table_style_info.rb +51 -0
  125. data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
  126. data/lib/axlsx/workbook/worksheet/worksheet.rb +174 -35
  127. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -5
  128. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +4 -10
  129. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +74 -0
  130. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
  131. data/lib/axlsx.rb +55 -5
  132. data/lib/schema/sml.xsd +4 -0
  133. data/test/axlsx.qcachegrind +2226 -0
  134. data/test/benchmark.rb +2 -3
  135. data/test/content_type/tc_default.rb +0 -11
  136. data/test/content_type/tc_override.rb +0 -13
  137. data/test/doc_props/tc_core.rb +7 -0
  138. data/test/drawing/tc_axes.rb +8 -0
  139. data/test/drawing/tc_axis.rb +15 -17
  140. data/test/drawing/tc_bar_3D_chart.rb +6 -0
  141. data/test/drawing/tc_cat_axis.rb +9 -9
  142. data/test/drawing/tc_chart.rb +20 -0
  143. data/test/drawing/tc_d_lbls.rb +14 -4
  144. data/test/drawing/tc_drawing.rb +0 -5
  145. data/test/drawing/tc_graphic_frame.rb +5 -3
  146. data/test/drawing/tc_hyperlink.rb +0 -4
  147. data/test/drawing/tc_line_chart.rb +39 -0
  148. data/test/drawing/tc_line_series.rb +8 -2
  149. data/test/drawing/tc_pic.rb +14 -3
  150. data/test/drawing/tc_ser_axis.rb +13 -12
  151. data/test/drawing/tc_two_cell_anchor.rb +3 -3
  152. data/test/drawing/tc_val_axis.rb +6 -6
  153. data/test/drawing/tc_vml_shape.rb +9 -3
  154. data/test/profile.rb +11 -21
  155. data/test/rels/tc_relationship.rb +32 -9
  156. data/test/rels/tc_relationships.rb +12 -1
  157. data/test/stylesheet/tc_color.rb +6 -0
  158. data/test/stylesheet/tc_styles.rb +15 -2
  159. data/test/tc_axlsx.rb +35 -2
  160. data/test/tc_helper.rb +7 -1
  161. data/test/tc_package.rb +44 -5
  162. data/test/util/tc_serialized_attributes.rb +19 -0
  163. data/test/util/tc_validators.rb +26 -1
  164. data/test/workbook/tc_defined_name.rb +2 -2
  165. data/test/workbook/tc_shared_strings_table.rb +6 -0
  166. data/test/workbook/tc_workbook.rb +38 -1
  167. data/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +38 -0
  168. data/test/workbook/worksheet/auto_filter/tc_filter_column.rb +76 -0
  169. data/test/workbook/worksheet/auto_filter/tc_filters.rb +50 -0
  170. data/test/workbook/worksheet/tc_break.rb +49 -0
  171. data/test/workbook/worksheet/tc_cell.rb +40 -6
  172. data/test/workbook/worksheet/tc_col.rb +11 -1
  173. data/test/workbook/worksheet/tc_color_scale.rb +31 -2
  174. data/test/workbook/worksheet/tc_comment.rb +21 -6
  175. data/test/workbook/worksheet/tc_comments.rb +2 -2
  176. data/test/workbook/worksheet/tc_conditional_formatting.rb +7 -0
  177. data/test/workbook/worksheet/tc_data_bar.rb +7 -0
  178. data/test/workbook/worksheet/tc_date_time_converter.rb +3 -11
  179. data/test/workbook/worksheet/tc_header_footer.rb +151 -0
  180. data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
  181. data/test/workbook/worksheet/tc_page_setup.rb +6 -1
  182. data/test/workbook/worksheet/tc_pane.rb +5 -45
  183. data/test/workbook/worksheet/tc_pivot_table.rb +120 -0
  184. data/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +54 -0
  185. data/test/workbook/worksheet/tc_row.rb +4 -4
  186. data/test/workbook/worksheet/tc_selection.rb +9 -48
  187. data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
  188. data/test/workbook/worksheet/tc_sheet_format_pr.rb +88 -0
  189. data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
  190. data/test/workbook/worksheet/tc_sheet_view.rb +39 -39
  191. data/test/workbook/worksheet/{table/tc_table.rb → tc_table.rb} +8 -3
  192. data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
  193. data/test/workbook/worksheet/tc_worksheet.rb +131 -16
  194. data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +55 -0
  195. metadata +97 -64
  196. data/examples/example.xlsx +0 -0
  197. data/examples/example_streamed.xlsx +0 -0
  198. data/examples/extractive.pdf +0 -0
  199. data/examples/image1.gif +0 -0
  200. data/examples/image1.jpg +0 -0
  201. data/examples/image1.png +0 -0
  202. data/examples/no-use_autowidth.xlsx +0 -0
  203. data/examples/sample.png +0 -0
  204. data/examples/scraping_html.rb +0 -91
  205. data/examples/shared_strings_example.xlsx +0 -0
  206. data/examples/sheet_view.rb +0 -34
  207. data/examples/two_cell_anchor_image.rb +0 -11
  208. data/lib/axlsx/workbook/worksheet/auto_filter.rb +0 -34
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e930f37405c7605025d570348ef553438e86a17e
4
+ data.tar.gz: 1b5a4d4eca67a123d7a9f6b83e78e686efd25cf7
5
+ SHA512:
6
+ metadata.gz: 5c28721794fe4270cdbe656a1eae69dcf47026cc16140772ce222cf82647369b4d9316ec012fc63bf118448590f251330092f6a11807d0a6462e398147d5cebe
7
+ data.tar.gz: f2d55d91d8513f33d530a307a5bb48e30a12368670ebed8ba132daffea2789912fe7e72112e5b6311a32af1dcdafdc7c23e6908ca23efb958ea67cca97125df9
data/.yardopts CHANGED
@@ -4,5 +4,6 @@
4
4
  --readme README.md
5
5
  --markup markdown
6
6
  --markup-provider kramdown
7
- --files CHANGELOG.md, LICENSE
8
- --list-undoc
7
+ -
8
+ CHANGELOG.md
9
+ LICENSE
data/.yardopts_guide ADDED
@@ -0,0 +1,19 @@
1
+ -t guide
2
+ --title YARD
3
+ -o doc_guide
4
+ --exclude /server/templates/
5
+ --exclude /yard/rubygems/
6
+ --asset docs/images:images
7
+ -
8
+ docs/WhatsNew.md
9
+ docs/GettingStarted.md
10
+ docs/Overview.md
11
+ docs/CodeObjects.md
12
+ docs/Tags.md
13
+ docs/Parser.md
14
+ docs/Handlers.md
15
+ docs/Templates.md
16
+ docs/Glossary.md
17
+ ChangeLog
18
+ LICENSE
19
+ LEGAL
data/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **November.25.12**:1.3.4
4
+ - Support for headers and footers for worksheets
5
+ - bug fix: Properly escape hyperlink urls
6
+ - Improvements in color_scale generation for conditional formatting
7
+ - Improvements in autowidth calculation.
8
+ - **November.8.12**:1.3.3
9
+ - Patched cell run styles for u and validation for family
10
+
11
+ - **November.5.12**:1.3.2
12
+ - MASSIVE REFACTORING
13
+ - Patch for apostrophes in worksheet names
14
+ - added sheet_by_name for workbook so you can now find your worksheets
15
+ by name
16
+ - added insert_worksheet so you can now add a worksheet to an
17
+ arbitrary position in the worksheets list.
18
+ - reduced memory consumption for package parts post serialization
19
+ - **September.30.12**: 1.3.1
20
+ - Improved control character handling
21
+ - Added stored auto filter values and date grouping items
22
+ - Improved support for autowidth when custom styles are applied
23
+ - Added support for table style info that lets you take advantage of
24
+ all the predefined table styles.
25
+ - Improved style management for fonts so they merge undefined values
26
+ from the initial master.
27
+ - **September.8.12**: 1.2.3
28
+ - enhance exponential float/bigdecimal values rendering as strings intead
29
+ of 'numbers' in excel.
30
+ - added support for :none option on chart axis labels
31
+ - added support for paper_size option on worksheet.page_setup
32
+ - **August.27.12**: 1.2.2
33
+ - minor patch for auto-filters
34
+ - minor documentation improvements.
35
+ - **August.12.12**: 1.2.1
36
+ - Add support for hyperlinks in worksheets
37
+ - Fix example that was using old style cell merging with concact.
38
+ - Fix bug that occurs when calculating the font_size for cells that use a user specified style which does not define sz
39
+ - **August.5.12**: 1.2.0
40
+ - rebuilt worksheet serialization to clean up the code base a bit.
41
+ - added data labels for charts
42
+ - added table header printing for each sheet via defined_name. This
43
+ means that when you print your worksheet, the header rows show for every page
44
+ - **July.??.12**: 1.1.9 release
45
+ - lots of code clean up for worksheet
46
+ - added in data labels for pie charts, line charts and bar charts.
47
+ - bugfix chard with data in a sheet that has a space in the name are
48
+ now auto updating formula based values
49
+ - **July.14.12**: 1.1.8 release
50
+ - added html entity encoding for sheet names. This allows you to use
51
+ characters like '<' and '&' in your sheet names.
52
+ - new - first round google docs interoperability
53
+ - added filter to strip out control characters from cell data.
54
+ - added in interop requirements so that charts are properly exported
55
+ to PDF from Libra Office
56
+ - various readability improvements and work standardizing attribute
57
+ names to snake_case. Aliases are provided for backward compatiblity
58
+ - **June.11.12**: 1.1.7 release
59
+ - fix chart rendering issue when label offset is specified as a
60
+ percentage in serialization and ensure that formula are not stored
61
+ in value caches
62
+ - fix bug that causes repair warnings when using a text only title reference.
63
+ - Add title property to axis so you can lable the x/y/series axis for
64
+ charts.
65
+ - Add sheet views with panes
3
66
  - **May.30.12**: 1.1.6 release
4
67
  - data protection with passwords for sheets
5
68
  - cell level input validators
@@ -10,7 +73,6 @@ CHANGELOG
10
73
  - added ph (phonetics) and s (style) attributes for row.
11
74
  - resolved all warnings generating from this gem.
12
75
  - improved comment relationship management for multiple comments
13
-
14
76
  - **May.13.12**: 1.1.5 release
15
77
  - MOAR print options! You can now specify paper size, orientation,
16
78
  fit to width, page margings and gridlines for printing.
@@ -174,3 +236,4 @@ CHANGELOG
174
236
  - Updated documentation
175
237
 
176
238
  ##October.20.11: 0.1.0 release
239
+
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Axlsx: Office Open XML Spreadsheet Generation
2
2
  ====================================
3
- [![Build Status](https://secure.travis-ci.org/randym/axlsx.png)](http://travis-ci.org/randym/axlsx/)
3
+ [![Build Status](https://secure.travis-ci.org/randym/axlsx.png?branch=master)](http://travis-ci.org/randym/axlsx/)
4
+
5
+ If you are using axlsx for comercial purposes, or just want to show your
6
+ appreciation for the gem, please don't hesitate to make a donation.
7
+
4
8
  [![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)
5
9
 
6
10
  **IRC**:[irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
@@ -11,29 +15,30 @@ Axlsx: Office Open XML Spreadsheet Generation
11
15
 
12
16
  **Google Group**: [https://groups.google.com/forum/?fromgroups#!forum/axlsx](https://groups.google.com/forum/?fromgroups#!forum/axlsx)
13
17
 
14
- **Author**: Randy Morgan
18
+ **Author**: Randy Morgan
15
19
 
16
- **Copyright**: 2011 - 2012
20
+ **Copyright**: 2011 - 2013
17
21
 
18
22
  **License**: MIT License
19
23
 
20
- **Latest Version**: 1.2.0
24
+ **Latest Version**: 2.0.0
21
25
 
22
- **Ruby Version**: 1.8.7, 1.9.2, 1.9.3
26
+ **Ruby Version**: 1.9.2, 1.9.3, 2.0.0
23
27
 
24
- **JRuby Version**: 1.6.7 1.8 and 1.9 modes
28
+ **JRuby Version**: 1.9 modes
25
29
 
26
30
  **Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.
27
31
 
28
- **Release Date**: August 5th 2012
32
+ **Release Date**: September 12th 2013
29
33
 
30
34
  If you are working in rails, or with active record see:
31
- * http://github.com/randym/acts_as_xlsx
35
+ [acts_as_xlsx](http://github.com/randym/acts_as_xlsx)
36
+
32
37
  acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
33
38
 
34
- ```ruby
35
- Posts.where(created_at > Time.now-30.days).to_xlsx
36
- ```
39
+ ```ruby
40
+ Posts.where(created_at > Time.now-30.days).to_xlsx
41
+ ```
37
42
 
38
43
  ** and **
39
44
 
@@ -43,6 +48,12 @@ Axlsx_Rails provides an Axlsx renderer so you can move all your spreadsheet code
43
48
  There are guides for using axlsx and acts_as_xlsx here:
44
49
  [http://axlsx.blog.randym.net](http://axlsx.blog.randym.net)
45
50
 
51
+ If you are working with ActiveAdmin see:
52
+
53
+ [activeadmin_axlsx](http://github.com/randym/activeadmin_axlsx)
54
+
55
+ It provies a plugin and dsl for generating downloadable reports.
56
+
46
57
  The examples directory contains a number of more specific examples as
47
58
  well.
48
59
 
@@ -59,43 +70,49 @@ With Axlsx you can create excel worksheets with charts, images (with links), aut
59
70
  Feature List
60
71
  ------------
61
72
 
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.
73
+ 1. Author xlsx documents: Axlsx is made to let you easily and quickly generate professional xlsx based reports that can be validated before serialization.
63
74
 
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.
75
+ 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.
65
76
 
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.
77
+ 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.
67
78
 
68
- **4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String, Date, Time and Boolean types are automatically identified and serialized to your spreadsheet.
79
+ 4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String, Date, Time and Boolean types are automatically identified and serialized to your spreadsheet.
69
80
 
70
- **5. Automatic and fixed column widths: Axlsx will automatically determine the appropriate width for your columns based on the content in the worksheet, or use any value you specify for the really funky stuff.
81
+ 5. Automatic and fixed column widths: Axlsx will automatically determine the appropriate width for your columns based on the content in the worksheet, or use any value you specify for the really funky stuff.
71
82
 
72
- **6. Support for automatically formatted 1904 and 1900 epochs configurable in the workbook.
83
+ 6. Support for automatically formatted 1904 and 1900 epochs configurable in the workbook.
73
84
 
74
- **7. Add jpg, gif and png images to worksheets with hyperlinks
85
+ 7. Add jpg, gif and png images to worksheets with hyperlinks
75
86
 
76
- **8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheet1!A3:B4" style references
87
+ 8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheet1!A3:B4" style references
77
88
 
78
- **9. Cell level style overrides for default and customized style objects
89
+ 9. Cell level style overrides for default and customized style objects
79
90
 
80
- **10. Support for formulas, merging, row and column outlining as well as
91
+ 10. Support for formulas, merging, row and column outlining as well as
81
92
  cell level input data validation.
82
93
 
83
- **12. Auto filtering tables with worksheet.auto_filter as well as support for Tables
94
+ 12. Auto filtering tables with worksheet.auto_filter as well as support for Tables
84
95
 
85
- **13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
96
+ 13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
86
97
 
87
- **14. Output to file or StringIO
98
+ 14. Output to file or StringIO
88
99
 
89
- **15. Support for page margins and print options
100
+ 15. Support for page margins and print options
90
101
 
91
- **16. Support for password and non password based sheet protection.
102
+ 16. Support for password and non password based sheet protection.
92
103
 
93
- **17. First stage interoperability support for GoogleDocs, LibreOffice,
104
+ 17. First stage interoperability support for GoogleDocs, LibreOffice,
94
105
  and Numbers
95
106
 
96
- **18. Support for defined names, which gives you repeated header rows for printing.
107
+ 18. Support for defined names, which gives you repeated header rows for printing.
108
+
109
+ 19. Data labels for charts as well as series color customization.
97
110
 
98
- **19. Data labels for charts as well as series color customization.
111
+ 20. Support for sheet headers and footers
112
+
113
+ 21. Pivot Tables
114
+
115
+ 22. Page Breaks
99
116
 
100
117
  Installing
101
118
  ----------
@@ -133,6 +150,7 @@ There is much, much more you can do with this gem. If you get stuck, grab me on
133
150
 
134
151
  #Documentation
135
152
  --------------
153
+
136
154
  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:
137
155
 
138
156
  gem install yard
@@ -141,37 +159,49 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
141
159
 
142
160
  #Specs
143
161
  ------
162
+
144
163
  This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
145
164
 
146
165
  #Change log
147
166
  ---------
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
167
+
168
+ - **September.12.13**:2.0.0
169
+ - DROPPED support for ruby 1.8.7
170
+ - Altered readme to link to contributors
171
+ - Lots of improvements to make charts and relations more stable.
172
+ - Patched color param mutation.
173
+ - Data sourced for pivot tables can now come from other sheets.
174
+ - Altered image file extension comparisons to be case insensitive.
175
+ - Added control character sanitization to shared strings.
176
+ - Added page breaks. see examples/example.rb for an example.
177
+ - Bugfix: single to dual cell anchors for images now swap properly so you can set the end_at position during instantiation, in a block or directly on the image.
178
+ - Improved how we convert date/time to include the UTC offset when provided.
179
+ - Pinned rubyzip to 0.9.9 for those who are not ready to go up. Please note that release 2.0.1 and on will be using the 1.n.n series of rubyzip
180
+ - Bugfix: transposition of cells for Worksheet#cols now supports
181
+ incongruent column counts.counts
182
+ - Added space preservation for cell text. This will allow whitespace
183
+ in cell text both when using shared strings and when serializing
184
+ directly to the cell.
185
+ - **April.24.13**:1.3.6
186
+ - Fixed LibreOffice/OpenOffice issue to properly apply colors to lines
187
+ in charts.
188
+ - Added support for specifying between/notBetween formula in an array.
189
+ *thanks* straydogstudio!
190
+ - Added standard line chart support. *thanks* scambra
191
+ - Fixed straydogstudio's link in the README. *thanks* nogara!
192
+ - **February.4.13**:1.3.5
193
+ - converted vary_colors for chart data to instance variable with appropriate defulats for the various charts.
194
+ - Added trust_input method on Axlsx to instruct the serializer to skip HTML escaping. This will give you a tremendous performance boost,
195
+ Please be sure that you will never have <, >, etc in your content or the XML will be invalid.
196
+ - Rewrote cell serialization to improve performance
197
+ - Added iso_8601 type to support text based date and time management.
198
+ - Bug fix for relationahip management in drawings when you add images
199
+ and charts to the same worksheet drawing.
200
+ - Added outline_level_rows and outline_level_columns to worksheet to simplify setting up outlining in the worksheet.
201
+ - Added support for pivot tables
202
+ - Added support for descrete border edge styles
203
+ - Improved validation of sheet names
204
+ - Added support for formula value caching so that iOS and OSX preview can show the proper values. See Cell.add_row and the formula_values option.
175
205
 
176
206
  Please see the {file:CHANGELOG.md} document for past release information.
177
207
 
@@ -180,7 +210,7 @@ As axslx implements the Office Open XML (ECMA-376 spec) much of the
180
210
  functionality is interoperable with other spreadsheet software. Below is
181
211
  a listing of some known issues.
182
212
 
183
- 1. Libra Office
213
+ 1. Libre Office
184
214
  - You must specify colors for your series. see examples/chart_colors.rb
185
215
  for an example.
186
216
  - You must use data in your sheet for charts. You cannot use hard coded
@@ -193,44 +223,32 @@ related to themes, which axlsx does not implement at this time.
193
223
  - border colors do not work
194
224
 
195
225
  3. Numbers
196
- - you must set 'use_shared_strings' to true
226
+ - you must set 'use_shared_strings' to true. This is most
227
+ conveniently done just before rendering by calling Package.use_shared_strings = true prior to serialization.
228
+
229
+ ```ruby
230
+ p = Axlsx::Package.new
231
+ p.workbook.add_worksheet(:name => "Basic Worksheet") do |sheet|
232
+ sheet.add_row ["First Column", "Second", "Third"]
233
+ sheet.add_row [1, 2, 3]
234
+ end
235
+ p.use_shared_strings = true
236
+ p.serialize('simple.xlsx')
237
+ ```
238
+
197
239
  - charts do not render
198
240
 
199
241
 
200
242
  #Thanks!
201
243
 
202
244
  Open source software is a community effort. None of this could have been
203
- done without the help of the people below.
204
-
205
- --------
206
- [ochko](https://github.com/ochko) - for performance fixes, kicking the crap out of axlsx and helping to maintain my general sanity.
207
-
208
- [kleine2](https://github.com/kleine2) - for generously donating in return for the image hyperlink feature.
209
-
210
- [ffmike](https://github.com/ffmike) - for knocking down an over restrictive i18n dependency, massive patience and great communication skills.
211
-
212
- [JonathanTron](https://github.com/JonathanTron) - for giving the gem some style, and making sure it applies.
213
-
214
- [JosephHalter](https://github.com/JosephHalter) - for making sure we arrive at the right time on the right date.
245
+ done without the help of these awesome folks.
215
246
 
216
- [noniq](https://github.com/noniq) - for keeping true to the gem's style, and making sure what we put on paper does not get marginalized.
217
-
218
- [jurriaan](https://github.com/jurriaan) - for showing there is more than one way to skin a cat, and work with rows while you are at it.
219
-
220
- [joekain](https://github.com/joekain) - for keeping our references working even in the double digits!
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.
247
+ [contributors](https://github.com/randym/axlsx/graphs/contributors)
231
248
 
232
249
  #Copyright and License
233
250
  ----------
234
251
 
235
- Axlsx &copy; 2011-2012 by [Randy Morgan](mailto:digial.ipseity@gmail.com). Axlsx is
236
- licensed under the MIT license. Please see the LICENSE document for more information.
252
+ Axlsx &copy; 2011-2013 by [Randy Morgan](mailto:digial.ipseity@gmail.com).
253
+
254
+ Axlsx is licensed under the MIT license. Please see the LICENSE document for more information.
data/Rakefile CHANGED
@@ -24,11 +24,6 @@ task :test do
24
24
  end
25
25
  end
26
26
 
27
- task :report do
28
- require 'cover_me'
29
- CoverMe.complete!
30
- end
31
-
32
27
  task :release => :build do
33
28
  system "gem push axlsx-#{Axlsx::VERSION}.gem"
34
29
  end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby -w -s
2
+ # -*- coding: utf-8 -*-
3
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
+
5
+ #```ruby
6
+ require 'axlsx'
7
+ p = Axlsx::Package.new
8
+ p.workbook.add_worksheet(:name => 'Excel 2010 comments') do |sheet|
9
+ sheet.add_row ['Cell with visible comment']
10
+ sheet.add_row
11
+ sheet.add_row
12
+ sheet.add_row ['Cell with hidden comment']
13
+
14
+ sheet.add_comment :ref => 'A1', :author => 'XXX', :text => 'Visibile'
15
+ sheet.add_comment :ref => 'A4', :author => 'XXX', :text => 'Hidden', :visible => false
16
+ end
17
+ p.serialize('excel_2010_comment_test.xlsx')
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
+ require 'axlsx'
3
+ xls = Axlsx::Package.new
4
+ wb = xls.workbook
5
+ wb.add_worksheet do |ws|
6
+ img = File.expand_path('../image1.jpeg', __FILE__)
7
+ ws.add_image(:image_src => img) do |image|
8
+ image.start_at 2, 2
9
+ image.end_at 5, 5
10
+ end
11
+ end
12
+ wb.add_worksheet do |ws|
13
+ img = File.expand_path('../image1.jpeg', __FILE__)
14
+ ws.add_image(:image_src => img, :start_at => "B2") do |image|
15
+ image.width = 70
16
+ image.height = 50
17
+ end
18
+ end
19
+ wb.add_worksheet do |ws|
20
+ img = File.expand_path('../image1.jpeg', __FILE__)
21
+ ws.add_image(:image_src => img, :start_at => [1,1]) do |image|
22
+ image.end_at "E7"
23
+ end
24
+ end
25
+
26
+
27
+
28
+ xls.serialize 'anchor.xlsx'
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby -w -s
2
+ # -*- coding: utf-8 -*-
3
+
4
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
5
+ require 'axlsx'
6
+ Axlsx::Package.new do |p|
7
+ p.workbook.add_worksheet(:name => "Table") do |sheet|
8
+ sheet.add_row ["Build Matrix"]
9
+ sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
10
+ sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
11
+ sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
12
+ sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
13
+ sheet.auto_filter = 'A2:D5'
14
+ sheet.auto_filter.add_column 3, :filters, :filter_items => ['1.9.2']
15
+ end
16
+ end.serialize('auto_filter.xlsx')
@@ -24,6 +24,8 @@ end
24
24
  chart.add_series :data => sheet["A2:D2"], :labels => sheet["A1:D1"], :title => 'bob'
25
25
  chart.d_lbls.show_val = true
26
26
  chart.d_lbls.show_cat_name = true
27
+ chart.catAxis.tick_lbl_pos = :none
28
+
27
29
  end
28
30
  end
29
31
 
@@ -38,6 +40,8 @@ end
38
40
  chart.catAxis.label_rotation = 45
39
41
  chart.d_lbls.d_lbl_pos = :outEnd
40
42
  chart.d_lbls.show_val = true
43
+
44
+ chart.catAxis.tick_lbl_pos = :none
41
45
  end
42
46
  end
43
47
 
@@ -0,0 +1,59 @@
1
+ require 'axlsx'
2
+
3
+ ###############################
4
+ # Function to output results data row to summary spreadsheet
5
+ def outputRow (sid, type)
6
+
7
+ $sumSheet.add_row [ sid, type, "1", "2", "3", "4", "5" ], :style => $black_cell
8
+
9
+ if sid.odd?
10
+ link = "A#{$curRow}"
11
+ puts "outputRow: sid: #{sid}, link: #{link}"
12
+ # Setting the style for the link will apply the xf that we created in the Main Program block
13
+ $sumSheet[link].style = $blue_link
14
+ $sumSheet.add_hyperlink :location => "'Log'!A#{$curRow}", :target => :sheet, :ref => link
15
+ end
16
+ $curRow += 1
17
+ end
18
+
19
+ ##############################
20
+ # Main Program
21
+
22
+ $package = Axlsx::Package.new
23
+ $workbook = $package.workbook
24
+ ## We want to create our sytles outside of the outputRow method
25
+ # Each style only needs to be declared once in the workbook.
26
+ $workbook.styles do |s|
27
+ $black_cell = s.add_style :sz => 10, :alignment => { :horizontal=> :center }
28
+ $blue_link = s.add_style :fg_color => '0000FF'
29
+ end
30
+
31
+
32
+ # Create summary sheet
33
+ $sumSheet = $workbook.add_worksheet(:name => 'Summary')
34
+ $sumSheet.add_row ["Test Results"], :sz => 16
35
+ $sumSheet.add_row
36
+ $sumSheet.add_row
37
+ $sumSheet.add_row ["Note: Blue cells below are links to the Log sheet"], :sz => 10
38
+ $sumSheet.add_row
39
+ $workbook.styles do |s|
40
+ black_cell = s.add_style :sz => 14, :alignment => { :horizontal=> :center }
41
+ $sumSheet.add_row ["ID","Type","Match","Mismatch","Diffs","Errors","Result"], :style => black_cell
42
+ end
43
+ $sumSheet.column_widths 10, 10, 10, 11, 10, 10, 10
44
+
45
+ # Starting data row in summary spreadsheet (after header info)
46
+ $curRow = 7
47
+
48
+ # Create Log Sheet
49
+ $logSheet = $workbook.add_worksheet(:name => 'Log')
50
+ $logSheet.column_widths 10
51
+ $logSheet.add_row ['Log Detail'], :sz => 16
52
+ $logSheet.add_row
53
+
54
+ # Add rows to summary sheet
55
+ for i in 1..10 do
56
+ outputRow(i, 'test')
57
+ end
58
+
59
+ $package.serialize 'where_is_my_color.xlsx'
@@ -11,8 +11,8 @@ percent = book.styles.add_style(:format_code => "0.00%", :border => Axlsx::STYLE
11
11
  money = book.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER)
12
12
 
13
13
  # define the style for conditional formatting
14
- profitable = book.styles.add_style( :fg_color=>"FF428751",
15
- :type => :dxf)
14
+ profitable = book.styles.add_style( :fg_color => "FF428751", :type => :dxf )
15
+ unprofitable = wb.styles.add_style( :fg_color => "FF0000", :type => :dxf )
16
16
 
17
17
  book.add_worksheet(:name => "Cell Is") do |ws|
18
18
 
@@ -27,6 +27,8 @@ book.add_worksheet(:name => "Cell Is") do |ws|
27
27
 
28
28
  # Apply conditional formatting to range B3:B100 in the worksheet
29
29
  ws.add_conditional_formatting("B3:B100", { :type => :cellIs, :operator => :greaterThan, :formula => "100000", :dxfId => profitable, :priority => 1 })
30
+ # Apply conditional using the between operator; NOTE: supply an array to :formula for between/notBetween
31
+ sheet.add_conditional_formatting("C3:C100", { :type => :cellIs, :operator => :between, :formula => ["0.00%","100.00%"], :dxfId => unprofitable, :priority => 1 })
30
32
  end
31
33
 
32
34
  book.add_worksheet(:name => "Color Scale") do |ws|