write_xlsx 0.75.0 → 0.76.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +4 -0
  3. data/Gemfile +8 -2
  4. data/README.md +4 -2
  5. data/lib/write_xlsx/chart/axis.rb +69 -96
  6. data/lib/write_xlsx/chart/bar.rb +18 -21
  7. data/lib/write_xlsx/chart/caption.rb +1 -1
  8. data/lib/write_xlsx/chart/column.rb +1 -5
  9. data/lib/write_xlsx/chart/line.rb +2 -16
  10. data/lib/write_xlsx/chart/pie.rb +18 -40
  11. data/lib/write_xlsx/chart/radar.rb +2 -5
  12. data/lib/write_xlsx/chart/scatter.rb +24 -32
  13. data/lib/write_xlsx/chart/series.rb +218 -236
  14. data/lib/write_xlsx/chart/stock.rb +15 -27
  15. data/lib/write_xlsx/chart.rb +303 -392
  16. data/lib/write_xlsx/chartsheet.rb +22 -20
  17. data/lib/write_xlsx/colors.rb +9 -15
  18. data/lib/write_xlsx/drawing.rb +26 -28
  19. data/lib/write_xlsx/format.rb +15 -15
  20. data/lib/write_xlsx/package/comments.rb +1 -1
  21. data/lib/write_xlsx/package/conditional_format.rb +8 -8
  22. data/lib/write_xlsx/package/relationships.rb +4 -15
  23. data/lib/write_xlsx/package/styles.rb +9 -16
  24. data/lib/write_xlsx/shape.rb +1 -15
  25. data/lib/write_xlsx/sparkline.rb +1 -1
  26. data/lib/write_xlsx/utility.rb +69 -13
  27. data/lib/write_xlsx/version.rb +1 -1
  28. data/lib/write_xlsx/workbook.rb +19 -7
  29. data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
  30. data/lib/write_xlsx/worksheet/hyperlink.rb +39 -37
  31. data/lib/write_xlsx/worksheet.rb +44 -72
  32. data/lib/write_xlsx/zip_file_utils.rb +99 -0
  33. data/test/chart/test_add_series.rb +5 -5
  34. data/test/chart/test_write_d_lbls.rb +1 -1
  35. data/test/chart/test_write_major_gridlines.rb +1 -1
  36. data/test/chart/test_write_marker.rb +1 -1
  37. data/test/chart/test_write_number_format.rb +1 -1
  38. data/test/helper.rb +7 -4
  39. data/test/regression/klt.csv +4 -0
  40. data/test/regression/test_chart_column07.rb +44 -0
  41. data/test/regression/test_chart_column08.rb +46 -0
  42. data/test/regression/test_chart_date01.rb +57 -0
  43. data/test/regression/test_chart_date02.rb +59 -0
  44. data/test/regression/test_chart_date03.rb +59 -0
  45. data/test/regression/test_chart_date04.rb +61 -0
  46. data/test/regression/test_chart_stock01.rb +1 -6
  47. data/test/regression/test_chart_title02.rb +44 -0
  48. data/test/regression/test_escapes01.rb +1 -1
  49. data/test/regression/test_escapes02.rb +1 -1
  50. data/test/regression/test_escapes03.rb +1 -1
  51. data/test/regression/test_escapes04.rb +1 -1
  52. data/test/regression/test_escapes05.rb +1 -1
  53. data/test/regression/test_escapes06.rb +1 -1
  54. data/test/regression/test_escapes07.rb +1 -1
  55. data/test/regression/test_escapes08.rb +1 -1
  56. data/test/regression/test_set_column09.rb +31 -0
  57. data/test/regression/test_shared_strings_encoding.rb +103 -0
  58. data/test/regression/xlsx_files/chart_column07.xlsx +0 -0
  59. data/test/regression/xlsx_files/chart_column08.xlsx +0 -0
  60. data/test/regression/xlsx_files/chart_date01.xlsx +0 -0
  61. data/test/regression/xlsx_files/chart_date02.xlsx +0 -0
  62. data/test/regression/xlsx_files/chart_date03.xlsx +0 -0
  63. data/test/regression/xlsx_files/chart_date04.xlsx +0 -0
  64. data/test/regression/xlsx_files/chart_title02.xlsx +0 -0
  65. data/test/regression/xlsx_files/set_column09.xlsx +0 -0
  66. data/test/regression/xlsx_files/shared_strings_encoding.xlsx +0 -0
  67. data/test/worksheet/test_write_hyperlink.rb +10 -15
  68. data/write_xlsx.gemspec +0 -3
  69. metadata +48 -39
  70. data/test/worksheet/test_set_column.rb +0 -25
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartColumn08 < 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_column08
14
+ @xlsx = 'chart_column08.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'column', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [68809856, 68811392])
21
+
22
+ data = [
23
+ [ 1, 2, 3, 4, 5 ],
24
+ [ 2, 4, 6, 8, 10 ],
25
+ [ 3, 6, 9, 12, 15 ]
26
+ ]
27
+
28
+ worksheet.write('A1', data)
29
+
30
+ chart.add_series(
31
+ :categories => '=(Sheet1!$A$1:$A$2,Sheet1!$A$4:$A$5)',
32
+ :values => '=(Sheet1!$B$1:$B$2,Sheet1!$B$4:$B$5)',
33
+ :categories_data => [1, 2, 4, 5],
34
+ :values_data => [2, 4, 8, 10]
35
+ )
36
+
37
+ worksheet.insert_chart('E9', chart)
38
+
39
+ workbook.close
40
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx),
41
+ @xlsx,
42
+ nil,
43
+ nil
44
+ )
45
+ end
46
+ end
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDate01 < 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_date01
14
+ @xlsx = 'chart_date01.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'line', :embedded => 1)
18
+ date_format = workbook.add_format(:num_format => 14)
19
+
20
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
21
+ chart.instance_variable_set(:@axis_ids, [73655040, 73907584])
22
+
23
+ worksheet.set_column('A:A', 12)
24
+
25
+ dates = [
26
+ '2013-01-01T', '2013-01-02T', '2013-01-03T', '2013-01-04T',
27
+ '2013-01-05T', '2013-01-06T', '2013-01-07T', '2013-01-08T',
28
+ '2013-01-09T', '2013-01-10T'
29
+ ]
30
+
31
+ data = [10, 30, 20, 40, 20, 60, 50, 40, 30, 30]
32
+
33
+ dates.each_with_index do |date_time, row|
34
+ worksheet.write_date_time(row, 0, date_time, date_format)
35
+ worksheet.write(row, 1, data[row])
36
+ end
37
+
38
+ chart.add_series(
39
+ :categories => '=Sheet1!$A$1:$A$10',
40
+ :values => '=Sheet1!$B$1:$B$10'
41
+ )
42
+
43
+ chart.set_x_axis(
44
+ :num_format => 'dd/mm/yyyy',
45
+ :num_format_linked => 1,
46
+ :date_axis => 1
47
+ )
48
+
49
+ worksheet.insert_chart('E9', chart)
50
+
51
+ workbook.close
52
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
53
+ nil,
54
+ {'xl/charts/chart1.xml' => ['<c:formatCode']}
55
+ )
56
+ end
57
+ end
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDate02 < 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_date02
14
+ @xlsx = 'chart_date02.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'line', :embedded => 1)
18
+ date_format = workbook.add_format(:num_format => 14)
19
+
20
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
21
+ chart.instance_variable_set(:@axis_ids, [55112064, 55115136])
22
+
23
+ worksheet.set_column('A:A', 12)
24
+
25
+ dates = [
26
+ '2013-01-01T', '2013-01-02T', '2013-01-03T', '2013-01-04T',
27
+ '2013-01-05T', '2013-01-06T', '2013-01-07T', '2013-01-08T',
28
+ '2013-01-09T', '2013-01-10T'
29
+ ]
30
+
31
+ data = [10, 30, 20, 40, 20, 60, 50, 40, 30, 30]
32
+
33
+ dates.each_with_index do |date_time, row|
34
+ worksheet.write_date_time(row, 0, date_time, date_format)
35
+ worksheet.write(row, 1, data[row])
36
+ end
37
+
38
+ chart.add_series(
39
+ :categories => '=Sheet1!$A$1:$A$10',
40
+ :values => '=Sheet1!$B$1:$B$10'
41
+ )
42
+
43
+ chart.set_x_axis(
44
+ :date_axis => 1,
45
+ :min => worksheet.convert_date_time('2013-01-02T'),
46
+ :max => worksheet.convert_date_time('2013-01-09T'),
47
+ :num_format => 'dd/mm/yyyy',
48
+ :num_format_linked => 1,
49
+ )
50
+
51
+ worksheet.insert_chart('E9', chart)
52
+
53
+ workbook.close
54
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
55
+ nil,
56
+ {'xl/charts/chart1.xml' => ['<c:formatCode']}
57
+ )
58
+ end
59
+ end
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDate03 < 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_date03
14
+ @xlsx = 'chart_date03.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'line', :embedded => 1)
18
+ date_format = workbook.add_format(:num_format => 14)
19
+
20
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
21
+ chart.instance_variable_set(:@axis_ids, [51761152, 51762688])
22
+
23
+ worksheet.set_column('A:A', 12)
24
+
25
+ dates = [
26
+ '2013-01-01T', '2013-01-02T', '2013-01-03T', '2013-01-04T',
27
+ '2013-01-05T', '2013-01-06T', '2013-01-07T', '2013-01-08T',
28
+ '2013-01-09T', '2013-01-10T'
29
+ ]
30
+
31
+ data = [10, 30, 20, 40, 20, 60, 50, 40, 30, 30]
32
+
33
+ dates.each_with_index do |date_time, row|
34
+ worksheet.write_date_time(row, 0, date_time, date_format)
35
+ worksheet.write(row, 1, data[row])
36
+ end
37
+
38
+ chart.add_series(
39
+ :categories => '=Sheet1!$A$1:$A$10',
40
+ :values => '=Sheet1!$B$1:$B$10'
41
+ )
42
+
43
+ chart.set_x_axis(
44
+ :date_axis => 1,
45
+ :minor_unit => 1,
46
+ :major_unit => 1,
47
+ :num_format => 'dd/mm/yyyy',
48
+ :num_format_linked => 1,
49
+ )
50
+
51
+ worksheet.insert_chart('E9', chart)
52
+
53
+ workbook.close
54
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
55
+ nil,
56
+ {'xl/charts/chart1.xml' => ['<c:formatCode']}
57
+ )
58
+ end
59
+ end
@@ -0,0 +1,61 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartDate04 < 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_date04
14
+ @xlsx = 'chart_date04.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'line', :embedded => 1)
18
+ date_format = workbook.add_format(:num_format => 14)
19
+
20
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
21
+ chart.instance_variable_set(:@axis_ids, [51761152, 51762688])
22
+
23
+ worksheet.set_column('A:A', 12)
24
+
25
+ dates = [
26
+ '2013-01-01T', '2013-01-02T', '2013-01-03T', '2013-01-04T',
27
+ '2013-01-05T', '2013-01-06T', '2013-01-07T', '2013-01-08T',
28
+ '2013-01-09T', '2013-01-10T'
29
+ ]
30
+
31
+ data = [10, 30, 20, 40, 20, 60, 50, 40, 30, 30]
32
+
33
+ dates.each_with_index do |date_time, row|
34
+ worksheet.write_date_time(row, 0, date_time, date_format)
35
+ worksheet.write(row, 1, data[row])
36
+ end
37
+
38
+ chart.add_series(
39
+ :categories => '=Sheet1!$A$1:$A$10',
40
+ :values => '=Sheet1!$B$1:$B$10'
41
+ )
42
+
43
+ chart.set_x_axis(
44
+ :date_axis => 1,
45
+ :minor_unit => 1,
46
+ :minor_unit_type => 'months',
47
+ :major_unit => 1,
48
+ :major_unit_type => 'years',
49
+ :num_format => 'dd/mm/yyyy',
50
+ :num_format_linked => 1,
51
+ )
52
+
53
+ worksheet.insert_chart('E9', chart)
54
+
55
+ workbook.close
56
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx,
57
+ nil,
58
+ {'xl/charts/chart1.xml' => ['<c:formatCode']}
59
+ )
60
+ end
61
+ end
@@ -61,12 +61,7 @@ class TestRegressionChartStock01 < Test::Unit::TestCase
61
61
  File.join(@regression_output, @xlsx),
