axlsx 1.3.5 → 1.3.6

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 (38) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +26 -17
  4. data/examples/conditional_formatting/example_conditional_formatting.rb +4 -2
  5. data/examples/example.rb +22 -9
  6. data/examples/pivot_table.rb +0 -2
  7. data/lib/axlsx/drawing/axes.rb +57 -0
  8. data/lib/axlsx/drawing/axis.rb +16 -13
  9. data/lib/axlsx/drawing/bar_3D_chart.rb +16 -12
  10. data/lib/axlsx/drawing/cat_axis.rb +2 -10
  11. data/lib/axlsx/drawing/d_lbls.rb +1 -1
  12. data/lib/axlsx/drawing/drawing.rb +2 -0
  13. data/lib/axlsx/drawing/line_3D_chart.rb +27 -70
  14. data/lib/axlsx/drawing/line_chart.rb +99 -0
  15. data/lib/axlsx/drawing/line_series.rb +20 -2
  16. data/lib/axlsx/drawing/scatter_chart.rb +27 -17
  17. data/lib/axlsx/drawing/ser_axis.rb +15 -16
  18. data/lib/axlsx/drawing/val_axis.rb +14 -13
  19. data/lib/axlsx/drawing/vml_shape.rb +18 -77
  20. data/lib/axlsx/util/serialized_attributes.rb +0 -1
  21. data/lib/axlsx/version.rb +1 -1
  22. data/lib/axlsx/workbook/worksheet/comment.rb +10 -23
  23. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +5 -3
  24. data/test/benchmark.rb +0 -1
  25. data/test/drawing/tc_axis.rb +15 -17
  26. data/test/drawing/tc_cat_axis.rb +9 -9
  27. data/test/drawing/tc_line_chart.rb +39 -0
  28. data/test/drawing/tc_line_series.rb +8 -2
  29. data/test/drawing/tc_ser_axis.rb +13 -12
  30. data/test/drawing/tc_val_axis.rb +6 -6
  31. data/test/drawing/tc_vml_shape.rb +9 -3
  32. data/test/profile.rb +5 -11
  33. data/test/tc_helper.rb +1 -0
  34. data/test/util/tc_validators.rb +5 -1
  35. data/test/workbook/worksheet/tc_comment.rb +5 -1
  36. data/test/workbook/worksheet/tc_comments.rb +2 -2
  37. data/test/workbook/worksheet/tc_conditional_formatting.rb +7 -0
  38. metadata +21 -55
@@ -2,29 +2,30 @@ require 'tc_helper.rb'
2
2
 
3
3
  class TestSerAxis < Test::Unit::TestCase
4
4
  def setup
5
- @axis = Axlsx::SerAxis.new 12345, 54321
5
+ @axis = Axlsx::SerAxis.new
6
6
  end
7
+
7
8
  def teardown
8
9
  end
9
10
 
10
11
  def test_options
11
- a = Axlsx::SerAxis.new 12345, 54321, :tickLblSkip => 9, :tickMarkSkip => 7
12
- assert_equal(a.tickLblSkip, 9)
13
- assert_equal(a.tickMarkSkip, 7)
12
+ a = Axlsx::SerAxis.new(:tick_lbl_skip => 9, :tick_mark_skip => 7)
13
+ assert_equal(a.tick_lbl_skip, 9)
14
+ assert_equal(a.tick_mark_skip, 7)
14
15
  end
15
16
 
16
17
 
17
- def test_tickLblSkip
18
- assert_raise(ArgumentError, "requires valid tickLblSkip") { @axis.tickLblSkip = -1 }
19
- assert_nothing_raised("accepts valid tickLblSkip") { @axis.tickLblSkip = 1 }
20
- assert_equal(@axis.tickLblSkip, 1)
18
+ def test_tick_lbl_skip
19
+ assert_raise(ArgumentError, "requires valid tick_lbl_skip") { @axis.tick_lbl_skip = -1 }
20
+ assert_nothing_raised("accepts valid tick_lbl_skip") { @axis.tick_lbl_skip = 1 }
21
+ assert_equal(@axis.tick_lbl_skip, 1)
21
22
  end
22
23
 
23
24
 
