writeexcel 0.1.0 → 0.3.0

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 (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
@@ -1,86 +1,86 @@
1
- #!/usr/bin/ruby -w
2
-
3
- ###############################################################################
4
- #
5
- # Spreadsheet::WriteExcel example of writing dates and times using the
6
- # write_date_time() Worksheet method.
7
- #
8
- # reverse('©'), August 2004, 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("date_time.xls")
19
- worksheet = workbook.add_worksheet
20
- bold = workbook.add_format(:bold => 1)
21
-
22
- # Expand the first column so that the date is visible.
23
- worksheet.set_column("A:B", 30)
24
-
25
- # Write the column headers
26
- worksheet.write('A1', 'Formatted date', bold)
27
- worksheet.write('B1', 'Format', bold)
28
-
29
- # Examples date and time formats. In the output file compare how changing
30
- # the format codes change the appearance of the date.
31
- #
32
- date_formats = [
33
- 'dd/mm/yy',
34
- 'mm/dd/yy',
35
- '',
36
- 'd mm yy',
37
- 'dd mm yy',
38
- '',
39
- 'dd m yy',
40
- 'dd mm yy',
41
- 'dd mmm yy',
42
- 'dd mmmm yy',
43
- '',
44
- 'dd mm y',
45
- 'dd mm yyy',
46
- 'dd mm yyyy',
47
- '',
48
- 'd mmmm yyyy',
49
- '',
50
- 'dd/mm/yy',
51
- 'dd/mm/yy hh:mm',
52
- 'dd/mm/yy hh:mm:ss',
53
- 'dd/mm/yy hh:mm:ss.000',
54
- '',
55
- 'hh:mm',
56
- 'hh:mm:ss',
57
- 'hh:mm:ss.000',
58
- ]
59
-
60
- # Write the same date and time using each of the above formats. The empty
61
- # string formats create a blank line to make the example clearer.
62
- #
63
- row = 0
64
- date_formats.each do |date_format|
65
- row += 1
66
- next if date_format == ''
67
-
68
- # Create a format for the date or time.
69
- format = workbook.add_format(
70
- :num_format => date_format,
71
- :align => 'left'
72
- )
73
-
74
- # Write the same date using different formats.
75
- worksheet.write_date_time(row, 0, '2004-08-01T12:30:45.123', format)
76
- worksheet.write(row, 1, date_format)
77
- end
78
-
79
- # The following is an example of an invalid date. It is written as a string instead
80
- # of a number. This is also Excel's default behaviour.
81
- #
82
- row += 2
83
- worksheet.write_date_time(row, 0, '2004-13-01T12:30:45.123')
84
- worksheet.write(row, 1, 'Invalid date. Written as string.', bold)
85
-
86
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ ###############################################################################
4
+ #
5
+ # WriteExcel example of writing dates and times using the
6
+ # write_date_time() Worksheet method.
7
+ #
8
+ # reverse('©'), August 2004, 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("date_time.xls")
19
+ worksheet = workbook.add_worksheet
20
+ bold = workbook.add_format(:bold => 1)
21
+
22
+ # Expand the first column so that the date is visible.
23
+ worksheet.set_column("A:B", 30)
24
+
25
+ # Write the column headers
26
+ worksheet.write('A1', 'Formatted date', bold)
27
+ worksheet.write('B1', 'Format', bold)
28
+
29
+ # Examples date and time formats. In the output file compare how changing
30
+ # the format codes change the appearance of the date.
31
+ #
32
+ date_formats = [
33
+ 'dd/mm/yy',
34
+ 'mm/dd/yy',
35
+ '',
36
+ 'd mm yy',
37
+ 'dd mm yy',
38
+ '',
39
+ 'dd m yy',
40
+ 'dd mm yy',
41
+ 'dd mmm yy',
42
+ 'dd mmmm yy',
43
+ '',
44
+ 'dd mm y',
45
+ 'dd mm yyy',
46
+ 'dd mm yyyy',
47
+ '',
48
+ 'd mmmm yyyy',
49
+ '',
50
+ 'dd/mm/yy',
51
+ 'dd/mm/yy hh:mm',
52
+ 'dd/mm/yy hh:mm:ss',
53
+ 'dd/mm/yy hh:mm:ss.000',
54
+ '',
55
+ 'hh:mm',
56
+ 'hh:mm:ss',
57
+ 'hh:mm:ss.000',
58
+ ]
59
+
60
+ # Write the same date and time using each of the above formats. The empty
61
+ # string formats create a blank line to make the example clearer.
62
+ #
63
+ row = 0
64
+ date_formats.each do |date_format|
65
+ row += 1
66
+ next if date_format == ''
67
+
68
+ # Create a format for the date or time.
69
+ format = workbook.add_format(
70
+ :num_format => date_format,
71
+ :align => 'left'
72
+ )
73
+
74
+ # Write the same date using different formats.
75
+ worksheet.write_date_time(row, 0, '2004-08-01T12:30:45.123', format)
76
+ worksheet.write(row, 1, date_format)
77
+ end
78
+
79
+ # The following is an example of an invalid date. It is written as a string instead
80
+ # of a number. This is also Excel's default behaviour.
81
+ #
82
+ row += 2
83
+ worksheet.write_date_time(row, 0, '2004-13-01T12:30:45.123')
84
+ worksheet.write(row, 1, 'Invalid date. Written as string.', bold)
85
+
86
+ workbook.close
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ ###############################################################################
4
+ #
5
+ # Example of how to create defined names in a WriteExcel file.
6
+ #
7
+ # reverse('ゥ'), September 2008, John McNamara, jmcnamara@cpan.org
8
+ #
9
+ # original written in Perl by John McNamara
10
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
11
+ #
12
+
13
+ require 'writeexcel'
14
+
15
+ workbook = WriteExcel.new('defined_name.xls')
16
+ worksheet1 = workbook.add_worksheet
17
+ worksheet2 = workbook.add_worksheet
18
+
19
+ workbook.define_name('Exchange_rate', '=0.96')
20
+ workbook.define_name('Sales', '=Sheet1!$G$1:$H$10')
21
+ workbook.define_name('Sheet2!Sales', '=Sheet2!$G$1:$G$10')
22
+
23
+ workbook.sheets.each do |worksheet|
24
+ worksheet.set_column('A:A', 45)
25
+ worksheet.write('A2', 'This worksheet contains some defined names,')
26
+ worksheet.write('A3', 'See the Insert -> Name -> Define dialog.')
27
+ end
28
+
29
+ worksheet1.write('A4', '=Exchange_rate')
30
+
31
+ workbook.close
data/examples/demo.rb CHANGED
@@ -1,118 +1,120 @@
1
- #!/usr/bin/ruby -w
2
-
3
- #######################################################################
4
- #
5
- # Demo of some of the features of Spreadsheet::WriteExcel.
6
- # Used to create the project screenshot for Freshmeat.
7
- #
8
- #
9
- # reverse('©'), October 2001, 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
- workbook = Spreadsheet::WriteExcel.new("demo.xls")
19
- worksheet = workbook.add_worksheet('Demo')
20
- worksheet2 = workbook.add_worksheet('Another sheet')
21
- worksheet3 = workbook.add_worksheet('And another')
22
-
23
- bold = workbook.add_format(:bold => 1)
24
-
25
- #######################################################################
26
- #
27
- # Write a general heading
28
- #
29
- worksheet.set_column('A:A', 36, bold)
30
- worksheet.set_column('B:B', 20 )
31
- worksheet.set_row(0, 40 )
32
-
33
- heading = workbook.add_format(
34
- :bold => 1,
35
- :color => 'blue',
36
- :size => 16,
37
- :merge => 1,
38
- :align => 'vcenter'
39
- )
40
-
41
- headings = ['Features of Spreadsheet::WriteExcel', '']
42
- worksheet.write_row('A1', headings, heading)
43
-
44
-
45
- #######################################################################
46
- #
47
- # Some text examples
48
- #
49
- text_format = workbook.add_format(
50
- :bold => 1,
51
- :italic => 1,
52
- :color => 'red',
53
- :size => 18,
54
- :font =>'Lucida Calligraphy'
55
- )
56
-
57
- # A phrase in Cyrillic
58
- unicode = [
59
- "042d0442043e002004440440043004370430002004"+
60
- "3d043000200440044304410441043a043e043c0021"
61
- ].pack('H*')
62
-
63
- worksheet.write('A2', "Text")
64
- worksheet.write('B2', "Hello Excel")
65
- worksheet.write('A3', "Formatted text")
66
- worksheet.write('B3', "Hello Excel", text_format)
67
- worksheet.write('A4', "Unicode text")
68
- worksheet.write_utf16be_string('B4', unicode)
69
-
70
-
71
- #######################################################################
72
- #
73
- # Some numeric examples
74
- #
75
- num1_format = workbook.add_format(:num_format => '$#,##0.00')
76
- num2_format = workbook.add_format(:num_format => ' d mmmm yyy')
77
-
78
- worksheet.write('A5', "Numbers")
79
- worksheet.write('B5', 1234.56)
80
- worksheet.write('A6', "Formatted numbers")
81
- worksheet.write('B6', 1234.56, num1_format)
82
- worksheet.write('A7', "Formatted numbers")
83
- worksheet.write('B7', 37257, num2_format)
84
-
85
-
86
- #######################################################################
87
- #
88
- # Formulae
89
- #
90
- worksheet.set_selection('B8')
91
- worksheet.write('A8', 'Formulas and functions, "=SIN(PI()/4)"')
92
- worksheet.write('B8', '=SIN(PI()/4)')
93
-
94
-
95
- #######################################################################
96
- #
97
- # Hyperlinks
98
- #
99
- worksheet.write('A9', "Hyperlinks")
100
- worksheet.write('B9', 'http://www.perl.com/' )
101
-
102
-
103
- #######################################################################
104
- #
105
- # Images
106
- #
107
- worksheet.write('A10', "Images")
108
- worksheet.insert_image('B10', 'republic.png', 16, 8)
109
-
110
-
111
- #######################################################################
112
- #
113
- # Misc
114
- #
115
- worksheet.write('A18', "Page/printer setup")
116
- worksheet.write('A19', "Multiple worksheets")
117
-
118
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ #######################################################################
4
+ #
5
+ # Demo of some of the features of WriteExcel.
6
+ # Used to create the project screenshot for Freshmeat.
7
+ #
8
+ #
9
+ # reverse('©'), October 2001, 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
+ # $debug = true
19
+
20
+ workbook = WriteExcel.new("demo.xls")
21
+ worksheet = workbook.add_worksheet('Demo')
22
+ worksheet2 = workbook.add_worksheet('Another sheet')
23
+ worksheet3 = workbook.add_worksheet('And another')
24
+
25
+ bold = workbook.add_format(:bold => 1)
26
+
27
+ #######################################################################
28
+ #
29
+ # Write a general heading
30
+ #
31
+ worksheet.set_column('A:A', 36, bold)
32
+ worksheet.set_column('B:B', 20 )
33
+ worksheet.set_row(0, 40 )
34
+
35
+ heading = workbook.add_format(
36
+ :bold => 1,
37
+ :color => 'blue',
38
+ :size => 16,
39
+ :merge => 1,
40
+ :align => 'vcenter'
41
+ )
42
+
43
+ headings = ['Features of Spreadsheet::WriteExcel', '']
44
+ worksheet.write_row('A1', headings, heading)
45
+
46
+
47
+ #######################################################################
48
+ #
49
+ # Some text examples
50
+ #
51
+ text_format = workbook.add_format(
52
+ :bold => 1,
53
+ :italic => 1,
54
+ :color => 'red',
55
+ :size => 18,
56
+ :font =>'Lucida Calligraphy'
57
+ )
58
+
59
+ # A phrase in Cyrillic
60
+ unicode = [
61
+ "042d0442043e002004440440043004370430002004"+
62
+ "3d043000200440044304410441043a043e043c0021"
63
+ ].pack('H*')
64
+
65
+ worksheet.write('A2', "Text")
66
+ worksheet.write('B2', "Hello Excel")
67
+ worksheet.write('A3', "Formatted text")
68
+ worksheet.write('B3', "Hello Excel", text_format)
69
+ worksheet.write('A4', "Unicode text")
70
+ worksheet.write_utf16be_string('B4', unicode)
71
+
72
+
73
+ #######################################################################
74
+ #
75
+ # Some numeric examples
76
+ #
77
+ num1_format = workbook.add_format(:num_format => '$#,##0.00')
78
+ num2_format = workbook.add_format(:num_format => ' d mmmm yyy')
79
+
80
+ worksheet.write('A5', "Numbers")
81
+ worksheet.write('B5', 1234.56)
82
+ worksheet.write('A6', "Formatted numbers")
83
+ worksheet.write('B6', 1234.56, num1_format)
84
+ worksheet.write('A7', "Formatted numbers")
85
+ worksheet.write('B7', 37257, num2_format)
86
+
87
+
88
+ #######################################################################
89
+ #
90
+ # Formulae
91
+ #
92
+ worksheet.set_selection('B8')
93
+ worksheet.write('A8', 'Formulas and functions, "=SIN(PI()/4)"')
94
+ worksheet.write('B8', '=SIN(PI()/4)')
95
+
96
+
97
+ #######################################################################
98
+ #
99
+ # Hyperlinks
100
+ #
101
+ worksheet.write('A9', "Hyperlinks")
102
+ worksheet.write('B9', 'http://www.perl.com/' )
103
+
104
+
105
+ #######################################################################
106
+ #
107
+ # Images
108
+ #
109
+ worksheet.write('A10', "Images")
110
+ worksheet.insert_image('B10', 'republic.png', 16, 8)
111
+
112
+
113
+ #######################################################################
114
+ #
115
+ # Misc
116
+ #
117
+ worksheet.write('A18', "Page/printer setup")
118
+ worksheet.write('A19', "Multiple worksheets")
119
+
120
+ workbook.close
@@ -1,35 +1,35 @@
1
- #!/usr/bin/ruby -w
2
-
3
- ##############################################################################
4
- #
5
- # A simple formatting example using Spreadsheet::WriteExcel.
6
- #
7
- # This program demonstrates the diagonal border cell format.
8
- #
9
- # reverse('©'), May 2004, 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
- workbook = Spreadsheet::WriteExcel.new('diag_border.xls')
19
- worksheet = workbook.add_worksheet
20
-
21
- format1 = workbook.add_format(:diag_type => 1)
22
- format2 = workbook.add_format(:diag_type => 2)
23
- format3 = workbook.add_format(:diag_type => 3)
24
- format4 = workbook.add_format(
25
- :diag_type => 3,
26
- :diag_border => 7,
27
- :diag_color => 'red'
28
- )
29
-
30
- worksheet.write('B3', 'Text', format1)
31
- worksheet.write('B6', 'Text', format2)
32
- worksheet.write('B9', 'Text', format3)
33
- worksheet.write('B12', 'Text', format4)
34
-
35
- workbook.close
1
+ #!/usr/bin/ruby -w
2
+
3
+ ##############################################################################
4
+ #
5
+ # A simple formatting example using WriteExcel.
6
+ #
7
+ # This program demonstrates the diagonal border cell format.
8
+ #
9
+ # reverse('©'), May 2004, 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
+ workbook = WriteExcel.new('diag_border.xls')
19
+ worksheet = workbook.add_worksheet
20
+
21
+ format1 = workbook.add_format(:diag_type => 1)
22
+ format2 = workbook.add_format(:diag_type => 2)
23
+ format3 = workbook.add_format(:diag_type => 3)
24
+ format4 = workbook.add_format(
25
+ :diag_type => 3,
26
+ :diag_border => 7,
27
+ :diag_color => 'red'
28
+ )
29
+
30
+ worksheet.write('B3', 'Text', format1)
31
+ worksheet.write('B6', 'Text', format2)
32
+ worksheet.write('B9', 'Text', format3)
33
+ worksheet.write('B12', 'Text', format4)
34
+
35
+ workbook.close