62
62
  @xlsx,
63
63
  nil,
64
- {
65
- 'xl/charts/chart1.xml' => [ '<c:formatCode', ],
66
-
67
- # Ignore the workbookView.
68
- 'xl/workbook.xml' => ['<workbookView']
69
- }
64
+ {'xl/charts/chart1.xml' => [ '<c:formatCode', ]}
70
65
  )
71
66
  end
72
67
  end
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionChartTitle02 < 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_title02
14
+ @xlsx = 'chart_title02.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+ chart = workbook.add_chart(:type => 'column', :embedded => 1)
18
+
19
+ # For testing, copy the randomly generated axis ids in the target xlsx file.
20
+ chart.instance_variable_set(:@axis_ids, [73655040, 73656576 ])
21
+
22
+ data = [
23
+ [1, 2, 3, 4, 5],
24
+ [2, 4, 6, 8, 10],
25
+ [3, 6, 9, 12, 15]
26
+ ]
27
+
28
+ worksheet.write('A1', data)
29
+
30
+ chart.add_series(:values => '=Sheet1!$A$1:$A$5')
31
+
32
+ chart.set_title(:name => 'Title!')
33
+
34
+ worksheet.insert_chart('E9', chart)
35
+
36
+ workbook.close
37
+ compare_xlsx_for_regression(
38
+ File.join(@regression_output, @xlsx),
39
+ @xlsx,
40
+ nil,
41
+ nil
42
+ )
43
+ end
44
+ end
@@ -10,7 +10,7 @@ class TestRegressionEscapes01 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes01
13
+ def test_escapes01
14
14
  @xlsx = 'escapes01.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet('5&4')
