axlsx 1.3.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts_guide +19 -0
- data/CHANGELOG.md +8 -0
- data/README.md +52 -79
- data/Rakefile +0 -5
- data/examples/2010_comments.rb +17 -0
- data/examples/anchor_swapping.rb +28 -0
- data/examples/example.rb +16 -1
- data/examples/pivot_table.rb +2 -0
- data/examples/underline.rb +13 -0
- data/lib/axlsx.rb +8 -0
- data/lib/axlsx/doc_props/core.rb +6 -1
- data/lib/axlsx/drawing/axes.rb +7 -3
- data/lib/axlsx/drawing/bar_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/chart.rb +20 -4
- data/lib/axlsx/drawing/drawing.rb +2 -17
- data/lib/axlsx/drawing/graphic_frame.rb +3 -8
- data/lib/axlsx/drawing/hyperlink.rb +5 -12
- data/lib/axlsx/drawing/marker.rb +25 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +9 -0
- data/lib/axlsx/drawing/pic.rb +17 -23
- data/lib/axlsx/drawing/two_cell_anchor.rb +7 -27
- data/lib/axlsx/package.rb +31 -11
- data/lib/axlsx/rels/relationship.rb +73 -8
- data/lib/axlsx/rels/relationships.rb +8 -1
- data/lib/axlsx/stylesheet/color.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +2 -2
- data/lib/axlsx/stylesheet/styles.rb +5 -3
- data/lib/axlsx/util/serialized_attributes.rb +11 -8
- data/lib/axlsx/util/simple_typed_list.rb +34 -13
- data/lib/axlsx/util/validators.rb +7 -0
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +12 -3
- data/lib/axlsx/workbook/workbook.rb +31 -8
- data/lib/axlsx/workbook/worksheet/break.rb +37 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +5 -5
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +35 -0
- data/lib/axlsx/workbook/worksheet/comment.rb +6 -5
- data/lib/axlsx/workbook/worksheet/comments.rb +3 -3
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +6 -5
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +32 -18
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -3
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/row.rb +1 -1
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +33 -0
- data/lib/axlsx/workbook/worksheet/table.rb +3 -2
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +61 -26
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -5
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +3 -9
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +5 -10
- data/lib/schema/sml.xsd +4 -0
- data/test/axlsx.qcachegrind +2226 -0
- data/test/doc_props/tc_core.rb +7 -0
- data/test/drawing/tc_axes.rb +8 -0
- data/test/drawing/tc_bar_3D_chart.rb +6 -0
- data/test/drawing/tc_chart.rb +13 -0
- data/test/drawing/tc_drawing.rb +0 -5
- data/test/drawing/tc_graphic_frame.rb +4 -7
- data/test/drawing/tc_hyperlink.rb +0 -4
- data/test/drawing/tc_pic.rb +14 -3
- data/test/drawing/tc_two_cell_anchor.rb +3 -3
- data/test/profile.rb +7 -3
- data/test/rels/tc_relationship.rb +29 -11
- data/test/rels/tc_relationships.rb +12 -1
- data/test/stylesheet/tc_color.rb +6 -0
- data/test/stylesheet/tc_styles.rb +2 -2
- data/test/tc_helper.rb +1 -0
- data/test/tc_package.rb +30 -0
- data/test/util/tc_serialized_attributes.rb +19 -0
- data/test/workbook/tc_shared_strings_table.rb +6 -0
- data/test/workbook/tc_workbook.rb +23 -1
- data/test/workbook/worksheet/tc_break.rb +49 -0
- data/test/workbook/worksheet/tc_comment.rb +17 -6
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_date_time_converter.rb +3 -11
- data/test/workbook/worksheet/tc_pivot_table.rb +40 -22
- data/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +9 -1
- data/test/workbook/worksheet/tc_sheet_view.rb +39 -39
- data/test/workbook/worksheet/tc_table.rb +2 -2
- data/test/workbook/worksheet/tc_worksheet.rb +39 -7
- data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +2 -11
- metadata +37 -10
- data/test/example.xlsx +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e930f37405c7605025d570348ef553438e86a17e
|
4
|
+
data.tar.gz: 1b5a4d4eca67a123d7a9f6b83e78e686efd25cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c28721794fe4270cdbe656a1eae69dcf47026cc16140772ce222cf82647369b4d9316ec012fc63bf118448590f251330092f6a11807d0a6462e398147d5cebe
|
7
|
+
data.tar.gz: f2d55d91d8513f33d530a307a5bb48e30a12368670ebed8ba132daffea2789912fe7e72112e5b6311a32af1dcdafdc7c23e6908ca23efb958ea67cca97125df9
|
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,13 @@
|
|
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
|
+
|
3
11
|
- **November.5.12**:1.3.2
|
4
12
|
- MASSIVE REFACTORING
|
5
13
|
- Patch for apostrophes in worksheet names
|
data/README.md
CHANGED
@@ -21,25 +21,24 @@ appreciation for the gem, please don't hesitate to make a donation.
|
|
21
21
|
|
22
22
|
**License**: MIT License
|
23
23
|
|
24
|
-
**Latest Version**:
|
24
|
+
**Latest Version**: 2.0.0
|
25
25
|
|
26
|
-
**Ruby Version**: 1.
|
26
|
+
**Ruby Version**: 1.9.2, 1.9.3, 2.0.0
|
27
27
|
|
28
|
-
**JRuby Version**: 1.
|
28
|
+
**JRuby Version**: 1.9 modes
|
29
29
|
|
30
30
|
**Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.
|
31
31
|
|
32
|
-
**Release Date**:
|
32
|
+
**Release Date**: September 12th 2013
|
33
33
|
|
34
34
|
If you are working in rails, or with active record see:
|
35
35
|
[acts_as_xlsx](http://github.com/randym/acts_as_xlsx)
|
36
36
|
|
37
37
|
acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
```ruby
|
40
|
+
Posts.where(created_at > Time.now-30.days).to_xlsx
|
41
|
+
```
|
43
42
|
|
44
43
|
** and **
|
45
44
|
|
@@ -71,46 +70,49 @@ With Axlsx you can create excel worksheets with charts, images (with links), aut
|
|
71
70
|
Feature List
|
72
71
|
------------
|
73
72
|
|
74
|
-
|
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.
|
75
74
|
|
76
|
-
|
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.
|
77
76
|
|
78
|
-
|
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.
|
79
78
|
|
80
|
-
|
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.
|
81
80
|
|
82
|
-
|
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.
|
83
82
|
|
84
|
-
|
83
|
+
6. Support for automatically formatted 1904 and 1900 epochs configurable in the workbook.
|
85
84
|
|
86
|
-
|
85
|
+
7. Add jpg, gif and png images to worksheets with hyperlinks
|
87
86
|
|
88
|
-
|
87
|
+
8. Reference cells in your worksheet with "A1" and "A1:D4" style references or from the workbook using "Sheet1!A3:B4" style references
|
89
88
|
|
90
|
-
|
89
|
+
9. Cell level style overrides for default and customized style objects
|
91
90
|
|
92
|
-
|
91
|
+
10. Support for formulas, merging, row and column outlining as well as
|
93
92
|
cell level input data validation.
|
94
93
|
|
95
|
-
|
94
|
+
12. Auto filtering tables with worksheet.auto_filter as well as support for Tables
|
96
95
|
|
97
|
-
|
96
|
+
13. Export using shared strings or inline strings so we can inter-op with iWork Numbers (sans charts for now).
|
98
97
|
|
99
|
-
|
98
|
+
14. Output to file or StringIO
|
100
99
|
|
101
|
-
|
100
|
+
15. Support for page margins and print options
|
102
101
|
|
103
|
-
|
102
|
+
16. Support for password and non password based sheet protection.
|
104
103
|
|
105
|
-
|
104
|
+
17. First stage interoperability support for GoogleDocs, LibreOffice,
|
106
105
|
and Numbers
|
107
106
|
|
108
|
-
|
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.
|
109
110
|
|
110
|
-
|
111
|
+
20. Support for sheet headers and footers
|
111
112
|
|
112
|
-
|
113
|
+
21. Pivot Tables
|
113
114
|
|
115
|
+
22. Page Breaks
|
114
116
|
|
115
117
|
Installing
|
116
118
|
----------
|
@@ -148,6 +150,7 @@ There is much, much more you can do with this gem. If you get stuck, grab me on
|
|
148
150
|
|
149
151
|
#Documentation
|
150
152
|
--------------
|
153
|
+
|
151
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:
|
152
155
|
|
153
156
|
gem install yard
|
@@ -156,10 +159,29 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
|
|
156
159
|
|
157
160
|
#Specs
|
158
161
|
------
|
162
|
+
|
159
163
|
This gem has 100% test coverage using test/unit. To execute tests for this gem, simply run rake in the gem directory.
|
160
164
|
|
161
165
|
#Change log
|
162
166
|
---------
|
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.
|
163
185
|
- **April.24.13**:1.3.6
|
164
186
|
- Fixed LibreOffice/OpenOffice issue to properly apply colors to lines
|
165
187
|
in charts.
|
@@ -180,13 +202,6 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
|
|
180
202
|
- Added support for descrete border edge styles
|
181
203
|
- Improved validation of sheet names
|
182
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.
|
183
|
-
- **November.25.12**:1.3.4
|
184
|
-
- Support for headers and footers for worksheets
|
185
|
-
- bug fix: Properly escape hyperlink urls
|
186
|
-
- Improvements in color_scale generation for conditional formatting
|
187
|
-
- Improvements in autowidth calculation.
|
188
|
-
- **November.8.12**:1.3.3
|
189
|
-
- Patched cell run styles for u and validation for family
|
190
205
|
|
191
206
|
Please see the {file:CHANGELOG.md} document for past release information.
|
192
207
|
|
@@ -227,55 +242,13 @@ p.serialize('simple.xlsx')
|
|
227
242
|
#Thanks!
|
228
243
|
|
229
244
|
Open source software is a community effort. None of this could have been
|
230
|
-
done without the help of
|
231
|
-
|
232
|
-
--------
|
233
|
-
[ochko](https://github.com/ochko) - for performance fixes, kicking the crap out of axlsx and helping to maintain my general sanity.
|
234
|
-
|
235
|
-
[kleine2](https://github.com/kleine2) - for generously donating in return for the image hyperlink feature.
|
236
|
-
|
237
|
-
[ffmike](https://github.com/ffmike) - for knocking down an over restrictive i18n dependency, massive patience and great communication skills.
|
238
|
-
|
239
|
-
[JonathanTron](https://github.com/JonathanTron) - for giving the gem some style, and making sure it applies.
|
240
|
-
|
241
|
-
[JosephHalter](https://github.com/JosephHalter) - for making sure we arrive at the right time on the right date.
|
242
|
-
|
243
|
-
[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.
|
244
|
-
|
245
|
-
[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.
|
246
|
-
|
247
|
-
[joekain](https://github.com/joekain) - for keeping our references working even in the double digits!
|
248
|
-
|
249
|
-
[moskrin](https://github.com/moskrin) - for keeping border creation on the edge.
|
250
|
-
|
251
|
-
[scpike](https://github.com/scpike) - for keeping numbers fixed even when they are rational and a super clean implementation of conditional formatting.
|
252
|
-
|
253
|
-
[janhuehne](https://github.com/janhuehne) - for working out the decoder ring and adding in cell level validation, and providing a support for window panes.
|
254
|
-
|
255
|
-
[rfc2616](https://github.com/rfc2616) - for FINALLY working out the interop issues with google docs.
|
256
|
-
|
257
|
-
[straydogstudio](https://github.com/straydogstudio) - For making an AWESOME axlsx templating gem for rails.
|
258
|
-
|
259
|
-
[MitchellAJ](https://github.com/MitchellAJ) - For catching a bug in font_size calculations, finding some old code in an example and above all for reporting all of that brilliantly
|
260
|
-
|
261
|
-
[ebenoist](https://github.com/ebenoist) - For taking control of control characters and keeping what is between the lines, between the lines.
|
262
|
-
|
263
|
-
[adammathys](https://github.com/adammathys) - For getting our head in the
|
264
|
-
air and our feet on the ground.
|
265
|
-
|
266
|
-
[raiis](https://github.com/raiis) - For letting us specify diffent border styles on any edge.
|
267
|
-
|
268
|
-
[alexrothenberg](https://github.com/alexrothenberg) - For an outstanding implementation of PivotTables, one of the last BIG chunks missing from the spec.
|
269
|
-
|
270
|
-
[ball-hayden](https://github.com/ball-hayden) - For making sure we only get the right characters in our sheet names.
|
271
|
-
|
272
|
-
[nibus](https://github.com/nibus) - For patching sheet name uniqueness.
|
245
|
+
done without the help of these awesome folks.
|
273
246
|
|
274
|
-
[
|
247
|
+
[contributors](https://github.com/randym/axlsx/graphs/contributors)
|
275
248
|
|
276
249
|
#Copyright and License
|
277
250
|
----------
|
278
251
|
|
279
|
-
Axlsx © 2011-2013 by [Randy Morgan](mailto:digial.ipseity@gmail.com).
|
252
|
+
Axlsx © 2011-2013 by [Randy Morgan](mailto:digial.ipseity@gmail.com).
|
280
253
|
|
281
254
|
Axlsx is licensed under the MIT license. Please see the LICENSE document for more information.
|
data/Rakefile
CHANGED
@@ -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'
|
data/examples/example.rb
CHANGED
@@ -46,6 +46,8 @@ examples << :streaming
|
|
46
46
|
examples << :shared_strings
|
47
47
|
examples << :no_autowidth
|
48
48
|
examples << :cached_formula
|
49
|
+
examples << :page_breaks
|
50
|
+
|
49
51
|
p = Axlsx::Package.new
|
50
52
|
wb = p.workbook
|
51
53
|
#```
|
@@ -57,6 +59,7 @@ if examples.include? :basic
|
|
57
59
|
wb.add_worksheet(:name => "Basic Worksheet") do |sheet|
|
58
60
|
sheet.add_row ["First Column", "Second", "Third"]
|
59
61
|
sheet.add_row [1, 2, 3]
|
62
|
+
sheet.add_row [' preserving whitespace']
|
60
63
|
end
|
61
64
|
end
|
62
65
|
#```
|
@@ -309,6 +312,7 @@ end
|
|
309
312
|
|
310
313
|
#```ruby
|
311
314
|
if examples.include? :mbcs
|
315
|
+
wb.styles.fonts.first.name = 'Arial Unicode MS'
|
312
316
|
wb.add_worksheet(:name => "日本語でのシート名") do |sheet|
|
313
317
|
sheet.add_row ["日本語"]
|
314
318
|
sheet.add_row ["华语/華語"]
|
@@ -640,6 +644,7 @@ if examples.include? :sheet_view
|
|
640
644
|
end
|
641
645
|
end
|
642
646
|
|
647
|
+
|
643
648
|
# conditional formatting
|
644
649
|
#
|
645
650
|
if examples.include? :conditional_formatting
|
@@ -710,7 +715,17 @@ if examples.include? :conditional_formatting
|
|
710
715
|
end
|
711
716
|
end
|
712
717
|
|
713
|
-
|
718
|
+
# Page Breaks
|
719
|
+
if examples.include? :page_breaks
|
720
|
+
ws = wb.add_worksheet(:name => "page breaks") do |sheet|
|
721
|
+
sheet.add_row ["A"] * 10
|
722
|
+
sheet.add_row ["A"] * 10
|
723
|
+
sheet.add_page_break("B2")
|
724
|
+
sheet.sheet_view.view = :page_layout # so you can see the breaks!
|
725
|
+
end
|
726
|
+
end
|
727
|
+
|
728
|
+
#Validate and Serialize
|
714
729
|
|
715
730
|
#```ruby
|
716
731
|
# Serialize directly to file
|
data/examples/pivot_table.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
2
|
+
require 'axlsx'
|
3
|
+
p = Axlsx::Package.new
|
4
|
+
p.workbook do |wb|
|
5
|
+
wb.styles do |s|
|
6
|
+
no_underline = s.add_style :sz => 10, :b => true, :u => false, :alignment => { :horizontal=> :right }
|
7
|
+
wb.add_worksheet(:name => 'wunderlinen') do |sheet|
|
8
|
+
sheet.add_row %w{a b c really?}, :style => no_underline
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
p.serialize 'no_underline.xlsx'
|
13
|
+
|
data/lib/axlsx.rb
CHANGED
@@ -127,6 +127,14 @@ module Axlsx
|
|
127
127
|
s.gsub(/_(.)/){ $1.upcase }
|
128
128
|
end
|
129
129
|
|
130
|
+
# returns the provided string with all invalid control charaters
|
131
|
+
# removed.
|
132
|
+
# @param [String] str The sting to process
|
133
|
+
# @return [String]
|
134
|
+
def self.sanitize(str)
|
135
|
+
str.gsub(CONTROL_CHAR_REGEX, '')
|
136
|
+
end
|
137
|
+
|
130
138
|
|
131
139
|
# Instructs the serializer to not try to escape cell value input.
|
132
140
|
# This will give you a huge speed bonus, but if you content has <, > or other xml character data
|
data/lib/axlsx/doc_props/core.rb
CHANGED
@@ -8,14 +8,19 @@ module Axlsx
|
|
8
8
|
|
9
9
|
# Creates a new Core object.
|
10
10
|
# @option options [String] creator
|
11
|
+
# @option options [Time] created
|
11
12
|
def initialize(options={})
|
12
13
|
@creator = options[:creator] || 'axlsx'
|
14
|
+
@created = options[:created]
|
13
15
|
end
|
14
16
|
|
15
17
|
# The author of the document. By default this is 'axlsx'
|
16
18
|
# @return [String]
|
17
19
|
attr_accessor :creator
|
18
20
|
|
21
|
+
# Creation time of the document. If nil, the current time will be used.
|
22
|
+
attr_accessor :created
|
23
|
+
|
19
24
|
# serializes the core.xml document
|
20
25
|
# @return [String]
|
21
26
|
def to_xml_string(str = '')
|
@@ -24,7 +29,7 @@ module Axlsx
|
|
24
29
|
str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
|
25
30
|
str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
|
26
31
|
str << '<dc:creator>' << self.creator << '</dc:creator>'
|
27
|
-
str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << Time.now.strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
|
32
|
+
str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
|
28
33
|
str << '<cp:revision>0</cp:revision>'
|
29
34
|
str << '</cp:coreProperties>'
|
30
35
|
end
|
data/lib/axlsx/drawing/axes.rb
CHANGED
@@ -5,9 +5,11 @@ module Axlsx
|
|
5
5
|
class Axes
|
6
6
|
|
7
7
|
# @param [Hash] options options used to generate axis each key
|
8
|
-
# should be an axis name like :
|
9
|
-
# class of the axis type to construct.
|
8
|
+
# should be an axis name like :val_axis and its value should be the
|
9
|
+
# class of the axis type to construct. The :cat_axis, if there is one,
|
10
|
+
# must come first (we assume a Ruby 1.9+ Hash or an OrderedHash).
|
10
11
|
def initialize(options={})
|
12
|
+
raise(ArgumentError, "CatAxis must come first") if options.keys.include?(:cat_axis) && options.keys.first != :cat_axis
|
11
13
|
options.each do |name, axis_class|
|
12
14
|
add_axis(name, axis_class)
|
13
15
|
end
|
@@ -28,7 +30,9 @@ module Axlsx
|
|
28
30
|
# serialized. Otherwise, each axis is serialized in full.
|
29
31
|
def to_xml_string(str = '', options = {})
|
30
32
|
if options[:ids]
|
31
|
-
|
33
|
+
# CatAxis must come first in the XML (for Microsoft Excel at least)
|
34
|
+
sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 }
|
35
|
+
sorted.inject(str) { |string, axis| string << '<c:axId val="' << axis[1].id.to_s << '"/>' }
|
32
36
|
else
|
33
37
|
axes.each { |axis| axis[1].to_xml_string(str) }
|
34
38
|
end
|