24
- def test_tickMarkSkip
25
- assert_raise(ArgumentError, "requires valid tickMarkSkip") { @axis.tickMarkSkip = :my_eyes }
26
- assert_nothing_raised("accepts valid tickMarkSkip") { @axis.tickMarkSkip = 2 }
27
- assert_equal(@axis.tickMarkSkip, 2)
25
+ def test_tick_mark_skip
26
+ assert_raise(ArgumentError, "requires valid tick_mark_skip") { @axis.tick_mark_skip = :my_eyes }
27
+ assert_nothing_raised("accepts valid tick_mark_skip") { @axis.tick_mark_skip = 2 }
28
+ assert_equal(@axis.tick_mark_skip, 2)
28
29
  end
29
30
 
30
31
  end
@@ -2,23 +2,23 @@ require 'tc_helper.rb'
2
2
 
3
3
  class TestValAxis < Test::Unit::TestCase
4
4
  def setup
5
- @axis = Axlsx::ValAxis.new 12345, 54321
5
+ @axis = Axlsx::ValAxis.new
6
6
  end
7
7
  def teardown
8
8
  end
9
9
 
10
10
  def test_initialization
11
- assert_equal(@axis.crossBetween, :between, "axis crossBetween default incorrect")
11
+ assert_equal(@axis.cross_between, :between, "axis crossBetween default incorrect")
12
12
  end
13
13
 
14
14
  def test_options
15
- a = Axlsx::ValAxis.new 2345, 4321, :crossBetween => :midCat
16
- assert_equal(a.crossBetween, :midCat)
15
+ a = Axlsx::ValAxis.new(:cross_between => :midCat)
16
+ assert_equal(:midCat, a.cross_between)
17
17
  end
18
18
 
19
19
  def test_crossBetween
20
- assert_raise(ArgumentError, "requires valid crossBetween") { @axis.crossBetween = :my_eyes }
21
- assert_nothing_raised("accepts valid crossBetween") { @axis.crossBetween = :midCat }
20
+ assert_raise(ArgumentError, "requires valid crossBetween") { @axis.cross_between = :my_eyes }
21
+ assert_nothing_raised("accepts valid crossBetween") { @axis.cross_between = :midCat }
22
22
  end
23
23
 
24
24
  end
@@ -6,8 +6,8 @@ class TestVmlShape < Test::Unit::TestCase
6
6
  p = Axlsx::Package.new
7
7
  wb = p.workbook
8
8
  @ws = wb.add_worksheet
9
- @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank'
10
- @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO'
9
+ @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank', :visible => true
10
+ @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO', :visible => false
11
11
  @comments = @ws.comments
12
12
  end
13
13
 
@@ -84,11 +84,17 @@ class TestVmlShape < Test::Unit::TestCase
84
84
  assert(shape.top_row == 3)
85
85
  assert_raise(ArgumentError) { shape.top_row = [] }
86
86
  end
87
-
87
+ def test_visible
88
+ shape = @comments.first.vml_shape
89
+ shape.visible = false
90
+ assert(shape.visible == false)
91
+ assert_raise(ArgumentError) { shape.visible = 'foo' }
92
+ end
88
93
  def test_to_xml_string
89
94
  str = @comments.vml_drawing.to_xml_string()
90
95
  doc = Nokogiri::XML(str)
91
96
  assert_equal(doc.xpath("//v:shape").size, 2)
97
+ assert_equal(1, doc.xpath("//x:Visible").size, 'ClientData/x:Visible element rendering')
92
98
  @comments.each do |comment|
93
99
  shape = comment.vml_shape
94
100
  assert(doc.xpath("//v:shape/x:ClientData/x:Row[text()='#{shape.row}']").size == 1)
@@ -1,26 +1,20 @@
1
1
  #!/usr/bin/env ruby -s
2
2
 
3
- # Usage:
4
- # > ruby test/profile.rb
5
- # > pprof.rb --gif /tmp/axlsx > /tmp/axlsx.gif
6
- # > open /tmp/axlsx_noautowidth.gif
7
-
8
3
  $:.unshift "#{File.dirname(__FILE__)}/../lib"
9
4
  require 'axlsx'
10
- require 'perftools'
11
- Axlsx.trust_input = true
5
+ require 'ruby-prof'
12
6
  row = []
13
7
  # Taking worst case scenario of all string data
14
8
  input = (32..126).to_a.pack('U*').chars.to_a
