write_xlsx 0.59.0 → 0.60.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/README.rdoc +11 -2
  2. data/bin/extract_vba.rb +5 -0
  3. data/lib/write_xlsx/package/comments.rb +0 -2
  4. data/lib/write_xlsx/package/packager.rb +3 -2
  5. data/lib/write_xlsx/package/vml.rb +250 -31
  6. data/lib/write_xlsx/package/xml_writer_simple.rb +1 -1
  7. data/lib/write_xlsx/version.rb +1 -1
  8. data/lib/write_xlsx/workbook.rb +28 -18
  9. data/lib/write_xlsx/worksheet.rb +139 -4
  10. data/test/package/vml/test_write_div.rb +1 -1
  11. data/test/package/vml/test_write_fill.rb +10 -2
  12. data/test/package/vml/test_write_path.rb +10 -2
  13. data/test/package/vml/test_write_shapetype.rb +9 -1
  14. data/test/package/vml/test_write_textbox.rb +1 -1
  15. data/test/regression/test_button01.rb +23 -0
  16. data/test/regression/test_button02.rb +29 -0
  17. data/test/regression/test_button03.rb +24 -0
  18. data/test/regression/test_button04.rb +25 -0
  19. data/test/regression/test_button05.rb +28 -0
  20. data/test/regression/test_button06.rb +28 -0
  21. data/test/regression/test_button07.rb +32 -0
  22. data/test/regression/test_escapes07.rb +29 -0
  23. data/test/regression/test_escapes08.rb +30 -0
  24. data/test/regression/test_vml01.rb +29 -0
  25. data/test/regression/test_vml02.rb +31 -0
  26. data/test/regression/test_vml03.rb +40 -0
  27. data/test/regression/test_vml04.rb +41 -0
  28. data/test/regression/xlsx_files/button01.xlsx +0 -0
  29. data/test/regression/xlsx_files/button02.xlsx +0 -0
  30. data/test/regression/xlsx_files/button03.xlsx +0 -0
  31. data/test/regression/xlsx_files/button04.xlsx +0 -0
  32. data/test/regression/xlsx_files/button05.xlsx +0 -0
  33. data/test/regression/xlsx_files/button07.xlsm +0 -0
  34. data/test/regression/xlsx_files/escapes07.xlsx +0 -0
  35. data/test/regression/xlsx_files/escapes08.xlsx +0 -0
  36. data/test/regression/xlsx_files/vbaProject02.bin +0 -0
  37. data/test/regression/xlsx_files/vml01.xlsx +0 -0
  38. data/test/regression/xlsx_files/vml02.xlsx +0 -0
  39. data/test/regression/xlsx_files/vml03.xlsx +0 -0
  40. data/test/regression/xlsx_files/vml04.xlsx +0 -0
  41. metadata +54 -2
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionButton03 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_button03
14
+ @xlsx = 'button03.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.insert_button('C2', {})
19
+ worksheet.insert_button('E5', {})
20
+
21
+ workbook.close
22
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionButton04 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_button04
14
+ @xlsx = 'button04.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet1 = workbook.add_worksheet
17
+ worksheet2 = workbook.add_worksheet
18
+
19
+ worksheet1.insert_button('C2', {})
20
+ worksheet2.insert_button('E5', {})
21
+
22
+ workbook.close
23
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionButton05 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_button05
14
+ @xlsx = 'button05.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.insert_button('C2', {
19
+ :macro => 'my_macro',
20
+ :x_scale => 2,
21
+ :y_scale => 1.5
22
+ }
23
+ )
24
+
25
+ workbook.close
26
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionButton06 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_button06
14
+ @xlsx = 'button05.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.insert_button('C2', {
19
+ :macro => 'my_macro',
20
+ :width => 128,
21
+ :height => 30
22
+ }
23
+ )
24
+
25
+ workbook.close
26
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionButton07 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_button07
14
+ @xlsx = 'button07.xlsm'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ workbook.instance_variable_set(:@vba_codename, 'ThisWorkbook')
19
+ worksheet.instance_variable_set(:@vba_codename, 'Sheet1')
20
+
21
+ worksheet.insert_button('C2', {
22
+ :macro => 'say_hello',
23
+ :caption => 'Hello'
24
+ }
25
+ )
26
+
27
+ workbook.add_vba_project(File.join(@regression_output, 'vbaProject02.bin'))
28
+
29
+ workbook.close
30
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionEscapes07 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_escapes07
14
+ @xlsx = 'escapes07.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write_url(
19
+ 'A1',
20
+ "http://example.com/!\"$%&'( )*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
21
+ )
22
+
23
+ workbook.close
24
+ compare_xlsx_for_regression(
25
+ File.join(@regression_output, @xlsx),
26
+ @xlsx
27
+ )
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionEscapes08 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_chart_escapes08
14
+ @xlsx = 'escapes08.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ # Test an already escaped string.
19
+ worksheet.write_url(
20
+ 'A1',
21
+ 'http://example.com/%5b0%5d', 'http://example.com/[0]'
22
+ )
23
+
24
+ workbook.close
25
+ compare_xlsx_for_regression(
26
+ File.join(@regression_output, @xlsx),
27
+ @xlsx
28
+ )
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionVml01 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_vml01
14
+ @xlsx = 'vml01.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write('A1', 'Foo')
19
+ worksheet.write_comment('B2', 'Some text')
20
+
21
+ # Set the author to match the target XLSX file.
22
+ worksheet.set_comments_author('John')
23
+
24
+ worksheet.insert_button('C4', {})
25
+
26
+ workbook.close
27
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionVml02 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_vml02
14
+ @xlsx = 'vml02.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ worksheet.write('A1', 'Foo')
19
+ worksheet.write_comment('B2', 'Some text')
20
+ worksheet.write_comment('D17', 'More text')
21
+
22
+ # Set the author to match the target XLSX file.
23
+ worksheet.set_comments_author('John')
24
+
25
+ worksheet.insert_button('C4', {})
26
+ worksheet.insert_button('E8', {})
27
+
28
+ workbook.close
29
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionVml03 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_vml03
14
+ @xlsx = 'vml03.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet1 = workbook.add_worksheet
17
+ worksheet2 = workbook.add_worksheet
18
+ worksheet3 = workbook.add_worksheet
19
+
20
+ worksheet1.write('A1', 'Foo')
21
+ worksheet1.write_comment('B2', 'Some text')
22
+
23
+ worksheet3.write('A1', 'Bar')
24
+ worksheet3.write_comment('C7', 'More text')
25
+
26
+ # Set the author to match the target XLSX file.
27
+ worksheet1.set_comments_author('John')
28
+ worksheet3.set_comments_author('John')
29
+
30
+ worksheet1.insert_button('C4', {})
31
+ worksheet1.insert_button('E8', {})
32
+
33
+ worksheet3.insert_button('B2', {})
34
+ worksheet3.insert_button('C4', {})
35
+ worksheet3.insert_button('E8', {})
36
+
37
+ workbook.close
38
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
39
+ end
40
+ end
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionVml04 < Test::Unit::TestCase
5
+ def setup
6
+ setup_dir_var
7
+ end
8
+
9
+ def teardown
10
+ File.delete(@xlsx) if File.exist?(@xlsx)
11
+ end
12
+
13
+ def test_vml04
14
+ @xlsx = 'vml04.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet1 = workbook.add_worksheet
17
+ worksheet2 = workbook.add_worksheet
18
+ worksheet3 = workbook.add_worksheet
19
+
20
+ (0..127).each do |row|
21
+ (0..15).each do |col|
22
+ worksheet1.write_comment(row, col, 'Some text')
23
+ end
24
+ end
25
+
26
+ worksheet3.write_comment('A1', 'More text')
27
+
28
+ # Set the author to match the target XLSX file.
29
+ worksheet1.set_comments_author('John')
30
+ worksheet3.set_comments_author('John')
31
+
32
+ worksheet1.insert_button('B2', {})
33
+ worksheet1.insert_button('C4', {})
34
+ worksheet1.insert_button('E6', {})
35
+
36
+ worksheet3.insert_button('E8', {})
37
+
38
+ workbook.close
39
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: write_xlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.59.0
4
+ version: 0.60.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-17 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
@@ -336,6 +336,13 @@ files:
336
336
  - test/regression/test_autofilter05.rb