@@ -10,7 +10,7 @@ class TestRegressionEscapes02 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes02
13
+ def test_escapes02
14
14
  @xlsx = 'escapes02.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet
@@ -10,7 +10,7 @@ class TestRegressionEscapes03 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes03
13
+ def test_escapes03
14
14
  @xlsx = 'escapes03.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet
@@ -10,7 +10,7 @@ class TestRegressionEscapes04 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes04
13
+ def test_escapes04
14
14
  @xlsx = 'escapes04.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet
@@ -10,7 +10,7 @@ class TestRegressionEscapes05 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes05
13
+ def test_escapes05
14
14
  @xlsx = 'escapes05.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet1 = workbook.add_worksheet('Start')
@@ -10,7 +10,7 @@ class TestRegressionEscapes06 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes06
13
+ def test_escapes06
14
14
  @xlsx = 'escapes06.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet
@@ -10,7 +10,7 @@ class TestRegressionEscapes07 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes07
13
+ def test_escapes07
14
14
  @xlsx = 'escapes07.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet
@@ -10,7 +10,7 @@ class TestRegressionEscapes08 < Test::Unit::TestCase
10
10
  File.delete(@xlsx) if File.exist?(@xlsx)
11
11
  end
12
12
 
13
- def test_chart_escapes08
13
+ def test_escapes08
14
14
  @xlsx = 'escapes08.xlsx'
