writeexcel 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/README +26 -31
  2. data/examples/a_simple.rb +42 -42
  3. data/examples/{autofilters.rb → autofilter.rb} +264 -266
  4. data/examples/bigfile.rb +29 -0
  5. data/examples/chart_area.rb +120 -0
  6. data/examples/chart_bar.rb +119 -0
  7. data/examples/chart_column.rb +119 -0
  8. data/examples/chart_line.rb +119 -0
  9. data/examples/chart_pie.rb +107 -0
  10. data/examples/chart_scatter.rb +120 -0
  11. data/examples/chart_stock.rb +147 -0
  12. data/examples/copyformat.rb +51 -51
  13. data/examples/data_validate.rb +278 -278
  14. data/examples/date_time.rb +86 -86
  15. data/examples/defined_name.rb +31 -0
  16. data/examples/demo.rb +120 -118
  17. data/examples/diag_border.rb +35 -35
  18. data/examples/formats.rb +489 -489
  19. data/examples/header.rb +136 -136
  20. data/examples/hidden.rb +28 -28
  21. data/examples/hyperlink.rb +42 -42
  22. data/examples/images.rb +52 -52
  23. data/examples/merge1.rb +39 -39
  24. data/examples/merge2.rb +44 -44
  25. data/examples/merge3.rb +65 -65
  26. data/examples/merge4.rb +82 -82
  27. data/examples/merge5.rb +79 -79
  28. data/examples/properties.rb +33 -0
  29. data/examples/properties_jp.rb +32 -0
  30. data/examples/protection.rb +46 -46
  31. data/examples/regions.rb +52 -52
  32. data/examples/repeat.rb +42 -42
  33. data/examples/stats.rb +75 -75
  34. data/examples/stocks.rb +80 -80
  35. data/examples/tab_colors.rb +30 -30
  36. data/examples/write_arrays.rb +82 -0
  37. data/lib/writeexcel.rb +1134 -18
  38. data/lib/writeexcel/biffwriter.rb +273 -260
  39. data/lib/writeexcel/chart.rb +2306 -217
  40. data/lib/writeexcel/charts/area.rb +152 -0
  41. data/lib/writeexcel/charts/bar.rb +177 -0
  42. data/lib/writeexcel/charts/column.rb +156 -0
  43. data/lib/writeexcel/charts/external.rb +61 -0
  44. data/lib/writeexcel/charts/line.rb +152 -0
  45. data/lib/writeexcel/charts/pie.rb +169 -0
  46. data/lib/writeexcel/charts/scatter.rb +192 -0
  47. data/lib/writeexcel/charts/stock.rb +211 -0
  48. data/lib/writeexcel/excelformulaparser.rb +208 -195
  49. data/lib/writeexcel/format.rb +1697 -1108
  50. data/lib/writeexcel/formula.rb +1050 -986
  51. data/lib/writeexcel/olewriter.rb +322 -322
  52. data/lib/writeexcel/properties.rb +251 -250
  53. data/lib/writeexcel/storage_lite.rb +968 -0
  54. data/lib/writeexcel/workbook.rb +3294 -2630
  55. data/lib/writeexcel/worksheet.rb +9012 -6377
  56. data/test/excelfile/Chart1.xls +0 -0
  57. data/test/excelfile/Chart2.xls +0 -0
  58. data/test/excelfile/Chart3.xls +0 -0
  59. data/test/excelfile/Chart4.xls +0 -0
  60. data/test/excelfile/Chart5.xls +0 -0
  61. data/test/perl_output/Chart1.xls.data +0 -0
  62. data/test/perl_output/Chart2.xls.data +0 -0
  63. data/test/perl_output/Chart3.xls.data +0 -0
  64. data/test/perl_output/Chart4.xls.data +0 -0
  65. data/test/perl_output/Chart5.xls.data +0 -0
  66. data/test/perl_output/a_simple.xls +0 -0
  67. data/test/perl_output/autofilter.xls +0 -0
  68. data/test/perl_output/chart_area.xls +0 -0
  69. data/test/perl_output/chart_bar.xls +0 -0
  70. data/test/perl_output/chart_column.xls +0 -0
  71. data/test/perl_output/chart_line.xls +0 -0
  72. data/test/perl_output/data_validate.xls +0 -0
  73. data/test/perl_output/date_time.xls +0 -0
  74. data/test/perl_output/demo.xls +0 -0
  75. data/test/perl_output/demo101.bin +0 -0
  76. data/test/perl_output/demo201.bin +0 -0
  77. data/test/perl_output/demo301.bin +0 -0
  78. data/test/perl_output/demo401.bin +0 -0
  79. data/test/perl_output/demo501.bin +0 -0
  80. data/test/perl_output/diag_border.xls +0 -0
  81. data/test/perl_output/headers.xls +0 -0
  82. data/test/perl_output/hyperlink.xls +0 -0
  83. data/test/perl_output/images.xls +0 -0
  84. data/test/perl_output/merge1.xls +0 -0
  85. data/test/perl_output/merge2.xls +0 -0
  86. data/test/perl_output/merge3.xls +0 -0
  87. data/test/perl_output/merge4.xls +0 -0
  88. data/test/perl_output/merge5.xls +0 -0
  89. data/test/perl_output/protection.xls +0 -0
  90. data/test/perl_output/regions.xls +0 -0
  91. data/test/perl_output/stats.xls +0 -0
  92. data/test/perl_output/stocks.xls +0 -0
  93. data/test/perl_output/tab_colors.xls +0 -0
  94. data/test/perl_output/unicode_cyrillic.xls +0 -0
  95. data/test/perl_output/workbook1.xls +0 -0
  96. data/test/perl_output/workbook2.xls +0 -0
  97. data/test/tc_all.rb +32 -31
  98. data/test/tc_biff.rb +104 -104
  99. data/test/tc_chart.rb +22 -22
  100. data/test/tc_example_match.rb +1944 -1280
  101. data/test/tc_format.rb +1254 -1267
  102. data/test/tc_formula.rb +63 -63
  103. data/test/tc_ole.rb +110 -110
  104. data/test/tc_storage_lite.rb +149 -0
  105. data/test/tc_workbook.rb +140 -115
  106. data/test/tc_worksheet.rb +115 -115
  107. data/test/test_00_IEEE_double.rb +14 -14
  108. data/test/test_01_add_worksheet.rb +12 -12
  109. data/test/test_02_merge_formats.rb +58 -58
  110. data/test/test_04_dimensions.rb +397 -397
  111. data/test/test_05_rows.rb +182 -182
  112. data/test/test_06_extsst.rb +80 -80
  113. data/test/test_11_date_time.rb +484 -484
  114. data/test/test_12_date_only.rb +506 -506
  115. data/test/test_13_date_seconds.rb +486 -486
  116. data/test/test_21_escher.rb +642 -629
  117. data/test/test_22_mso_drawing_group.rb +750 -739
  118. data/test/test_23_note.rb +78 -78
  119. data/test/test_24_txo.rb +80 -80
  120. data/test/test_25_position_object.rb +82 -0
  121. data/test/test_26_autofilter.rb +327 -327
  122. data/test/test_27_autofilter.rb +144 -144
  123. data/test/test_28_autofilter.rb +174 -174
  124. data/test/test_29_process_jpg.rb +681 -131
  125. data/test/test_30_validation_dval.rb +82 -82
  126. data/test/test_31_validation_dv_strings.rb +131 -131
  127. data/test/test_32_validation_dv_formula.rb +211 -211
  128. data/test/test_40_property_types.rb +191 -191
  129. data/test/test_41_properties.rb +238 -238
  130. data/test/test_42_set_properties.rb +442 -419
  131. data/test/test_50_name_stored.rb +305 -0
  132. data/test/test_51_name_print_area.rb +363 -0
  133. data/test/test_52_name_print_titles.rb +460 -0
  134. data/test/test_53_autofilter.rb +209 -0
  135. data/test/test_60_chart_generic.rb +576 -0
  136. data/test/test_61_chart_subclasses.rb +97 -0
  137. data/test/test_62_chart_formats.rb +270 -0
  138. data/test/test_63_chart_area_formats.rb +647 -0
  139. data/test/test_chartex.rb +35 -0
  140. data/test/ts_all.rb +46 -34
  141. data/writeexcel.gemspec +18 -0
  142. data/writeexcel.rdoc +583 -0
  143. metadata +162 -108