15
9
  20.times { row << input.shuffle.join}
16
- times = 3000
17
10
 
18
- PerfTools::CpuProfiler.start("/tmp/axlsx") do
11
+ profile = RubyProf.profile do
19
12
  p = Axlsx::Package.new
20
13
  p.workbook.add_worksheet do |sheet|
21
- times.times do
14
+ 30.times do
22
15
  sheet << row
23
16
  end
24
17
  end
25
- p.serialize("example.xlsx")
26
18
  end
19
+ printer = RubyProf::CallTreePrinter.new(profile)
20
+ printer.print(File.new('axlsx.qcachegrind', 'w'))
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
2
  require 'simplecov'
3
3
  SimpleCov.start do
4
4
  add_filter "/test/"
5
+ add_filter "/vendor/"
5
6
  end
6
7
 
7
8
  require 'test/unit'
@@ -158,7 +158,11 @@ class TestValidators < Test::Unit::TestCase
158
158
  assert_raise(ArgumentError) { Axlsx.validate_split_state_type 'frozen_split' }
159
159
  assert_raise(ArgumentError) { Axlsx.validate_split_state_type 0 }
160
160
  end
161
-
161
+
162
+ def test_validate_integerish
163
+ assert_raise(ArgumentError) { Axlsx.validate_integerish Axlsx }
164
+ [1, 1.4, "a"].each { |test_value| assert_nothing_raised { Axlsx.validate_integerish test_value } }
165
+ end
162
166
  def test_validate_family
163
167
  assert_raise(ArgumentError) { Axlsx.validate_family 0 }
164
168
  (1..5).each do |item|
@@ -5,7 +5,7 @@ class TestComment < Test::Unit::TestCase
5
5
  p = Axlsx::Package.new
6
6
  wb = p.workbook
7
7
  @ws = wb.add_worksheet
8
- @c1 = @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank'
8
+ @c1 = @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank', :visible => false
9
9
  @c2 = @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO'
10
10
  end
11
11
 
@@ -28,6 +28,10 @@ class TestComment < Test::Unit::TestCase
28
28
  assert_equal(@c2.author_index, 0)
29
29
  end
30
30
 
31
+ def test_visible
32
+ assert_equal(false, @c1.visible)
33
+ assert_equal(true, @c2.visible)
34
+ end
31
35
  def test_ref
32
36
  assert(@c1.ref == 'A1')
33
37
  assert(@c2.ref == 'C3')
@@ -25,9 +25,9 @@ class TestComments < Test::Unit::TestCase
25
25
  end
26
26
  def test_authors
27
27
  assert_equal(@ws.comments.authors.size, @ws.comments.size)
28
- @ws.add_comment(:text => 'Yes We Can!', :author => :bob, :ref => 'F1')
28
+ @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1')
29
29
  assert_equal(@ws.comments.authors.size, 3)
30
- @ws.add_comment(:text => 'Yes We Can!', :author => :bob, :ref => 'F1')
30
+ @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1')
31
31
  assert_equal(@ws.comments.authors.size, 3, 'only unique authors are returned')
32
32
  end
33
33
  def test_pn
@@ -130,6 +130,13 @@ class TestConditionalFormatting < Test::Unit::TestCase
130
130
  assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='greaterThan']//xmlns:formula='0.5'")
131
131
  end
132
132
 
133
+ def test_multiple_formulas
134
+ @ws.add_conditional_formatting "B3:B3", { :type => :cellIs, :dxfId => 0, :priority => 1, :operator => :between, :formula => ["1","5"] }
135
+ doc = Nokogiri::XML.parse(@ws.to_xml_string)
136
+ assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='between']//xmlns:formula='1'")
137
+ assert doc.xpath("//xmlns:worksheet/xmlns:conditionalFormatting//xmlns:cfRule[@type='cellIs'][@dxfId=0][@priority=1][@operator='between']//xmlns:formula='5'")
138
+ end
139
+
133
140
  def test_sqref
134
141
  assert_raise(ArgumentError) { @cf.sqref = 10 }