337
337
  - test/regression/test_autofilter06.rb
338
338
  - test/regression/test_autofilter07.rb
339
+ - test/regression/test_button01.rb
340
+ - test/regression/test_button02.rb
341
+ - test/regression/test_button03.rb
342
+ - test/regression/test_button04.rb
343
+ - test/regression/test_button05.rb
344
+ - test/regression/test_button06.rb
345
+ - test/regression/test_button07.rb
339
346
  - test/regression/test_chart_area01.rb
340
347
  - test/regression/test_chart_area02.rb
341
348
  - test/regression/test_chart_area03.rb
@@ -504,6 +511,8 @@ files:
504
511
  - test/regression/test_escapes04.rb
505
512
  - test/regression/test_escapes05.rb
506
513
  - test/regression/test_escapes06.rb
514
+ - test/regression/test_escapes07.rb
515
+ - test/regression/test_escapes08.rb
507
516
  - test/regression/test_fit_to_pages01.rb
508
517
  - test/regression/test_fit_to_pages02.rb
509
518
  - test/regression/test_fit_to_pages03.rb
@@ -626,6 +635,10 @@ files:
626
635
  - test/regression/test_table12.rb
627
636
  - test/regression/test_table13.rb
628
637
  - test/regression/test_table14.rb
638
+ - test/regression/test_vml01.rb
639
+ - test/regression/test_vml02.rb
640
+ - test/regression/test_vml03.rb
641
+ - test/regression/test_vml04.rb
629
642
  - test/regression/xlsx_files/array_formula01.xlsx