15
15
  workbook = WriteXLSX.new(@xlsx)
16
16
  worksheet = workbook.add_worksheet
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+
4
+ class TestRegressionSetColumn09 < 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_set_column09
14
+ @xlsx = 'set_column09.xlsx'
15
+ workbook = WriteXLSX.new(@xlsx)
16
+ worksheet = workbook.add_worksheet
17
+
18
+ # Test the order and overwriting of columns.
19
+ worksheet.set_column('A:A', 100)
20
+ worksheet.set_column('F:H', 8)
21
+ worksheet.set_column('C:D', 12)
22
+ worksheet.set_column('A:A', 10)
23
+ worksheet.set_column('XFD:XFD', 5)
24
+ worksheet.set_column('ZZ:ZZ', 3)
25
+
26
+ workbook.close
27
+
28
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
29
+
30
+ end
31
+ end
@@ -0,0 +1,103 @@
1
+ # -*- coding: iso-8859-8 -*-
2
+
3
+ require 'helper'
4
+
5
+ class TestRegressionSharedStringsEncoding < Test::Unit::TestCase
6
+ def setup
7
+ setup_dir_var
8
+ @f = File.open(File.join(@test_dir, 'regression', 'klt.csv'), "r:iso-8859-8")
9
+ end
10
+
11
+ def teardown
12
+ File.delete(@xlsx) if File.exist?(@xlsx)
13
+ end
14
+
15
+ def test_shared_strings_encoding
16
+ sizes = [10, 10, 18, 10, 18, 18, 12, 16, 16, 25,
17
+ 18, 36, 60, 16, 16, 16, 18, 16, 16, 22,
18
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
19
+ 14, 14, 14, 14, 14, 14]
20
+
21
+ # input_file = ARGV[0]
22
+ # output_file = ARGV[1]
23
+
24
+ # coding: ISO-8859-8
25
+ # Encoding.default_external = Encoding.find("ISO-8859-8")
26
+
27
+ # define an array to hold the Sikum records
28
+
29
+ # loop through each record in the csv file, adding
30
+ # each record to our array.
31
+ #f = File.open(input_file, "r")
32
+ @xlsx = 'shared_strings_encoding.xlsx'
33
+ workbook = WriteXLSX.new(@xlsx)
34
+ heading1 = workbook.add_format(:align => 'center', :bold => 1 , :size => 12 , :color => 'blue', :bg_color => 27)
35
+ heading2 = workbook.add_format(:align => 'center', :bold => 1 , :size => 12 , :color => 'blue', :bg_color => 'silver')
36
+ format1 = workbook.add_format(:align => 'right', :color => 'blue', :bg_color => 9 )
37
+ format11 = workbook.add_format(:align => 'right', :color => 'blue', :bg_color => 9 )
38
+ format11.set_num_format('0.00')
39
+ format3 = workbook.add_format(:align => 'right', :color => 'red', :bg_color => 9 )
40
+ worksheet = workbook.add_worksheet
41
+ worksheet.right_to_left
42
+
43
+ i=0
44
+
45
+ @f.each_line { |line|
46
+ words = line.split(',')
47
+ if i == 0 then
48
+ for j in 0..words.size-1
49
+
50
+ word = words[j].to_s.gsub(/"/," ")
51
+ word = word.gsub(/\n/, "" )
52
+ word = word.gsub(/\r/, "" )
53
+
54
+ # worksheet.merge_range( 'A1:L1', word.force_encoding('iso-8859-8').encode("UTF-8"), heading1)
55
+ worksheet.merge_range( 'A1:L1', word, heading1)
56
+ end
57
+ elsif i == 1 then
58
+ for j in 0..words.size-1
59
+
60
+ word = words[j].to_s.gsub(/"/," ")
61
+ word = word.gsub(/\n/, "" )
62
+ word = word.gsub(/\r/, "" )
63
+
64
+ worksheet.set_column(j,0,sizes[j])
65
+ # worksheet.write( i, j, word.force_encoding('iso-8859-8').encode("UTF-8"), heading2)
66
+ worksheet.write( i, j, word, heading2)
67
+ end
68
+ else
69
+
70
+ heara = words[11].to_s
71
+ for j in 0..words.size-1
72
+
73
+ jj=j
74
+ word = words[j].to_s.gsub("_"," ")
75
+ word = word.gsub(/\n/, "" )
76
+ word = word.gsub(/\r/, "" )
77
+ word = word.lstrip.rstrip
78
+
79
+ if heara.include?('abcdefghijklml') then
80
+ # worksheet.write( i, jj, word.force_encoding('iso-8859-8').encode("UTF-8"), format3)
81
+ worksheet.write( i, jj, word, format3)
82
+ else
83
+ # worksheet.write( i, jj, word.force_encoding('iso-8859-8').encode("UTF-8"), format1)
84
+ worksheet.write( i, jj, word, format1)
85
+ end
86
+ end
87
+ end
88
+ i = i+1
89
+ }
90
+
91
+ workbook.close
92
+ compare_xlsx_for_regression(File.join(@regression_output, @xlsx), @xlsx)
93
+ end
94
+
95
+ def input_file
96
+ <<EOS
97
+ ����� ������� ������ ������
98
+ ����� ����,��� ����,�� ����,���� ����,���� ����,��,���� ������,����,����,����,�����,����
99
+ 01/11/2012,09:04:20,_���� , 131, 39977777,����������� ,00171044973, , ,�� ����� , ,����� ����/����� �� ���� ������
100
+ 01/11/2012,09:04:24,_���� , 131, 36888865,������� ,00171081635,���� ������ ,���� ������ ,�� ����� , ,
101
+ EOS
102
+ end
103
+ end
@@ -9,36 +9,31 @@ class TestWriteHyperlink < Test::Unit::TestCase
9
9
  @worksheet = @workbook.add_worksheet('')
10
10
  end
11
11
 
12
- def test_write_hyperlink_external
12
+ def test_attributes
13
13
  hyperlink = Writexlsx::Worksheet::Hyperlink.factory('')
14
- @worksheet.__send__('write_hyperlink_external', hyperlink, 0, 0, 1)
15
- result = @worksheet.instance_variable_get(:@writer).string
16
- expected = '<hyperlink ref="A1" r:id="rId1"/>'
14
+ result = hyperlink.attributes(0, 0, 1)
15
+ expected = [ ['ref', 'A1'], ['r:id', 'rId1']]
17
16
  assert_equal(expected, result)
18
17
  end
19
18
 
20
19
  def test_write_hyperlink_internal_sheet2
21
20
  hyperlink = Writexlsx::Worksheet::Hyperlink.factory('internal:Sheet2!A1', 'Sheet2!A1')
22
- @worksheet.__send__('write_hyperlink_internal', hyperlink, 0, 0)
23
- result = @worksheet.instance_variable_get(:@writer).string
24
- expected = '<hyperlink ref="A1" location="Sheet2!A1" display="Sheet2!A1"/>'
21
+ result = hyperlink.attributes(0, 0)
22
+ expected = [%w(ref A1), %w(location Sheet2!A1), %w(display Sheet2!A1)]
25
23
  assert_equal(expected, result)
26
24
  end
27
25
 
28
26
  def test_write_hyperlink_internal_quoted_sheet
29
27
  hyperlink = Writexlsx::Worksheet::Hyperlink.factory("internal:'Data Sheet'!D5", "'Data Sheet'!D5")
30
- @worksheet.__send__('write_hyperlink_internal', hyperlink, 4, 0)
31
- result = @worksheet.instance_variable_get(:@writer).string
32
- expected = %q{<hyperlink ref="A5" location="'Data Sheet'!D5" display="'Data Sheet'!D5"/>}
28
+ result = hyperlink.attributes(4, 0)
29
+ expected = [%w(ref A5), ["location", "'Data Sheet'!D5"], ["display", "'Data Sheet'!D5"]]
33
30
  assert_equal(expected, result)
34
31
  end
35
32
 
36
33
  def test_write_hyperlink_internal_tooltip
37
- hyperlink = Writexlsx::Worksheet::Hyperlink.factory('internal:Sheet2!A1', 'Sheet2!A1')
38
- hyperlink.tip = 'Screen Tip 1'
39
- @worksheet.__send__('write_hyperlink_internal', hyperlink, 17, 0)
40
- result = @worksheet.instance_variable_get(:@writer).string
41
- expected = '<hyperlink ref="A18" location="Sheet2!A1" tooltip="Screen Tip 1" display="Sheet2!A1"/>'
34
+ hyperlink = Writexlsx::Worksheet::Hyperlink.factory('internal:Sheet2!A1', 'Sheet2!A1', 'Screen Tip 1')
35
+ result = hyperlink.attributes(17, 0)
36
+ expected = [%w(ref A18), %w(location Sheet2!A1), ["tooltip", "Screen Tip 1"], %w(display Sheet2!A1)]
42
37
  assert_equal(expected, result)
43
38
  end
44
39
  end
data/write_xlsx.gemspec CHANGED
@@ -22,7 +22,4 @@ Gem::Specification.new do |gem|
22
22
  "README.md",
23
23
  "Changes"
24
24
  ]
25
-
26
- gem.add_runtime_dependency(%q<rubyzip>, [">=1.0.0"])
27
- gem.add_development_dependency(%q<simplecov>) if RUBY_VERSION >= "1.9"
28
25
  end