135
142
  assert_nothing_raised { @cf.sqref = "A1:A1" }
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: axlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
5
- prerelease:
4
+ version: 1.3.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Randy Morgan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
11
+ date: 2013-04-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.4.1
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.4.1
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rubyzip
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.9.5
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.9.5
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: htmlentities
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,60 +55,33 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: yard
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: kramdown
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: simplecov
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- description: ! ' xlsx spreadsheet generation with charts, images, automated column
111
- width, customizable styles and full schema validation. Axlsx helps you create beautiful
112
- Office Open XML Spreadsheet documents ( Excel, Google Spreadsheets, Numbers, LibreOffice)
113
- without having to understand the entire ECMA specification. Check out the README
114
- for some examples of how easy it is. Best of all, you can validate your xlsx file
115
- before serialization so you know for sure that anything generated is going to load
116
- on your client''s machine.
117
-
118
- '
83
+ description: |2
84
+ xlsx spreadsheet generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx helps you create beautiful Office Open XML Spreadsheet documents ( Excel, Google Spreadsheets, Numbers, LibreOffice) without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.
119
85
  email: digital.ipseity@gmail.com
120
86
  executables: []
121
87
  extensions: []
@@ -128,6 +94,7 @@ files:
128
94
  - lib/axlsx/doc_props/app.rb
129
95
  - lib/axlsx/doc_props/core.rb
130
96
  - lib/axlsx/drawing/ax_data_source.rb
97
+ - lib/axlsx/drawing/axes.rb
131
98
  - lib/axlsx/drawing/axis.rb
132
99
  - lib/axlsx/drawing/bar_3D_chart.rb
133
100
  - lib/axlsx/drawing/bar_series.rb
@@ -138,6 +105,7 @@ files:
138
105
  - lib/axlsx/drawing/graphic_frame.rb
139
106
  - lib/axlsx/drawing/hyperlink.rb
140
107
  - lib/axlsx/drawing/line_3D_chart.rb
108
+ - lib/axlsx/drawing/line_chart.rb
141
109
  - lib/axlsx/drawing/line_series.rb
142
110
  - lib/axlsx/drawing/marker.rb
143
111
  - lib/axlsx/drawing/num_data.rb
@@ -324,6 +292,7 @@ files:
324
292
  - test/drawing/tc_graphic_frame.rb
325
293
  - test/drawing/tc_hyperlink.rb
326
294
  - test/drawing/tc_line_3d_chart.rb
295
+ - test/drawing/tc_line_chart.rb
327
296
  - test/drawing/tc_line_series.rb
328
297
  - test/drawing/tc_marker.rb
329
298
  - test/drawing/tc_named_axis_data.rb
@@ -414,30 +383,26 @@ files:
414
383
  - test/workbook/worksheet/tc_worksheet_hyperlink.rb
415
384
  homepage: https://github.com/randym/axlsx
416
385
  licenses: []
386
+ metadata: {}
417
387
  post_install_message:
418
388
  rdoc_options: []
419
389
  require_paths:
420
390
  - lib
421
391
  required_ruby_version: !ruby/object:Gem::Requirement
422
- none: false
423
392
  requirements:
424
- - - ! '>='
393
+ - - '>='
425
394
  - !ruby/object:Gem::Version
426
395
  version: 1.8.7
427
396
  required_rubygems_version: !ruby/object:Gem::Requirement
428
- none: false
429
397
  requirements:
430
- - - ! '>='
398
+ - - '>='
431
399
  - !ruby/object:Gem::Version
432
400
  version: '0'
433
- segments:
434
- - 0
435
- hash: -4130267238681018479
436
401
  requirements: []
437
402
  rubyforge_project:
438
- rubygems_version: 1.8.24
403
+ rubygems_version: 2.0.3
439
404
  signing_key:
440
- specification_version: 3
405
+ specification_version: 4
441
406
  summary: excel OOXML (xlsx) with charts, styles, images and autowidth columns.
442
407
  test_files:
443
408
  - test/benchmark.rb
@@ -458,6 +423,7 @@ test_files:
458
423
  - test/drawing/tc_graphic_frame.rb
459
424
  - test/drawing/tc_hyperlink.rb
460
425
  - test/drawing/tc_line_3d_chart.rb
426
+ - test/drawing/tc_line_chart.rb
461
427
  - test/drawing/tc_line_series.rb
462
428
  - test/drawing/tc_marker.rb
463
429
  - test/drawing/tc_named_axis_data.rb