630
643
  - test/regression/xlsx_files/array_formula02.xlsx
631
644
  - test/regression/xlsx_files/autofilter00.xlsx
@@ -636,6 +649,12 @@ files:
636
649
  - test/regression/xlsx_files/autofilter05.xlsx
637
650
  - test/regression/xlsx_files/autofilter06.xlsx
638
651
  - test/regression/xlsx_files/autofilter07.xlsx
652
+ - test/regression/xlsx_files/button01.xlsx
653
+ - test/regression/xlsx_files/button02.xlsx
654
+ - test/regression/xlsx_files/button03.xlsx
655
+ - test/regression/xlsx_files/button04.xlsx
656
+ - test/regression/xlsx_files/button05.xlsx
657
+ - test/regression/xlsx_files/button07.xlsm
639
658
  - test/regression/xlsx_files/chart_area01.xlsx
640
659
  - test/regression/xlsx_files/chart_area02.xlsx
641
660
  - test/regression/xlsx_files/chart_area03.xlsx
@@ -804,6 +823,8 @@ files:
804
823
  - test/regression/xlsx_files/escapes04.xlsx
805
824
  - test/regression/xlsx_files/escapes05.xlsx
806
825
  - test/regression/xlsx_files/escapes06.xlsx
826
+ - test/regression/xlsx_files/escapes07.xlsx
827
+ - test/regression/xlsx_files/escapes08.xlsx
807
828
  - test/regression/xlsx_files/filehandle01.xlsx
808
829
  - test/regression/xlsx_files/fit_to_pages01.xlsx
809
830
  - test/regression/xlsx_files/fit_to_pages02.xlsx
@@ -928,6 +949,11 @@ files:
928
949
  - test/regression/xlsx_files/table13.xlsx
929
950
  - test/regression/xlsx_files/table14.xlsx
930
951
  - test/regression/xlsx_files/vbaProject01.bin
952
+ - test/regression/xlsx_files/vbaProject02.bin
953
+ - test/regression/xlsx_files/vml01.xlsx
954
+ - test/regression/xlsx_files/vml02.xlsx
955
+ - test/regression/xlsx_files/vml03.xlsx
956
+ - test/regression/xlsx_files/vml04.xlsx
931
957
  - test/test_delete_files.rb
932
958
  - test/test_example_match.rb
933
959
  - test/test_xml_writer_simple.rb
@@ -1249,6 +1275,13 @@ test_files:
1249
1275
  - test/regression/test_autofilter05.rb
1250
1276
  - test/regression/test_autofilter06.rb
