spreadsheet 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/README.txt +3 -4
- data/lib/spreadsheet.rb +1 -1
- data/lib/spreadsheet/excel/internals.rb +22 -0
- data/lib/spreadsheet/excel/reader.rb +14 -12
- data/lib/spreadsheet/excel/writer/format.rb +20 -8
- data/lib/spreadsheet/format.rb +33 -17
- data/lib/spreadsheet/row.rb +6 -0
- data/spreadsheet.gemspec +1 -1
- metadata +76 -52
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
Last Update:
|
1
|
+
Last Update: 26.06.2012 - Zeno R.R. Davatz
|
2
2
|
|
3
3
|
= Spreadsheet
|
4
4
|
|
5
|
-
|
5
|
+
https://github.com/zdavatz/spreadsheet
|
6
6
|
|
7
7
|
The Mailing List can be found here:
|
8
8
|
|
@@ -10,7 +10,7 @@ http://groups.google.com/group/rubyspreadsheet
|
|
10
10
|
|
11
11
|
The code can be found here:
|
12
12
|
|
13
|
-
|
13
|
+
https://github.com/zdavatz/spreadsheet
|
14
14
|
|
15
15
|
For a viewable directory of all recent changes, please see:
|
16
16
|
|
@@ -24,7 +24,6 @@ For Non-GPLv3 commercial licencing, please see:
|
|
24
24
|
|
25
25
|
http://www.spreadsheet.ch
|
26
26
|
|
27
|
-
|
28
27
|
== Description
|
29
28
|
|
30
29
|
The Spreadsheet Library is designed to read and write Spreadsheet Documents.
|
data/lib/spreadsheet.rb
CHANGED
@@ -411,6 +411,28 @@ module Internals
|
|
411
411
|
:distributed => 4,
|
412
412
|
}
|
413
413
|
NGILA_V_FX = XF_V_ALIGN.invert
|
414
|
+
# border line styles taken from http://www.openoffice.org/sc/excelfileformat.pdf
|
415
|
+
XF_BORDER_LINE_STYLES = {
|
416
|
+
0x00 => :none,
|
417
|
+
0x01 => :thin,
|
418
|
+
0x02 => :medium,
|
419
|
+
0x03 => :dashed,
|
420
|
+
0x04 => :dotted,
|
421
|
+
0x05 => :thick,
|
422
|
+
0x06 => :double,
|
423
|
+
0x07 => :hair,
|
424
|
+
# the following are only valid for BIFF8 and higher:
|
425
|
+
0x08 => :medium_dashed,
|
426
|
+
0x09 => :thin_dash_dotted,
|
427
|
+
0x0a => :medium_dash_dotted,
|
428
|
+
0x0b => :thin_dash_dot_dotted,
|
429
|
+
0x0c => :medium_dash_dot_dotted,
|
430
|
+
0x0d => :slanted_medium_dash_dotted
|
431
|
+
}
|
432
|
+
# ensure reader always gets a valid line style
|
433
|
+
XF_BORDER_LINE_STYLES.default = :none
|
434
|
+
SELYTS_ENIL_REDROB_FX = XF_BORDER_LINE_STYLES.invert
|
435
|
+
SELYTS_ENIL_REDROB_FX.default = 0x00
|
414
436
|
OPCODE_SIZE = 4
|
415
437
|
ROW_HEIGHT = 12.1
|
416
438
|
SST_CHUNKSIZE = 20
|
@@ -1048,21 +1048,23 @@ class Reader
|
|
1048
1048
|
fmt.indent_level = xf_indent & 0x0f
|
1049
1049
|
fmt.shrink = xf_indent & 0x10 > 0
|
1050
1050
|
fmt.text_direction = NOITCERID_TXET_FX[xf_indent & 0xc0]
|
1051
|
-
fmt.left
|
1052
|
-
fmt.right
|
1053
|
-
fmt.top
|
1054
|
-
fmt.bottom
|
1055
|
-
fmt.left_color = COLOR_CODES[xf_borders & 0x007f0000] || :
|
1056
|
-
fmt.right_color = COLOR_CODES[xf_borders & 0x3f800000] || :
|
1051
|
+
fmt.left = XF_BORDER_LINE_STYLES[xf_borders & 0x0000000f]
|
1052
|
+
fmt.right = XF_BORDER_LINE_STYLES[(xf_borders & 0x000000f0) >> 4]
|
1053
|
+
fmt.top = XF_BORDER_LINE_STYLES[(xf_borders & 0x00000f00) >> 8]
|
1054
|
+
fmt.bottom = XF_BORDER_LINE_STYLES[(xf_borders & 0x0000f000) >> 12]
|
1055
|
+
fmt.left_color = COLOR_CODES[(xf_borders & 0x007f0000) >> 16] || :black
|
1056
|
+
fmt.right_color = COLOR_CODES[(xf_borders & 0x3f800000) >> 23] || :black
|
1057
1057
|
fmt.cross_down = xf_borders & 0x40000000 > 0
|
1058
1058
|
fmt.cross_up = xf_borders & 0x80000000 > 0
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1059
|
+
if xf_brdcolors
|
1060
|
+
fmt.top_color = COLOR_CODES[xf_brdcolors & 0x0000007f] || :black
|
1061
|
+
fmt.bottom_color = COLOR_CODES[(xf_brdcolors & 0x00003f80) >> 7] || :black
|
1062
|
+
fmt.diagonal_color = COLOR_CODES[(xf_brdcolors & 0x001fc000) >> 14] || :black
|
1063
|
+
#fmt.diagonal_style = COLOR_CODES[xf_brdcolors & 0x01e00000]
|
1064
|
+
fmt.pattern = (xf_brdcolors & 0xfc000000) >> 26
|
1065
|
+
end
|
1064
1066
|
fmt.pattern_fg_color = COLOR_CODES[xf_pattern & 0x007f] || :border
|
1065
|
-
fmt.pattern_bg_color = COLOR_CODES[xf_pattern & 0x3f80] || :pattern_bg
|
1067
|
+
fmt.pattern_bg_color = COLOR_CODES[(xf_pattern & 0x3f80) >> 7] || :pattern_bg
|
1066
1068
|
@workbook.add_format fmt
|
1067
1069
|
end
|
1068
1070
|
def read_sheet_protection worksheet, op, data
|
@@ -21,13 +21,22 @@ class Format < DelegateClass Spreadsheet::Format
|
|
21
21
|
color_code(@format.send(key) || default)
|
22
22
|
end
|
23
23
|
end
|
24
|
+
def Format.line_style key, default
|
25
|
+
define_method key do
|
26
|
+
style_code(@format.send(key) || default)
|
27
|
+
end
|
28
|
+
end
|
24
29
|
boolean :hidden, :locked, :merge_range, :shrink, :text_justlast, :text_wrap,
|
25
|
-
:cross_down, :cross_up
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
color :
|
30
|
+
:cross_down, :cross_up
|
31
|
+
line_style :left, :none
|
32
|
+
line_style :right, :none
|
33
|
+
line_style :top, :none
|
34
|
+
line_style :bottom, :none
|
35
|
+
color :left_color, :black
|
36
|
+
color :right_color, :black
|
37
|
+
color :top_color, :black
|
38
|
+
color :bottom_color, :black
|
39
|
+
color :diagonal_color, :black
|
31
40
|
color :pattern_fg_color, :pattern_bg
|
32
41
|
color :pattern_bg_color, :pattern_bg
|
33
42
|
attr_reader :format
|
@@ -41,6 +50,9 @@ class Format < DelegateClass Spreadsheet::Format
|
|
41
50
|
def color_code color
|
42
51
|
SEDOC_ROLOC[color]
|
43
52
|
end
|
53
|
+
def style_code style
|
54
|
+
SELYTS_ENIL_REDROB_FX[style]
|
55
|
+
end
|
44
56
|
def font_index
|
45
57
|
@writer.font_index @workbook, font.key
|
46
58
|
end
|
@@ -212,7 +224,7 @@ class Format < DelegateClass Spreadsheet::Format
|
|
212
224
|
rot
|
213
225
|
end
|
214
226
|
def xf_type_prot type
|
215
|
-
type = type.to_s.downcase == 'style' ?
|
227
|
+
type = type.to_s.downcase == 'style' ? 0xfff4 : 0x0000
|
216
228
|
type |= locked
|
217
229
|
type |= hidden << 1
|
218
230
|
type
|
@@ -229,7 +241,7 @@ class Format < DelegateClass Spreadsheet::Format
|
|
229
241
|
then
|
230
242
|
atr_alc = 1
|
231
243
|
end
|
232
|
-
atr_bdr =
|
244
|
+
atr_bdr = 1
|
233
245
|
atr_pat = 0
|
234
246
|
if @format.pattern_fg_color != :border \
|
235
247
|
|| @format.pattern_bg_color != :pattern_bg \
|
data/lib/spreadsheet/format.rb
CHANGED
@@ -21,16 +21,32 @@ module Spreadsheet
|
|
21
21
|
# #shrink:: Shrink the contents to fit the cell.
|
22
22
|
# #text_justlast:: Force the last line of a cell to be justified. This
|
23
23
|
# probably makes sense if horizontal_align = :justify
|
24
|
-
# #left::
|
25
|
-
# #right::
|
26
|
-
# #top::
|
27
|
-
# #bottom::
|
24
|
+
# #left:: Apply a border style to the left of the cell.
|
25
|
+
# #right:: Apply a border style to the right of the cell.
|
26
|
+
# #top:: Apply a border style at the top of the cell.
|
27
|
+
# #bottom:: Apply a border style at the bottom of the cell.
|
28
28
|
# #rotation_stacked:: Characters in the cell are stacked on top of each
|
29
29
|
# other. Excel will ignore other rotation values if
|
30
30
|
# this is set.
|
31
31
|
boolean :cross_down, :cross_up, :hidden, :locked,
|
32
|
-
:merge_range, :shrink, :text_justlast, :text_wrap,
|
33
|
-
|
32
|
+
:merge_range, :shrink, :text_justlast, :text_wrap,
|
33
|
+
:rotation_stacked
|
34
|
+
##
|
35
|
+
# Border line styles
|
36
|
+
# Valid values: :none, :thin, :medium, :dashed, :dotted, :thick,
|
37
|
+
# :double, :hair, :medium_dashed, :thin_dash_dotted,
|
38
|
+
# :medium_dash_dotted, :thin_dash_dot_dotted,
|
39
|
+
# :medium_dash_dot_dotted, :slanted_medium_dash_dotted
|
40
|
+
# Default: :none
|
41
|
+
styles = [ :thin, :medium, :dashed, :dotted, :thick,
|
42
|
+
:double, :hair, :medium_dashed, :thin_dash_dotted,
|
43
|
+
:medium_dash_dotted, :thin_dash_dot_dotted,
|
44
|
+
:medium_dash_dot_dotted, :slanted_medium_dash_dotted ]
|
45
|
+
enum :left, :none, *styles
|
46
|
+
enum :right, :none, *styles
|
47
|
+
enum :top, :none, *styles
|
48
|
+
enum :bottom, :none, *styles
|
49
|
+
|
34
50
|
##
|
35
51
|
# Color attributes
|
36
52
|
colors :bottom_color, :top_color, :left_color, :right_color,
|
@@ -77,11 +93,11 @@ module Spreadsheet
|
|
77
93
|
@number_format = client 'GENERAL', 'UTF-8'
|
78
94
|
@rotation = 0
|
79
95
|
@pattern = 0
|
80
|
-
@bottom_color = :
|
81
|
-
@top_color = :
|
82
|
-
@left_color = :
|
83
|
-
@right_color = :
|
84
|
-
@diagonal_color = :
|
96
|
+
@bottom_color = :black
|
97
|
+
@top_color = :black
|
98
|
+
@left_color = :black
|
99
|
+
@right_color = :black
|
100
|
+
@diagonal_color = :black
|
85
101
|
@pattern_fg_color = :border
|
86
102
|
@pattern_bg_color = :pattern_bg
|
87
103
|
@regexes = {
|
@@ -116,21 +132,21 @@ module Spreadsheet
|
|
116
132
|
self.vertical_align = location rescue ArgumentError
|
117
133
|
end
|
118
134
|
##
|
119
|
-
# Returns an Array containing the
|
135
|
+
# Returns an Array containing the line styles of the four borders:
|
120
136
|
# bottom, top, right, left
|
121
137
|
def border
|
122
|
-
[bottom,top,right,left]
|
138
|
+
[bottom, top, right, left]
|
123
139
|
end
|
124
140
|
##
|
125
|
-
#
|
126
|
-
def border=(
|
127
|
-
[:bottom=, :top=, :right=, :left=].each do |writer| send writer,
|
141
|
+
# Set same line style on all four borders at once (left, right, top, bottom)
|
142
|
+
def border=(style)
|
143
|
+
[:bottom=, :top=, :right=, :left=].each do |writer| send writer, style end
|
128
144
|
end
|
129
145
|
##
|
130
146
|
# Returns an Array containing the colors of the four borders:
|
131
147
|
# bottom, top, right, left
|
132
148
|
def border_color
|
133
|
-
[@bottom_color,@top_color,@left_color
|
149
|
+
[@bottom_color,@top_color,@right_color,@left_color]
|
134
150
|
end
|
135
151
|
##
|
136
152
|
# Set all four border colors to _color_ (left, right, top, bottom)
|
data/lib/spreadsheet/row.rb
CHANGED
@@ -65,6 +65,12 @@ module Spreadsheet
|
|
65
65
|
@height = 12.1
|
66
66
|
end
|
67
67
|
##
|
68
|
+
# The default Format of this Row, if you have set one.
|
69
|
+
# Returns the Worksheet's default or the Workbook's default Format otherwise.
|
70
|
+
def default_format
|
71
|
+
@default_format || @worksheet.default_format || @workbook.default_format
|
72
|
+
end
|
73
|
+
##
|
68
74
|
# Set the default Format used when writing a Cell if no explicit Format is
|
69
75
|
# stored for the cell.
|
70
76
|
def default_format= format
|
data/spreadsheet.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "spreadsheet"
|
3
|
-
s.version = "0.7.
|
3
|
+
s.version = "0.7.3"
|
4
4
|
s.summary = "The Spreadsheet Library is designed to read and write Spreadsheet Documents"
|
5
5
|
s.description = "As of version 0.6.0, only Microsoft Excel compatible spreadsheets are supported"
|
6
6
|
s.author = "Masaomi Hatakeyama, Zeno R.R. Davatz"
|
metadata
CHANGED
@@ -1,71 +1,86 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadsheet
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 3
|
10
|
+
version: 0.7.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-06-26 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: ruby-ole
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: "1.0"
|
22
33
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
26
36
|
name: rdoc
|
27
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
40
|
+
requirements:
|
30
41
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 19
|
44
|
+
segments:
|
45
|
+
- 3
|
46
|
+
- 10
|
47
|
+
version: "3.10"
|
33
48
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
37
51
|
name: hoe
|
38
|
-
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
54
|
none: false
|
40
|
-
requirements:
|
55
|
+
requirements:
|
41
56
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 25
|
59
|
+
segments:
|
60
|
+
- 2
|
61
|
+
- 13
|
62
|
+
version: "2.13"
|
44
63
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Documents.
|
49
|
-
|
64
|
+
version_requirements: *id003
|
65
|
+
description: |-
|
66
|
+
The Spreadsheet Library is designed to read and write Spreadsheet Documents.
|
50
67
|
As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
|
51
|
-
|
52
68
|
supported. Spreadsheet is a combination/complete rewrite of the
|
53
|
-
|
54
69
|
Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by
|
55
|
-
|
56
|
-
|
57
|
-
email:
|
70
|
+
Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
|
71
|
+
email:
|
58
72
|
- mhatakeyama@ywesee.com, zdavatz@ywesee.com
|
59
|
-
executables:
|
73
|
+
executables:
|
60
74
|
- xlsopcodes
|
61
75
|
extensions: []
|
62
|
-
|
76
|
+
|
77
|
+
extra_rdoc_files:
|
63
78
|
- GUIDE.txt
|
64
79
|
- History.txt
|
65
80
|
- LICENSE.txt
|
66
81
|
- Manifest.txt
|
67
82
|
- README.txt
|
68
|
-
files:
|
83
|
+
files:
|
69
84
|
- .gitignore
|
70
85
|
- GUIDE.txt
|
71
86
|
- History.txt
|
@@ -136,30 +151,39 @@ files:
|
|
136
151
|
- test/worksheet.rb
|
137
152
|
- test/workbook_protection.rb
|
138
153
|
- .gemtest
|
139
|
-
homepage:
|
154
|
+
homepage: https://github.com/zdavatz/spreadsheet
|
140
155
|
licenses: []
|
156
|
+
|
141
157
|
post_install_message:
|
142
|
-
rdoc_options:
|
158
|
+
rdoc_options:
|
143
159
|
- --main
|
144
160
|
- README.txt
|
145
|
-
require_paths:
|
161
|
+
require_paths:
|
146
162
|
- lib
|
147
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
164
|
none: false
|
149
|
-
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
|
153
|
-
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
hash: 3
|
169
|
+
segments:
|
170
|
+
- 0
|
171
|
+
version: "0"
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
173
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
hash: 3
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
version: "0"
|
159
181
|
requirements: []
|
182
|
+
|
160
183
|
rubyforge_project: spreadsheet
|
161
184
|
rubygems_version: 1.8.15
|
162
185
|
signing_key:
|
163
186
|
specification_version: 3
|
164
187
|
summary: The Spreadsheet Library is designed to read and write Spreadsheet Documents
|
165
188
|
test_files: []
|
189
|
+
|