writeexcel 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +26 -31
- data/examples/a_simple.rb +42 -42
- data/examples/{autofilters.rb → autofilter.rb} +264 -266
- data/examples/bigfile.rb +29 -0
- data/examples/chart_area.rb +120 -0
- data/examples/chart_bar.rb +119 -0
- data/examples/chart_column.rb +119 -0
- data/examples/chart_line.rb +119 -0
- data/examples/chart_pie.rb +107 -0
- data/examples/chart_scatter.rb +120 -0
- data/examples/chart_stock.rb +147 -0
- data/examples/copyformat.rb +51 -51
- data/examples/data_validate.rb +278 -278
- data/examples/date_time.rb +86 -86
- data/examples/defined_name.rb +31 -0
- data/examples/demo.rb +120 -118
- data/examples/diag_border.rb +35 -35
- data/examples/formats.rb +489 -489
- data/examples/header.rb +136 -136
- data/examples/hidden.rb +28 -28
- data/examples/hyperlink.rb +42 -42
- data/examples/images.rb +52 -52
- data/examples/merge1.rb +39 -39
- data/examples/merge2.rb +44 -44
- data/examples/merge3.rb +65 -65
- data/examples/merge4.rb +82 -82
- data/examples/merge5.rb +79 -79
- data/examples/properties.rb +33 -0
- data/examples/properties_jp.rb +32 -0
- data/examples/protection.rb +46 -46
- data/examples/regions.rb +52 -52
- data/examples/repeat.rb +42 -42
- data/examples/stats.rb +75 -75
- data/examples/stocks.rb +80 -80
- data/examples/tab_colors.rb +30 -30
- data/examples/write_arrays.rb +82 -0
- data/lib/writeexcel.rb +1134 -18
- data/lib/writeexcel/biffwriter.rb +273 -260
- data/lib/writeexcel/chart.rb +2306 -217
- data/lib/writeexcel/charts/area.rb +152 -0
- data/lib/writeexcel/charts/bar.rb +177 -0
- data/lib/writeexcel/charts/column.rb +156 -0
- data/lib/writeexcel/charts/external.rb +61 -0
- data/lib/writeexcel/charts/line.rb +152 -0
- data/lib/writeexcel/charts/pie.rb +169 -0
- data/lib/writeexcel/charts/scatter.rb +192 -0
- data/lib/writeexcel/charts/stock.rb +211 -0
- data/lib/writeexcel/excelformulaparser.rb +208 -195
- data/lib/writeexcel/format.rb +1697 -1108
- data/lib/writeexcel/formula.rb +1050 -986
- data/lib/writeexcel/olewriter.rb +322 -322
- data/lib/writeexcel/properties.rb +251 -250
- data/lib/writeexcel/storage_lite.rb +968 -0
- data/lib/writeexcel/workbook.rb +3294 -2630
- data/lib/writeexcel/worksheet.rb +9012 -6377
- data/test/excelfile/Chart1.xls +0 -0
- data/test/excelfile/Chart2.xls +0 -0
- data/test/excelfile/Chart3.xls +0 -0
- data/test/excelfile/Chart4.xls +0 -0
- data/test/excelfile/Chart5.xls +0 -0
- data/test/perl_output/Chart1.xls.data +0 -0
- data/test/perl_output/Chart2.xls.data +0 -0
- data/test/perl_output/Chart3.xls.data +0 -0
- data/test/perl_output/Chart4.xls.data +0 -0
- data/test/perl_output/Chart5.xls.data +0 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/autofilter.xls +0 -0
- data/test/perl_output/chart_area.xls +0 -0
- data/test/perl_output/chart_bar.xls +0 -0
- data/test/perl_output/chart_column.xls +0 -0
- data/test/perl_output/chart_line.xls +0 -0
- data/test/perl_output/data_validate.xls +0 -0
- data/test/perl_output/date_time.xls +0 -0
- data/test/perl_output/demo.xls +0 -0
- data/test/perl_output/demo101.bin +0 -0
- data/test/perl_output/demo201.bin +0 -0
- data/test/perl_output/demo301.bin +0 -0
- data/test/perl_output/demo401.bin +0 -0
- data/test/perl_output/demo501.bin +0 -0
- data/test/perl_output/diag_border.xls +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hyperlink.xls +0 -0
- data/test/perl_output/images.xls +0 -0
- data/test/perl_output/merge1.xls +0 -0
- data/test/perl_output/merge2.xls +0 -0
- data/test/perl_output/merge3.xls +0 -0
- data/test/perl_output/merge4.xls +0 -0
- data/test/perl_output/merge5.xls +0 -0
- data/test/perl_output/protection.xls +0 -0
- data/test/perl_output/regions.xls +0 -0
- data/test/perl_output/stats.xls +0 -0
- data/test/perl_output/stocks.xls +0 -0
- data/test/perl_output/tab_colors.xls +0 -0
- data/test/perl_output/unicode_cyrillic.xls +0 -0
- data/test/perl_output/workbook1.xls +0 -0
- data/test/perl_output/workbook2.xls +0 -0
- data/test/tc_all.rb +32 -31
- data/test/tc_biff.rb +104 -104
- data/test/tc_chart.rb +22 -22
- data/test/tc_example_match.rb +1944 -1280
- data/test/tc_format.rb +1254 -1267
- data/test/tc_formula.rb +63 -63
- data/test/tc_ole.rb +110 -110
- data/test/tc_storage_lite.rb +149 -0
- data/test/tc_workbook.rb +140 -115
- data/test/tc_worksheet.rb +115 -115
- data/test/test_00_IEEE_double.rb +14 -14
- data/test/test_01_add_worksheet.rb +12 -12
- data/test/test_02_merge_formats.rb +58 -58
- data/test/test_04_dimensions.rb +397 -397
- data/test/test_05_rows.rb +182 -182
- data/test/test_06_extsst.rb +80 -80
- data/test/test_11_date_time.rb +484 -484
- data/test/test_12_date_only.rb +506 -506
- data/test/test_13_date_seconds.rb +486 -486
- data/test/test_21_escher.rb +642 -629
- data/test/test_22_mso_drawing_group.rb +750 -739
- data/test/test_23_note.rb +78 -78
- data/test/test_24_txo.rb +80 -80
- data/test/test_25_position_object.rb +82 -0
- data/test/test_26_autofilter.rb +327 -327
- data/test/test_27_autofilter.rb +144 -144
- data/test/test_28_autofilter.rb +174 -174
- data/test/test_29_process_jpg.rb +681 -131
- data/test/test_30_validation_dval.rb +82 -82
- data/test/test_31_validation_dv_strings.rb +131 -131
- data/test/test_32_validation_dv_formula.rb +211 -211
- data/test/test_40_property_types.rb +191 -191
- data/test/test_41_properties.rb +238 -238
- data/test/test_42_set_properties.rb +442 -419
- data/test/test_50_name_stored.rb +305 -0
- data/test/test_51_name_print_area.rb +363 -0
- data/test/test_52_name_print_titles.rb +460 -0
- data/test/test_53_autofilter.rb +209 -0
- data/test/test_60_chart_generic.rb +576 -0
- data/test/test_61_chart_subclasses.rb +97 -0
- data/test/test_62_chart_formats.rb +270 -0
- data/test/test_63_chart_area_formats.rb +647 -0
- data/test/test_chartex.rb +35 -0
- data/test/ts_all.rb +46 -34
- data/writeexcel.gemspec +18 -0
- data/writeexcel.rdoc +583 -0
- metadata +162 -108
data/examples/date_time.rb
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
|
3
|
-
###############################################################################
|
4
|
-
#
|
5
|
-
#
|
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 =
|
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
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
worksheet.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
worksheet.write('
|
66
|
-
worksheet.write('
|
67
|
-
worksheet.write('
|
68
|
-
worksheet.
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
worksheet.write('
|
81
|
-
worksheet.write('
|
82
|
-
worksheet.write('
|
83
|
-
worksheet.write('
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
worksheet.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
#
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
#
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
data/examples/diag_border.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
|
3
|
-
##############################################################################
|
4
|
-
#
|
5
|
-
# A simple formatting example using
|
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 =
|
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
|