data/examples/merge1.rb CHANGED
@@ -1,39 +1,39 @@
1
- #!/usr/bin/ruby -w
2
-
3
- ###############################################################################
4
- #
5
- # Simple example of merging cells using the Spreadsheet::WriteExcel module.
6
- #
7
- # This merges three cells using the "Centre Across Selection" alignment.
8
- # This was the Excel 5 method of achieving a merge. Use the merge_range()
9
- # worksheet method instead. See merge3.pl - merge6.pl.
10
- #
11
- # reverse('©'), August 2002, John McNamara, jmcnamara@cpan.org
12
- #
13
- # original written in Perl by John McNamara
14
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
15
- #
16
-
17
- require 'rubygems'
18
- require 'writeexcel'
19
-
20
- # Create a new workbook and add a worksheet
21
- workbook = Spreadsheet::WriteExcel.new('merge1.xls')
22
- worksheet = workbook.add_worksheet
23
-
24
-
25
- # Increase the cell size of the merged cells to highlight the formatting.
26
- worksheet.set_column('B:D', 20)
27
- worksheet.set_row(2, 30)
28
-
29
-
30
- # Create a merge format
31
- format = workbook.add_format(:center_across => 1)
32
-
33
-
34
- # Only one cell should contain text, the others should be blank.
35
- worksheet.write(2, 1, "Center across selection", format)
36
- worksheet.write_blank(2, 2, format)
37
- worksheet.write_blank(2, 3, format)
38
-
39
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ ###############################################################################
4
+ #
5
+ # Simple example of merging cells using the WriteExcel module.
6
+ #
7
+ # This merges three cells using the "Centre Across Selection" alignment.
8
+ # This was the Excel 5 method of achieving a merge. Use the merge_range()
9
+ # worksheet method instead. See merge3.pl - merge6.pl.
10
+ #
11
+ # reverse('©'), August 2002, John McNamara, jmcnamara@cpan.org
12
+ #
13
+ # original written in Perl by John McNamara
14
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
15
+ #
16
+
17
+ require 'rubygems'
18
+ require 'writeexcel'
19
+
20
+ # Create a new workbook and add a worksheet
21
+ workbook = WriteExcel.new('merge1.xls')
22
+ worksheet = workbook.add_worksheet
23
+
24
+
25
+ # Increase the cell size of the merged cells to highlight the formatting.
26
+ worksheet.set_column('B:D', 20)
27
+ worksheet.set_row(2, 30)
28
+
29
+
30
+ # Create a merge format
31
+ format = workbook.add_format(:center_across => 1)
32
+
33
+
34
+ # Only one cell should contain text, the others should be blank.
35
+ worksheet.write(2, 1, "Center across selection", format)
36
+ worksheet.write_blank(2, 2, format)
37
+ worksheet.write_blank(2, 3, format)
38
+
39
+ workbook.close
data/examples/merge2.rb CHANGED
@@ -1,44 +1,44 @@
1
- #!/usr/bin/ruby -w
2
-
3
- ###############################################################################
4
- #
5
- # Simple example of merging cells using the Spreadsheet::WriteExcel module
6
- #
7
- # This merges two formatted cells using the "Centre Across Selection" alignment.
8
- # This was the Excel 5 method of achieving a merge. Use the merge_range()
9
- # worksheet method instead. See merge3.pl - merge6.pl.
10
- #
11
- # reverse('©'), August 2002, John McNamara, jmcnamara@cpan.org
12
- #
13
- # original written in Perl by John McNamara
14
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
15
- #
16
-
17
- require 'rubygems'
18
- require 'writeexcel'
19
-
20
- # Create a new workbook and add a worksheet
21
- workbook = Spreadsheet::WriteExcel.new("merge2.xls")
22
- worksheet = workbook.add_worksheet
23
-
24
- # Increase the cell size of the merged cells to highlight the formatting.
25
- worksheet.set_column(1, 2, 30)
26
- worksheet.set_row(2, 40)
27
-
28
- # Create a merged format
29
- format = workbook.add_format(
30
- :center_across => 1,
31
- :bold => 1,
32
- :size => 15,
33
- :pattern => 1,
34
- :border => 6,
35
- :color => 'white',
36
- :fg_color => 'green',
37
- :border_color => 'yellow',
38
- :align => 'vcenter'
39
- )
40
-
41
- # Only one cell should contain text, the others should be blank.
42
- worksheet.write(2, 1, "Center across selection", format)
43
- worksheet.write_blank(2, 2, format)
44
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ ###############################################################################
4
+ #
5
+ # Simple example of merging cells using the WriteExcel module
6
+ #
7
+ # This merges two formatted cells using the "Centre Across Selection" alignment.
8
+ # This was the Excel 5 method of achieving a merge. Use the merge_range()
9
+ # worksheet method instead. See merge3.pl - merge6.pl.
10
+ #
11
+ # reverse('©'), August 2002, John McNamara, jmcnamara@cpan.org
12
+ #
13
+ # original written in Perl by John McNamara
14
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
15
+ #
16
+
17
+ require 'rubygems'
18
+ require 'writeexcel'
19
+
20
+ # Create a new workbook and add a worksheet
21
+ workbook = WriteExcel.new("merge2.xls")
22
+ worksheet = workbook.add_worksheet
23
+
24
+ # Increase the cell size of the merged cells to highlight the formatting.
25
+ worksheet.set_column(1, 2, 30)
26
+ worksheet.set_row(2, 40)
27
+
28
+ # Create a merged format
29
+ format = workbook.add_format(
30
+ :center_across => 1,
31
+ :bold => 1,
32
+ :size => 15,
33
+ :pattern => 1,
34
+ :border => 6,
35
+ :color => 'white',
36
+ :fg_color => 'green',
37
+ :border_color => 'yellow',
38
+ :align => 'vcenter'
39
+ )
40
+
41
+ # Only one cell should contain text, the others should be blank.
42
+ worksheet.write(2, 1, "Center across selection", format)
43
+ worksheet.write_blank(2, 2, format)
44
+ workbook.close
data/examples/merge3.rb CHANGED
@@ -1,65 +1,65 @@
1
- #!/usr/bin/ruby -w
2
-
3
- ###############################################################################
4
- #
5
- # Example of how to use Spreadsheet::WriteExcel to write a hyperlink in a
6
- # merged cell. There are two options write_url_range() with a standard merge
7
- # format or merge_range().
8
- #
9
- # reverse('©'), September 2002, John McNamara, jmcnamara@cpan.org
10
- #
11
- # original written in Perl by John McNamara
12
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
13
- #
14
-
15
- require 'rubygems'
16
- require 'writeexcel'
17
-
18
- # Create a new workbook and add a worksheet
19
- workbook = Spreadsheet::WriteExcel.new("merge3.xls")
20
- worksheet = workbook.add_worksheet()
21
-
22
- # Increase the cell size of the merged cells to highlight the formatting.
23
- [1, 3,6,7].each { |row| worksheet.set_row(row, 30) }
24
- worksheet.set_column('B:D', 20)
25
-
26
- bp=1
27
- ###############################################################################
28
- #
29
- # Example 1: Merge cells containing a hyperlink using write_url_range()
30
- # and the standard Excel 5+ merge property.
31
- #
32
- format1 = workbook.add_format(
33
- :center_across => 1,
34
- :border => 1,
35
- :underline => 1,
36
- :color => 'blue'
37
- )
38
-
39
- # Write the cells to be merged
40
- worksheet.write_url_range('B2:D2', 'http://www.perl.com', format1)
41
- worksheet.write_blank('C2', format1)
42
- worksheet.write_blank('D2', format1)
43
-
44
-
45
-
46
- ###############################################################################
47
- #
48
- # Example 2: Merge cells containing a hyperlink using merge_range().
49
- #
50
- format2 = workbook.add_format(
51
- :border => 1,
52
- :underline => 1,
53
- :color => 'blue',
54
- :align => 'center',
55
- :valign => 'vcenter'
56
- )
57
-
58
- # Merge 3 cells
59
- worksheet.merge_range('B4:D4', 'http://www.perl.com', format2)
60
-
61
-
62
- # Merge 3 cells over two rows
63
- worksheet.merge_range('B7:D8', 'http://www.perl.com', format2)
64
-
65
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ ###############################################################################
4
+ #
5
+ # Example of how to use WriteExcel to write a hyperlink in a
6
+ # merged cell. There are two options write_url_range() with a standard merge
7
+ # format or merge_range().
8
+ #
9
+ # reverse('©'), September 2002, John McNamara, jmcnamara@cpan.org
10
+ #
11
+ # original written in Perl by John McNamara
12
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
13
+ #
14
+
15
+ require 'rubygems'
16
+ require 'writeexcel'
17
+
18
+ # Create a new workbook and add a worksheet
19
+ workbook = WriteExcel.new("merge3.xls")
20
+ worksheet = workbook.add_worksheet()
21
+
22
+ # Increase the cell size of the merged cells to highlight the formatting.
23
+ [1, 3,6,7].each { |row| worksheet.set_row(row, 30) }
24
+ worksheet.set_column('B:D', 20)
25
+
26
+ bp=1
27
+ ###############################################################################
28
+ #
29
+ # Example 1: Merge cells containing a hyperlink using write_url_range()
30
+ # and the standard Excel 5+ merge property.
31
+ #
32
+ format1 = workbook.add_format(
33
+ :center_across => 1,
34
+ :border => 1,
35
+ :underline => 1,
36
+ :color => 'blue'
37
+ )
38
+
39
+ # Write the cells to be merged
40
+ worksheet.write_url_range('B2:D2', 'http://www.perl.com', format1)
41
+ worksheet.write_blank('C2', format1)
42
+ worksheet.write_blank('D2', format1)
43
+
44
+
45
+
46
+ ###############################################################################
47
+ #
48
+ # Example 2: Merge cells containing a hyperlink using merge_range().
49
+ #
50
+ format2 = workbook.add_format(
51
+ :border => 1,
52
+ :underline => 1,
53
+ :color => 'blue',
54
+ :align => 'center',
55
+ :valign => 'vcenter'
56
+ )
57
+
58
+ # Merge 3 cells
59
+ worksheet.merge_range('B4:D4', 'http://www.perl.com', format2)
60
+
61
+
62
+ # Merge 3 cells over two rows
63
+ worksheet.merge_range('B7:D8', 'http://www.perl.com', format2)
64
+
65
+ workbook.close
data/examples/merge4.rb CHANGED
@@ -1,82 +1,82 @@
1
- #!/usr/bin/ruby -w
2
-
3
- ###############################################################################
4
- #
5
- # Example of how to use the Spreadsheet::WriteExcel merge_range() workbook
6
- # method with complex formatting.
7
- #
8
- # reverse('©'), September 2002, John McNamara, jmcnamara@cpan.org
9
- #
10
- # original written in Perl by John McNamara
11
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
12
- #
13
-
14
- require 'rubygems'
15
- require 'writeexcel'
16
-
17
- # Create a new workbook and add a worksheet
18
- workbook = Spreadsheet::WriteExcel.new('merge4.xls')
19
- worksheet = workbook.add_worksheet
20
-
21
- # Increase the cell size of the merged cells to highlight the formatting.
22
- (1..11).each { |row| worksheet.set_row(row, 30) }
23
- worksheet.set_column('B:D', 20)
24
-
25
- ###############################################################################
26
- #
27
- # Example 1: Text centered vertically and horizontally
28
- #
29
- format1 = workbook.add_format(
30
- :border => 6,
31
- :bold => 1,
32
- :color => 'red',
33
- :valign => 'vcenter',
34
- :align => 'center'
35
- )
36
-
37
- worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
38
-
39
-
40
- ###############################################################################
41
- #
42
- # Example 2: Text aligned to the top and left
43
- #
44
- format2 = workbook.add_format(
45
- :border => 6,
46
- :bold => 1,
47
- :color => 'red',
48
- :valign => 'top',
49
- :align => 'left'
50
- )
51
-
52
- worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
53
-
54
- ###############################################################################
55
- #
56
- # Example 3: Text aligned to the bottom and right
57
- #
58
- format3 = workbook.add_format(
59
- :border => 6,
60
- :bold => 1,
61
- :color => 'red',
62
- :valign => 'bottom',
63
- :align => 'right'
64
- )
65
-
66
- worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
67
-
68
- ###############################################################################
69
- #
70
- # Example 4: Text justified (i.e. wrapped) in the cell
71
- #
72
- format4 = workbook.add_format(
73
- :border => 6,
74
- :bold => 1,
75
- :color => 'red',
76
- :valign => 'top',
77
- :align => 'justify'
78
- )
79
-
80
- worksheet.merge_range('B11:D12', 'Justified: '+'so on and '*18, format4)
81
-
82
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ ###############################################################################
4
+ #
5
+ # Example of how to use the WriteExcel merge_range() workbook
6
+ # method with complex formatting.
7
+ #
8
+ # reverse('©'), September 2002, John McNamara, jmcnamara@cpan.org
9
+ #
10
+ # original written in Perl by John McNamara
11
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
12
+ #
13
+
14
+ require 'rubygems'
15
+ require 'writeexcel'
16
+
17
+ # Create a new workbook and add a worksheet
18
+ workbook = WriteExcel.new('merge4.xls')
19
+ worksheet = workbook.add_worksheet
20
+
21
+ # Increase the cell size of the merged cells to highlight the formatting.
22
+ (1..11).each { |row| worksheet.set_row(row, 30) }
23
+ worksheet.set_column('B:D', 20)
24
+
25
+ ###############################################################################
26
+ #
27
+ # Example 1: Text centered vertically and horizontally
28
+ #
29
+ format1 = workbook.add_format(
30
+ :border => 6,
31
+ :bold => 1,
32
+ :color => 'red',
33
+ :valign => 'vcenter',
34
+ :align => 'center'
35
+ )
36
+
37
+ worksheet.merge_range('B2:D3', 'Vertical and horizontal', format1)
38
+
39
+
40
+ ###############################################################################
41
+ #
42
+ # Example 2: Text aligned to the top and left
43
+ #
44
+ format2 = workbook.add_format(
45
+ :border => 6,
46
+ :bold => 1,
47
+ :color => 'red',
48
+ :valign => 'top',
49
+ :align => 'left'
50
+ )
51
+
52
+ worksheet.merge_range('B5:D6', 'Aligned to the top and left', format2)
53
+
54
+ ###############################################################################
55
+ #
56
+ # Example 3: Text aligned to the bottom and right
57
+ #
58
+ format3 = workbook.add_format(
59
+ :border => 6,
60
+ :bold => 1,
61
+ :color => 'red',
62
+ :valign => 'bottom',
63
+ :align => 'right'
64
+ )
65
+
66
+ worksheet.merge_range('B8:D9', 'Aligned to the bottom and right', format3)
67
+
68
+ ###############################################################################
69
+ #
70
+ # Example 4: Text justified (i.e. wrapped) in the cell
71
+ #
72
+ format4 = workbook.add_format(
73
+ :border => 6,
74
+ :bold => 1,
75
+ :color => 'red',
76
+ :valign => 'top',
77
+ :align => 'justify'
78
+ )
79
+
80
+ worksheet.merge_range('B11:D12', 'Justified: '+'so on and '*18, format4)
81
+
82
+ workbook.close