1251
1277
  - test/regression/test_autofilter07.rb
1278
+ - test/regression/test_button01.rb
1279
+ - test/regression/test_button02.rb
1280
+ - test/regression/test_button03.rb
1281
+ - test/regression/test_button04.rb
1282
+ - test/regression/test_button05.rb
1283
+ - test/regression/test_button06.rb
1284
+ - test/regression/test_button07.rb
1252
1285
  - test/regression/test_chart_area01.rb
1253
1286
  - test/regression/test_chart_area02.rb
1254
1287
  - test/regression/test_chart_area03.rb
@@ -1417,6 +1450,8 @@ test_files:
1417
1450
  - test/regression/test_escapes04.rb
1418
1451
  - test/regression/test_escapes05.rb
1419
1452
  - test/regression/test_escapes06.rb
1453
+ - test/regression/test_escapes07.rb
1454
+ - test/regression/test_escapes08.rb
1420
1455
  - test/regression/test_fit_to_pages01.rb
1421
1456
  - test/regression/test_fit_to_pages02.rb
1422
1457
  - test/regression/test_fit_to_pages03.rb
@@ -1539,6 +1574,10 @@ test_files:
1539
1574
  - test/regression/test_table12.rb
1540
1575
  - test/regression/test_table13.rb
1541
1576
  - test/regression/test_table14.rb
1577
+ - test/regression/test_vml01.rb
1578
+ - test/regression/test_vml02.rb
1579
+ - test/regression/test_vml03.rb
1580
+ - test/regression/test_vml04.rb
1542
1581
  - test/regression/xlsx_files/array_formula01.xlsx
1543
1582
  - test/regression/xlsx_files/array_formula02.xlsx
1544
1583
  - test/regression/xlsx_files/autofilter00.xlsx
@@ -1549,6 +1588,12 @@ test_files:
1549
1588
  - test/regression/xlsx_files/autofilter05.xlsx
1550
1589
  - test/regression/xlsx_files/autofilter06.xlsx
1551
1590
  - test/regression/xlsx_files/autofilter07.xlsx
1591
+ - test/regression/xlsx_files/button01.xlsx
1592
+ - test/regression/xlsx_files/button02.xlsx
1593
+ - test/regression/xlsx_files/button03.xlsx
1594
+ - test/regression/xlsx_files/button04.xlsx
1595
+ - test/regression/xlsx_files/button05.xlsx
1596
+ - test/regression/xlsx_files/button07.xlsm
1552
1597
  - test/regression/xlsx_files/chart_area01.xlsx
1553
1598
  - test/regression/xlsx_files/chart_area02.xlsx
1554
1599
  - test/regression/xlsx_files/chart_area03.xlsx
@@ -1717,6 +1762,8 @@ test_files:
1717
1762
  - test/regression/xlsx_files/escapes04.xlsx
1718
1763
  - test/regression/xlsx_files/escapes05.xlsx
1719
1764
  - test/regression/xlsx_files/escapes06.xlsx
1765
+ - test/regression/xlsx_files/escapes07.xlsx
1766
+ - test/regression/xlsx_files/escapes08.xlsx
1720
1767
  - test/regression/xlsx_files/filehandle01.xlsx
1721
1768
  - test/regression/xlsx_files/fit_to_pages01.xlsx
1722
1769
  - test/regression/xlsx_files/fit_to_pages02.xlsx
@@ -1841,6 +1888,11 @@ test_files:
1841
1888
  - test/regression/xlsx_files/table13.xlsx
1842
1889
  - test/regression/xlsx_files/table14.xlsx
1843
1890
  - test/regression/xlsx_files/vbaProject01.bin
1891
+ - test/regression/xlsx_files/vbaProject02.bin
1892
+ - test/regression/xlsx_files/vml01.xlsx
1893
+ - test/regression/xlsx_files/vml02.xlsx
1894
+ - test/regression/xlsx_files/vml03.xlsx
1895
+ - test/regression/xlsx_files/vml04.xlsx
1844
1896
  - test/test_delete_files.rb
1845
1897
  - test/test_example_match.rb
1846
1898
  - test/test_xml_writer_simple.rb