surpass 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +0 -0
- data/README.txt +133 -0
- data/Rakefile +35 -0
- data/examples/big-16mb.rb +25 -0
- data/examples/big-random-strings.rb +28 -0
- data/examples/blanks.rb +34 -0
- data/examples/col_width.rb +16 -0
- data/examples/dates.rb +31 -0
- data/examples/format.rb +23 -0
- data/examples/hello-world.rb +9 -0
- data/examples/image.rb +10 -0
- data/examples/merged.rb +36 -0
- data/examples/merged0.rb +27 -0
- data/examples/merged1.rb +99 -0
- data/examples/num_formats.rb +55 -0
- data/examples/numbers.rb +24 -0
- data/examples/outline.rb +110 -0
- data/examples/panes.rb +48 -0
- data/examples/protection.rb +132 -0
- data/examples/python.bmp +0 -0
- data/examples/row_styles.rb +16 -0
- data/examples/row_styles_empty.rb +15 -0
- data/examples/set_cell_and_range_style.rb +12 -0
- data/examples/wrapped-text.rb +13 -0
- data/examples/write_arrays.rb +16 -0
- data/examples/ws_props.rb +80 -0
- data/lib/biff_record.rb +2168 -0
- data/lib/bitmap.rb +218 -0
- data/lib/cell.rb +214 -0
- data/lib/chart.rb +16 -0
- data/lib/column.rb +40 -0
- data/lib/document.rb +406 -0
- data/lib/excel_formula.rb +6 -0
- data/lib/excel_magic.rb +1013 -0
- data/lib/formatting.rb +554 -0
- data/lib/row.rb +137 -0
- data/lib/style.rb +179 -0
- data/lib/surpass.rb +51 -0
- data/lib/utilities.rb +86 -0
- data/lib/workbook.rb +206 -0
- data/lib/worksheet.rb +561 -0
- data/spec/biff_record_spec.rb +268 -0
- data/spec/cell_spec.rb +56 -0
- data/spec/data/random-strings.txt +10000 -0
- data/spec/document_spec.rb +168 -0
- data/spec/excel_formula_spec.rb +0 -0
- data/spec/formatting_spec.rb +53 -0
- data/spec/reference/P-0508-0000507647-3280-5298.xls +0 -0
- data/spec/reference/all-cell-styles.bin +0 -0
- data/spec/reference/all-number-formats.bin +0 -0
- data/spec/reference/all-styles.bin +0 -0
- data/spec/reference/mini.xls +0 -0
- data/spec/row_spec.rb +19 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/style_spec.rb +89 -0
- data/spec/utilities_spec.rb +57 -0
- data/spec/workbook_spec.rb +48 -0
- data/spec/worksheet_spec.rb +0 -0
- data/stats/cloc.txt +8 -0
- data/stats/rcov.txt +0 -0
- data/stats/specdoc.txt +158 -0
- data/surpass-manual-0-0-3.pdf +0 -0
- data/surpass.gemspec +34 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/excel.rake +6 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/metrics.rake +42 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +144 -0
data/History.txt
ADDED
File without changes
|
data/README.txt
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
surpass
|
2
|
+
by Ana Nelson, based on original Python code by Roman V. Kiseliov
|
3
|
+
http://launchpad.net/surpass
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Surpass is writing (and eventually reading) excel workbooks in pure Ruby. Surpass is based on xlwt (and pyExcelerator).
|
8
|
+
|
9
|
+
== REQUIREMENTS:
|
10
|
+
|
11
|
+
Ruby 1.8.6 (C or JRuby)
|
12
|
+
|
13
|
+
== INSTALL:
|
14
|
+
|
15
|
+
bones installation:
|
16
|
+
sudo rake gem:install
|
17
|
+
|
18
|
+
== Documentation
|
19
|
+
|
20
|
+
See surpass-manual.pdf
|
21
|
+
|
22
|
+
== LICENSE:
|
23
|
+
|
24
|
+
Portions Copyright (c) 2008-9, Ana Nelson
|
25
|
+
All rights reserved.
|
26
|
+
|
27
|
+
Redistribution and use in source and binary forms, with or without
|
28
|
+
modification, are permitted provided that the following conditions are
|
29
|
+
met:
|
30
|
+
|
31
|
+
* Redistributions of source code must retain the above copyright
|
32
|
+
notice, this list of conditions and the following disclaimer.
|
33
|
+
|
34
|
+
* Redistributions in binary form must reproduce the above copyright
|
35
|
+
notice, this list of conditions and the following disclaimer in the
|
36
|
+
documentation and/or other materials provided with the distribution.
|
37
|
+
|
38
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
39
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
40
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
41
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
42
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
43
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
44
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
45
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
46
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
47
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
48
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
Surpass is a Ruby port of Python projects xlwt and pyExcelerator, whose
|
53
|
+
licenses are below.
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
Portions copyright © 2007, Stephen John Machin, Lingfo Pty Ltd
|
58
|
+
All rights reserved.
|
59
|
+
|
60
|
+
Redistribution and use in source and binary forms, with or without
|
61
|
+
modification, are permitted provided that the following conditions are met:
|
62
|
+
|
63
|
+
1. Redistributions of source code must retain the above copyright notice,
|
64
|
+
this list of conditions and the following disclaimer.
|
65
|
+
|
66
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
67
|
+
this list of conditions and the following disclaimer in the documentation
|
68
|
+
and/or other materials provided with the distribution.
|
69
|
+
|
70
|
+
3. None of the names of Stephen John Machin, Lingfo Pty Ltd and any
|
71
|
+
contributors may be used to endorse or promote products derived from this
|
72
|
+
software without specific prior written permission.
|
73
|
+
|
74
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
75
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
76
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
77
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
78
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
79
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
80
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
81
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
82
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
83
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
84
|
+
THE POSSIBILITY OF SUCH DAMAGE.
|
85
|
+
|
86
|
+
|
87
|
+
Copyright (C) 2005 Roman V. Kiseliov
|
88
|
+
All rights reserved.
|
89
|
+
|
90
|
+
Redistribution and use in source and binary forms, with or without
|
91
|
+
modification, are permitted provided that the following conditions
|
92
|
+
are met:
|
93
|
+
|
94
|
+
1. Redistributions of source code must retain the above copyright
|
95
|
+
notice, this list of conditions and the following disclaimer.
|
96
|
+
|
97
|
+
2. Redistributions in binary form must reproduce the above copyright
|
98
|
+
notice, this list of conditions and the following disclaimer in
|
99
|
+
the documentation and/or other materials provided with the
|
100
|
+
distribution.
|
101
|
+
|
102
|
+
3. All advertising materials mentioning features or use of this
|
103
|
+
software must display the following acknowledgment:
|
104
|
+
"This product includes software developed by
|
105
|
+
Roman V. Kiseliov <roman@kiseliov.ru>."
|
106
|
+
|
107
|
+
4. Redistributions of any form whatsoever must retain the following
|
108
|
+
acknowledgment:
|
109
|
+
"This product includes software developed by
|
110
|
+
Roman V. Kiseliov <roman@kiseliov.ru>."
|
111
|
+
|
112
|
+
THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
|
113
|
+
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
114
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
115
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Roman V. Kiseliov OR
|
116
|
+
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
117
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
118
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
119
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
120
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
121
|
+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
122
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
123
|
+
OF THE POSSIBILITY OF SUCH DAMAGE.
|
124
|
+
|
125
|
+
Roman V. Kiseliov
|
126
|
+
Russia
|
127
|
+
Kursk
|
128
|
+
Libknecht St., 4
|
129
|
+
|
130
|
+
+7(0712)56-09-83
|
131
|
+
|
132
|
+
<roman@kiseliov.ru>
|
133
|
+
Subject: pyExcelerator
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bones'
|
7
|
+
Bones.setup
|
8
|
+
rescue LoadError
|
9
|
+
begin
|
10
|
+
load 'tasks/setup.rb'
|
11
|
+
rescue LoadError
|
12
|
+
raise RuntimeError, '### please install the "bones" gem ###'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ensure_in_path 'lib'
|
17
|
+
require 'surpass'
|
18
|
+
|
19
|
+
task :default => 'spec:run'
|
20
|
+
|
21
|
+
PROJ.name = 'surpass'
|
22
|
+
PROJ.authors = 'Ana Nelson'
|
23
|
+
PROJ.email = 'ana@ananelson.com'
|
24
|
+
PROJ.url = 'https://surpass.rubyforge.org'
|
25
|
+
PROJ.version = Surpass::VERSION
|
26
|
+
PROJ.rubyforge.name = 'surpass'
|
27
|
+
|
28
|
+
PROJ.ignore_file = '.bzrignore'
|
29
|
+
|
30
|
+
PROJ.spec.opts << '--color'
|
31
|
+
|
32
|
+
PROJ.exclude = %w{.bzr webby}
|
33
|
+
|
34
|
+
|
35
|
+
PROJ.rdoc.format = 'darkfish'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
s = book.add_sheet('0')
|
6
|
+
|
7
|
+
colcount = 200 + 1
|
8
|
+
rowcount = 6000 + 1
|
9
|
+
|
10
|
+
start = Time.now
|
11
|
+
puts "starting at #{start.to_s}"
|
12
|
+
|
13
|
+
colcount.times do |c|
|
14
|
+
rowcount.times do |r|
|
15
|
+
s.write(r, c, "BIG")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
t = Time.now - start
|
20
|
+
puts "time elapsed (writing data to workbook) #{t.to_s}"
|
21
|
+
|
22
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
23
|
+
|
24
|
+
t = Time.now - start
|
25
|
+
puts "time elapsed (writing workbook to file) #{t.to_s}"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
strings = File.read("spec/data/random-strings.txt").split("\n")
|
5
|
+
|
6
|
+
book = Workbook.new
|
7
|
+
s = book.add_sheet('0')
|
8
|
+
|
9
|
+
colcount = 100 + 1
|
10
|
+
rowcount = 100 + 1
|
11
|
+
|
12
|
+
start = Time.now
|
13
|
+
puts "starting at #{start.to_s}"
|
14
|
+
|
15
|
+
colcount.times do |c|
|
16
|
+
rowcount.times do |r|
|
17
|
+
i = c * rowcount + r
|
18
|
+
s.write(r, c, strings[i])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
t = Time.now - start
|
23
|
+
puts "time elapsed (writing data to workbook) #{t.to_s}"
|
24
|
+
|
25
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
26
|
+
|
27
|
+
t = Time.now - start
|
28
|
+
puts "time elapsed (writing workbook to file) #{t.to_s}"
|
data/examples/blanks.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
font0 = Font.new
|
5
|
+
font0.name = 'Times New Roman'
|
6
|
+
font0.struck_out = true
|
7
|
+
font0.bold = true
|
8
|
+
|
9
|
+
style0 = StyleFormat.new
|
10
|
+
style0.font = font0
|
11
|
+
|
12
|
+
|
13
|
+
book = Workbook.new
|
14
|
+
ws0 = book.add_sheet('0')
|
15
|
+
|
16
|
+
ws0.write(1, 1, 'Test', style0)
|
17
|
+
|
18
|
+
0.upto(0x53) do |i|
|
19
|
+
borders = Borders.new
|
20
|
+
borders.left = i
|
21
|
+
borders.right = i
|
22
|
+
borders.top = i
|
23
|
+
borders.bottom = i
|
24
|
+
|
25
|
+
style = StyleFormat.new
|
26
|
+
style.borders = borders
|
27
|
+
|
28
|
+
ws0.write(i, 2, '', style)
|
29
|
+
ws0.write(i, 3, hex(i), style0)
|
30
|
+
end
|
31
|
+
|
32
|
+
ws0.write_merge(5, 8, 6, 10, "")
|
33
|
+
|
34
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
ws = book.add_sheet('Hey, Dude')
|
6
|
+
|
7
|
+
(6...80).each do |i|
|
8
|
+
fnt = Font.new
|
9
|
+
fnt.height = i*20
|
10
|
+
style = StyleFormat.new
|
11
|
+
style.font = fnt
|
12
|
+
ws.write(1, i, 'Test')
|
13
|
+
ws.set_column_width(i, i)
|
14
|
+
end
|
15
|
+
|
16
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
data/examples/dates.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
ws = book.add_sheet('Hey, Dude')
|
6
|
+
|
7
|
+
formats = [
|
8
|
+
'M/D/YY',
|
9
|
+
'D-MMM-YY',
|
10
|
+
'D-MMM',
|
11
|
+
'MMM-YY',
|
12
|
+
'h:mm AM/PM',
|
13
|
+
'h:mm:ss AM/PM',
|
14
|
+
'h:mm',
|
15
|
+
'h:mm:ss',
|
16
|
+
'M/D/YY h:mm',
|
17
|
+
'mm:ss',
|
18
|
+
'[h]:mm:ss',
|
19
|
+
'mm:ss.0',
|
20
|
+
]
|
21
|
+
|
22
|
+
formats.each_with_index do |f, i|
|
23
|
+
ws.write(i, 0, f)
|
24
|
+
|
25
|
+
style = StyleFormat.new
|
26
|
+
style.number_format_string = f
|
27
|
+
|
28
|
+
ws.write(i, 4, Time.now, style)
|
29
|
+
end
|
30
|
+
|
31
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
data/examples/format.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
style0 = StyleFormat.new(:font_name => 'Times New Roman', :font_struck_out => true, :font_bold => true)
|
5
|
+
|
6
|
+
book = Workbook.new
|
7
|
+
ws0 = book.add_sheet('0')
|
8
|
+
|
9
|
+
ws0.write(1, 1, 'Test', style0)
|
10
|
+
|
11
|
+
(0...0x53).each do |i|
|
12
|
+
style = StyleFormat.new(:font_name => 'Arial', :font_color_index => i, :font_outline => true)
|
13
|
+
|
14
|
+
borders = Borders.new
|
15
|
+
borders.left = i
|
16
|
+
|
17
|
+
style.borders = borders
|
18
|
+
|
19
|
+
ws0.write(i, 2, 'colour', style)
|
20
|
+
ws0.write(i, 3, hex(i), style0)
|
21
|
+
end
|
22
|
+
|
23
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
data/examples/image.rb
ADDED
data/examples/merged.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
fnt = Font.new
|
5
|
+
fnt.name = 'Arial'
|
6
|
+
fnt.colour_index = 4
|
7
|
+
fnt.bold = true
|
8
|
+
|
9
|
+
borders = Borders.new
|
10
|
+
borders.left = 6
|
11
|
+
borders.right = 6
|
12
|
+
borders.top = 6
|
13
|
+
borders.bottom = 6
|
14
|
+
|
15
|
+
al = Alignment.new
|
16
|
+
al.horz = Alignment::HORZ_CENTER
|
17
|
+
al.vert = Alignment::VERT_CENTER
|
18
|
+
|
19
|
+
style = StyleFormat.new
|
20
|
+
style.font = fnt
|
21
|
+
style.borders = borders
|
22
|
+
style.alignment = al
|
23
|
+
|
24
|
+
|
25
|
+
book = Workbook.new
|
26
|
+
ws0 = book.add_sheet
|
27
|
+
ws1 = book.add_sheet
|
28
|
+
ws2 = book.add_sheet
|
29
|
+
|
30
|
+
(0...0x200).step(2) do |i|
|
31
|
+
ws0.write_merge(i, i+1, 1, 5, "test #{i}", style)
|
32
|
+
ws1.write_merge(i, i, 1, 7, "test #{i}", style)
|
33
|
+
ws2.write_merge(i, i+1, 1, 7 + (i%10), "test #{i}", style)
|
34
|
+
end
|
35
|
+
|
36
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
data/examples/merged0.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
ws0 = book.add_sheet
|
6
|
+
|
7
|
+
|
8
|
+
fnt = Font.new
|
9
|
+
fnt.name = 'Arial'
|
10
|
+
fnt.colour_index = 4
|
11
|
+
fnt.bold = true
|
12
|
+
|
13
|
+
borders = Borders.new
|
14
|
+
borders.left = 6
|
15
|
+
borders.right = 6
|
16
|
+
borders.top = 6
|
17
|
+
borders.bottom = 6
|
18
|
+
|
19
|
+
style = StyleFormat.new
|
20
|
+
style.font = fnt
|
21
|
+
style.borders = borders
|
22
|
+
|
23
|
+
ws0.write_merge(3, 3, 1, 5, 'test1', style)
|
24
|
+
ws0.write_merge(4, 10, 1, 5, 'test2', style)
|
25
|
+
ws0.set_column_width(1, 0x0d00)
|
26
|
+
|
27
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
data/examples/merged1.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
ws0 = book.add_sheet
|
6
|
+
|
7
|
+
fnt1 = Font.new
|
8
|
+
fnt1.name = 'Verdana'
|
9
|
+
fnt1.bold = true
|
10
|
+
fnt1.height = 18*0x14
|
11
|
+
|
12
|
+
pat1 = Pattern.new
|
13
|
+
pat1.pattern = Pattern::SOLID_PATTERN
|
14
|
+
pat1.pattern_fore_colour = 0x16
|
15
|
+
|
16
|
+
brd1 = Borders.new
|
17
|
+
brd1.left = 0x06
|
18
|
+
brd1.right = 0x06
|
19
|
+
brd1.top = 0x06
|
20
|
+
brd1.bottom = 0x06
|
21
|
+
|
22
|
+
fnt2 = Font.new
|
23
|
+
fnt2.name = 'Verdana'
|
24
|
+
fnt2.bold = true
|
25
|
+
fnt2.height = 14*0x14
|
26
|
+
|
27
|
+
brd2 = Borders.new
|
28
|
+
brd2.left = 0x01
|
29
|
+
brd2.right = 0x01
|
30
|
+
brd2.top = 0x01
|
31
|
+
brd2.bottom = 0x01
|
32
|
+
|
33
|
+
pat2 = Pattern.new
|
34
|
+
pat2.pattern = Pattern::SOLID_PATTERN
|
35
|
+
pat2.pattern_fore_colour = 0x01F
|
36
|
+
|
37
|
+
fnt3 = Font.new
|
38
|
+
fnt3.name = 'Verdana'
|
39
|
+
fnt3.bold = true
|
40
|
+
fnt3.italic = true
|
41
|
+
fnt3.height = 12*0x14
|
42
|
+
|
43
|
+
brd3 = Borders.new
|
44
|
+
brd3.left = 0x07
|
45
|
+
brd3.right = 0x07
|
46
|
+
brd3.top = 0x07
|
47
|
+
brd3.bottom = 0x07
|
48
|
+
|
49
|
+
fnt4 = Font.new
|
50
|
+
|
51
|
+
al1 = Alignment.new
|
52
|
+
al1.horz = Alignment::HORZ_CENTER
|
53
|
+
al1.vert = Alignment::VERT_CENTER
|
54
|
+
|
55
|
+
al2 = Alignment.new
|
56
|
+
al2.horz = Alignment::HORZ_RIGHT
|
57
|
+
al2.vert = Alignment::VERT_CENTER
|
58
|
+
|
59
|
+
al3 = Alignment.new
|
60
|
+
al3.horz = Alignment::HORZ_LEFT
|
61
|
+
al3.vert = Alignment::VERT_CENTER
|
62
|
+
|
63
|
+
style1 = StyleFormat.new
|
64
|
+
style1.font = fnt1
|
65
|
+
style1.alignment = al1
|
66
|
+
style1.pattern = pat1
|
67
|
+
style1.borders = brd1
|
68
|
+
|
69
|
+
style2 = StyleFormat.new
|
70
|
+
style2.font = fnt2
|
71
|
+
style2.alignment = al1
|
72
|
+
style2.pattern = pat2
|
73
|
+
style2.borders = brd2
|
74
|
+
|
75
|
+
style3 = StyleFormat.new
|
76
|
+
style3.font = fnt3
|
77
|
+
style3.alignment = al1
|
78
|
+
style3.pattern = pat2
|
79
|
+
style3.borders = brd3
|
80
|
+
|
81
|
+
price_style = StyleFormat.new
|
82
|
+
price_style.font = fnt4
|
83
|
+
price_style.alignment = al2
|
84
|
+
price_style.borders = brd3
|
85
|
+
price_style.number_format_string = '_(#,##0.00_) "money"'
|
86
|
+
|
87
|
+
ware_style = StyleFormat.new
|
88
|
+
ware_style.font = fnt4
|
89
|
+
ware_style.alignment = al3
|
90
|
+
ware_style.borders = brd3
|
91
|
+
|
92
|
+
|
93
|
+
ws0.merge(3, 3, 1, 5, style1)
|
94
|
+
ws0.merge(4, 10, 1, 6, style2)
|
95
|
+
ws0.merge(14, 16, 1, 7, style3)
|
96
|
+
ws0.set_column_width(1, 0x0d00)
|
97
|
+
|
98
|
+
|
99
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
ws = book.add_sheet
|
6
|
+
|
7
|
+
fmts = [
|
8
|
+
'General',
|
9
|
+
'0',
|
10
|
+
'0.00',
|
11
|
+
'#,##0',
|
12
|
+
'#,##0.00',
|
13
|
+
'"$"#,##0_);("$"#,##',
|
14
|
+
'"$"#,##0_);[Red]("$"#,##',
|
15
|
+
'"$"#,##0.00_);("$"#,##',
|
16
|
+
'"$"#,##0.00_);[Red]("$"#,##',
|
17
|
+
'0%',
|
18
|
+
'0.00%',
|
19
|
+
'0.00E+00',
|
20
|
+
'# ?/?',
|
21
|
+
'# ??/??',
|
22
|
+
'M/D/YY',
|
23
|
+
'D-MMM-YY',
|
24
|
+
'D-MMM',
|
25
|
+
'MMM-YY',
|
26
|
+
'h:mm AM/PM',
|
27
|
+
'h:mm:ss AM/PM',
|
28
|
+
'h:mm',
|
29
|
+
'h:mm:ss',
|
30
|
+
'M/D/YY h:mm',
|
31
|
+
'_(#,##0_);(#,##0)',
|
32
|
+
'_(#,##0_);[Red](#,##0)',
|
33
|
+
'_(#,##0.00_);(#,##0.00)',
|
34
|
+
'_(#,##0.00_);[Red](#,##0.00)',
|
35
|
+
'_("$"* #,##0_);_("$"* (#,##0);_("$"* "-"_);_(@_)',
|
36
|
+
'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',
|
37
|
+
'_("$"* #,##0.00_);_("$"* (#,##0.00);_("$"* "-"??_);_(@_)',
|
38
|
+
'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',
|
39
|
+
'mm:ss',
|
40
|
+
'[h]:mm:ss',
|
41
|
+
'mm:ss.0',
|
42
|
+
'##0.0E+0',
|
43
|
+
'@'
|
44
|
+
]
|
45
|
+
|
46
|
+
fmts.each_with_index do |fmt, i|
|
47
|
+
ws.write(i, 0, fmt)
|
48
|
+
|
49
|
+
style = StyleFormat.new
|
50
|
+
style.number_format_string = fmt
|
51
|
+
|
52
|
+
ws.write(i, 4, -1278.9078, style)
|
53
|
+
end
|
54
|
+
|
55
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|
data/examples/numbers.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "surpass"
|
3
|
+
|
4
|
+
book = Workbook.new
|
5
|
+
ws = book.add_sheet
|
6
|
+
|
7
|
+
ws.write(0, 0, 1)
|
8
|
+
ws.write(1, 0, 1.23)
|
9
|
+
ws.write(2, 0, 12345678)
|
10
|
+
ws.write(3, 0, 123456.78)
|
11
|
+
|
12
|
+
ws.write(0, 1, -1)
|
13
|
+
ws.write(1, 1, -1.23)
|
14
|
+
ws.write(2, 1, -12345678)
|
15
|
+
ws.write(3, 1, -123456.78)
|
16
|
+
|
17
|
+
ws.write(0, 2, -17867868678687.0)
|
18
|
+
ws.write(1, 2, -1.23e-5)
|
19
|
+
ws.write(2, 2, -12345678.90780980)
|
20
|
+
ws.write(3, 2, -123456.78)
|
21
|
+
|
22
|
+
ws.write(0, 4, true)
|
23
|
+
|
24
|
+
book.save(__FILE__.gsub(/rb$/, "xls"))
|