spreadsheet 0.6.5.9 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/Manifest.txt +2 -0
- data/README.txt +10 -1
- data/lib/spreadsheet.rb +1 -1
- data/lib/spreadsheet/datatypes.rb +57 -1
- data/lib/spreadsheet/excel/internals.rb +83 -19
- data/lib/spreadsheet/excel/reader.rb +23 -0
- data/lib/spreadsheet/excel/reader/biff5.rb +20 -0
- data/lib/spreadsheet/excel/reader/biff8.rb +21 -0
- data/lib/spreadsheet/excel/writer/worksheet.rb +15 -0
- data/lib/spreadsheet/worksheet.rb +8 -1
- data/spreadsheet.gemspec +1 -1
- data/test/data/test_merged_cells.xls +0 -0
- data/test/data/test_version_excel97_2010.xls +0 -0
- data/test/excel/writer/worksheet.rb +16 -0
- data/test/integration.rb +31 -0
- data/test/suite.rb +5 -7
- metadata +28 -15
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 0.6.7 / 18.01.2012
|
2
|
+
|
3
|
+
* http://dev.ywesee.com/wiki.php/Gem/Spreadsheet points point 2.
|
4
|
+
* Tests by Michal
|
5
|
+
* Patches by Timon
|
6
|
+
|
7
|
+
=== 0.6.6 / 18.01.2012
|
8
|
+
|
9
|
+
* http://dev.ywesee.com/wiki.php/Gem/Spreadsheet points 8 and 9.
|
10
|
+
* Fixes byjsaak@napalm.hu
|
11
|
+
* Patches by Vitaly Klimov
|
12
|
+
|
1
13
|
=== 0.6.5.9 / 7.9.2011
|
2
14
|
|
3
15
|
* Fixed a frozen string bug thanks to dblock (Daniel Doubrovkine),
|
data/Manifest.txt
CHANGED
@@ -47,10 +47,12 @@ test/data/test_datetime.xls
|
|
47
47
|
test/data/test_empty.xls
|
48
48
|
test/data/test_formula.xls
|
49
49
|
test/data/test_long_sst_record.xls
|
50
|
+
test/data/test_merged_cells.xls
|
50
51
|
test/data/test_missing_row.xls
|
51
52
|
test/data/test_version_excel5.xls
|
52
53
|
test/data/test_version_excel95.xls
|
53
54
|
test/data/test_version_excel97.xls
|
55
|
+
test/data/test_version_excel97_2010.xls
|
54
56
|
test/excel/row.rb
|
55
57
|
test/excel/writer/workbook.rb
|
56
58
|
test/excel/writer/worksheet.rb
|
data/README.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Last Update:
|
1
|
+
Last Update: 08.12.2011 - Zeno R.R. Davatz
|
2
2
|
|
3
3
|
= Spreadsheet
|
4
4
|
|
@@ -33,6 +33,11 @@ supported. Spreadsheet is a combination/complete rewrite of the
|
|
33
33
|
Spreadsheet::Excel Library by Daniel J. Berger and the ParseExcel Library by
|
34
34
|
Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
|
35
35
|
|
36
|
+
== Notes from Users
|
37
|
+
|
38
|
+
Alfred: a@boxbot.org: I think it should be noted in the README file that the library doesn't
|
39
|
+
recognize cell formats in Excel created documents, which results in
|
40
|
+
Floats returned for any number.
|
36
41
|
|
37
42
|
== What's new?
|
38
43
|
|
@@ -52,6 +57,10 @@ Hannes Wyss. Spreadsheet can read, write and modify Spreadsheet Documents.
|
|
52
57
|
1.0.0:: Ruby 1.9 Support;
|
53
58
|
Remove backward compatibility code
|
54
59
|
|
60
|
+
Note: Spreadsheet supports Ruby 1.8.6, 1.8.7, 1.9.2, 1.9.3
|
61
|
+
|
62
|
+
You will get a deprecated warning about iconv when using spreadsheet with Ruby
|
63
|
+
1.9.3. So replacing iconv is on the Roadmap as well ;).
|
55
64
|
|
56
65
|
== Dependencies
|
57
66
|
|
data/lib/spreadsheet.rb
CHANGED
@@ -18,7 +18,63 @@ class << self
|
|
18
18
|
:chart_border, :tooltip_bg, :tooltip_text, :aqua,
|
19
19
|
:black, :blue, :cyan, :brown, :fuchsia, :gray, :grey, :green,
|
20
20
|
:lime, :magenta, :navy, :orange, :purple, :red, :silver, :white,
|
21
|
-
:yellow
|
21
|
+
:yellow,
|
22
|
+
:xls_color_0,
|
23
|
+
:xls_color_1,
|
24
|
+
:xls_color_2,
|
25
|
+
:xls_color_3,
|
26
|
+
:xls_color_4,
|
27
|
+
:xls_color_5,
|
28
|
+
:xls_color_6,
|
29
|
+
:xls_color_7,
|
30
|
+
:xls_color_8,
|
31
|
+
:xls_color_9,
|
32
|
+
:xls_color_10,
|
33
|
+
:xls_color_11,
|
34
|
+
:xls_color_12,
|
35
|
+
:xls_color_13,
|
36
|
+
:xls_color_14,
|
37
|
+
:xls_color_15,
|
38
|
+
:xls_color_16,
|
39
|
+
:xls_color_17,
|
40
|
+
:xls_color_18,
|
41
|
+
:xls_color_19,
|
42
|
+
:xls_color_20,
|
43
|
+
:xls_color_21,
|
44
|
+
:xls_color_22,
|
45
|
+
:xls_color_23,
|
46
|
+
:xls_color_24,
|
47
|
+
:xls_color_25,
|
48
|
+
:xls_color_26,
|
49
|
+
:xls_color_27,
|
50
|
+
:xls_color_28,
|
51
|
+
:xls_color_29,
|
52
|
+
:xls_color_30,
|
53
|
+
:xls_color_31,
|
54
|
+
:xls_color_32,
|
55
|
+
:xls_color_33,
|
56
|
+
:xls_color_34,
|
57
|
+
:xls_color_35,
|
58
|
+
:xls_color_36,
|
59
|
+
:xls_color_37,
|
60
|
+
:xls_color_38,
|
61
|
+
:xls_color_39,
|
62
|
+
:xls_color_40,
|
63
|
+
:xls_color_41,
|
64
|
+
:xls_color_42,
|
65
|
+
:xls_color_43,
|
66
|
+
:xls_color_44,
|
67
|
+
:xls_color_45,
|
68
|
+
:xls_color_46,
|
69
|
+
:xls_color_47,
|
70
|
+
:xls_color_48,
|
71
|
+
:xls_color_49,
|
72
|
+
:xls_color_50,
|
73
|
+
:xls_color_51,
|
74
|
+
:xls_color_52,
|
75
|
+
:xls_color_53,
|
76
|
+
:xls_color_54,
|
77
|
+
:xls_color_55 ]
|
22
78
|
##
|
23
79
|
# Define instance methods to read and write boolean attributes.
|
24
80
|
def boolean *args
|
@@ -54,6 +54,8 @@ module Internals
|
|
54
54
|
32769 => "WINDOWS-1252", #(Latin I) (BIFF2-BIFF3)
|
55
55
|
}
|
56
56
|
SEGAPEDOC = CODEPAGES.invert
|
57
|
+
# color_codes according to http://support.softartisans.com/kbview_1205.aspx
|
58
|
+
# synonyms are in comments when reverse lookup
|
57
59
|
COLOR_CODES = {
|
58
60
|
0x0000 => :builtin_black,
|
59
61
|
0x0001 => :builtin_white,
|
@@ -63,21 +65,63 @@ module Internals
|
|
63
65
|
0x0005 => :builtin_yellow,
|
64
66
|
0x0006 => :builtin_magenta,
|
65
67
|
0x0007 => :builtin_cyan,
|
66
|
-
0x0008 => :black,
|
67
|
-
0x0009 => :white,
|
68
|
-
0x000a => :red,
|
69
|
-
0x000b => :lime,
|
70
|
-
0x000c => :blue,
|
71
|
-
0x000d => :yellow,
|
72
|
-
0x000e => :magenta,
|
73
|
-
0x000f => :cyan,
|
74
|
-
0x0010 => :brown,
|
75
|
-
0x0011 => :green,
|
76
|
-
0x0012 => :navy,
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
68
|
+
0x0008 => :black, #xls_color_0
|
69
|
+
0x0009 => :white, #xls_color_1
|
70
|
+
0x000a => :red, #xls_color_2
|
71
|
+
0x000b => :lime, #xls_color_3
|
72
|
+
0x000c => :blue, #xls_color_4
|
73
|
+
0x000d => :yellow, #xls_color_5
|
74
|
+
0x000e => :magenta, #xls_color_6, fuchsia
|
75
|
+
0x000f => :cyan, #xls_color_7, aqua
|
76
|
+
0x0010 => :brown, #xls_color_8
|
77
|
+
0x0011 => :green, #xls_color_9
|
78
|
+
0x0012 => :navy, #xls_color_10
|
79
|
+
0x0013 => :xls_color_11,
|
80
|
+
0x0014 => :xls_color_12,
|
81
|
+
0x0015 => :xls_color_13,
|
82
|
+
0x0016 => :silver, #xls_color_14
|
83
|
+
0x0017 => :gray, #xls_color_15, grey
|
84
|
+
0x0018 => :xls_color_16,
|
85
|
+
0x0019 => :xls_color_17,
|
86
|
+
0x001a => :xls_color_18,
|
87
|
+
0x001b => :xls_color_19,
|
88
|
+
0x001c => :xls_color_20,
|
89
|
+
0x001d => :xls_color_21,
|
90
|
+
0x001e => :xls_color_22,
|
91
|
+
0x001f => :xls_color_23,
|
92
|
+
0x0020 => :xls_color_24,
|
93
|
+
0x0021 => :xls_color_25,
|
94
|
+
0x0022 => :xls_color_26,
|
95
|
+
0x0023 => :xls_color_27,
|
96
|
+
0x0024 => :purple, #xls_color_28
|
97
|
+
0x0025 => :xls_color_29,
|
98
|
+
0x0026 => :xls_color_30,
|
99
|
+
0x0027 => :xls_color_31,
|
100
|
+
0x0028 => :xls_color_32,
|
101
|
+
0x0029 => :xls_color_33,
|
102
|
+
0x002a => :xls_color_34,
|
103
|
+
0x002b => :xls_color_35,
|
104
|
+
0x002c => :xls_color_36,
|
105
|
+
0x002d => :xls_color_37,
|
106
|
+
0x002e => :xls_color_38,
|
107
|
+
0x002f => :xls_color_39,
|
108
|
+
0x0030 => :xls_color_40,
|
109
|
+
0x0031 => :xls_color_41,
|
110
|
+
0x0032 => :xls_color_42,
|
111
|
+
0x0033 => :xls_color_43,
|
112
|
+
0x0034 => :orange, #xls_color_44
|
113
|
+
0x0035 => :xls_color_45,
|
114
|
+
0x0036 => :xls_color_46,
|
115
|
+
0x0037 => :xls_color_47,
|
116
|
+
0x0038 => :xls_color_48,
|
117
|
+
0x0039 => :xls_color_49,
|
118
|
+
0x003a => :xls_color_50,
|
119
|
+
0x003b => :xls_color_51,
|
120
|
+
0x003c => :xls_color_52,
|
121
|
+
0x003d => :xls_color_53,
|
122
|
+
0x003e => :xls_color_54,
|
123
|
+
0x003f => :xls_color_55,
|
124
|
+
|
81
125
|
0x0040 => :border,
|
82
126
|
0x0041 => :pattern_bg,
|
83
127
|
0x0043 => :dialog_bg,
|
@@ -86,11 +130,30 @@ module Internals
|
|
86
130
|
0x004f => :chart_border,
|
87
131
|
0x0050 => :tooltip_bg,
|
88
132
|
0x0051 => :tooltip_text,
|
89
|
-
0x7fff => :text
|
133
|
+
0x7fff => :text
|
90
134
|
}
|
91
|
-
|
92
|
-
|
93
|
-
|
135
|
+
|
136
|
+
SEDOC_ROLOC = COLOR_CODES.invert.update(
|
137
|
+
:xls_color_0 => 0x0008,
|
138
|
+
:xls_color_1 => 0x0009,
|
139
|
+
:xls_color_2 => 0x000a,
|
140
|
+
:xls_color_3 => 0x000b,
|
141
|
+
:xls_color_4 => 0x000c,
|
142
|
+
:xls_color_5 => 0x000d,
|
143
|
+
:xls_color_6 => 0x000e,
|
144
|
+
:fuchsia => 0x000e,
|
145
|
+
:xls_color_7 => 0x000f,
|
146
|
+
:aqua => 0x000f,
|
147
|
+
:xls_color_8 => 0x0010,
|
148
|
+
:xls_color_9 => 0x0011,
|
149
|
+
:xls_color_10 => 0x0012,
|
150
|
+
:xls_color_14 => 0x0016,
|
151
|
+
:xls_color_15 => 0x0017,
|
152
|
+
:grey => 0x0017,
|
153
|
+
:xls_color_28 => 0x0024,
|
154
|
+
:xls_color_44 => 0x0034
|
155
|
+
)
|
156
|
+
|
94
157
|
BINARY_FORMATS = {
|
95
158
|
:blank => 'v3',
|
96
159
|
:boolerr => 'v3C2',
|
@@ -216,6 +279,7 @@ module Internals
|
|
216
279
|
:hlink => 0x01b8, # HLINK ➜ 6.52 (BIFF8 only)
|
217
280
|
:label => 0x0204, # LABEL ➜ 6.59 (BIFF2-BIFF7)
|
218
281
|
:labelsst => 0x00fd, # LABELSST ➜ 6.61 (BIFF8 only)
|
282
|
+
:mergedcells => 0x00e5, # ○○ MERGEDCELLS ➜ 5.67 (BIFF8 only)
|
219
283
|
:mulblank => 0x00be, # MULBLANK ➜ 6.64 (BIFF5-BIFF8)
|
220
284
|
:mulrk => 0x00bd, # MULRK ➜ 6.65 (BIFF5-BIFF8)
|
221
285
|
:number => 0x0203, # NUMBER ➜ 6.68
|
@@ -761,6 +761,27 @@ class Reader
|
|
761
761
|
flags, _ = work.unpack 'v'
|
762
762
|
worksheet.selected = flags & 0x0200 > 0
|
763
763
|
end
|
764
|
+
|
765
|
+
def read_merged_cells worksheet, work, pos, len
|
766
|
+
# This record contains the addresses of merged cell ranges in the current sheet.
|
767
|
+
# Record MERGEDCELLS, BIFF8:
|
768
|
+
# Offset Size Contents
|
769
|
+
# 0 var. Cell range address list with merged ranges (➜ 2.5.15)
|
770
|
+
# If the record size exceeds the limit, it is not continued with a CONTINUE record,
|
771
|
+
# but another self-contained MERGEDCELLS record is started. The limit of 8224 bytes
|
772
|
+
# per record results in a maximum number of 1027 merged ranges.
|
773
|
+
|
774
|
+
worksheet.merged_cells.push *read_range_address_list(work, len)
|
775
|
+
#
|
776
|
+
# A cell range address list consists of a field with the number of ranges and the list
|
777
|
+
# of the range addresses.
|
778
|
+
# Cell range address list, BIFF2-BIFF8:
|
779
|
+
# Offset Size Contents
|
780
|
+
# 0 2 Number of following cell range addresses (nm)
|
781
|
+
# 2 6∙nm or 8∙nm List of nm cell range addresses (➜ 2.5.14)
|
782
|
+
#
|
783
|
+
end
|
784
|
+
|
764
785
|
def read_workbook
|
765
786
|
worksheet = nil
|
766
787
|
previous_op = nil
|
@@ -843,6 +864,8 @@ class Reader
|
|
843
864
|
read_hlink worksheet, work, pos, len
|
844
865
|
when :window2
|
845
866
|
read_window2 worksheet, work, pos, len
|
867
|
+
when :mergedcells # ○○ MERGEDCELLS ➜ 5.67
|
868
|
+
read_merged_cells worksheet, work, pos, len
|
846
869
|
else
|
847
870
|
if ROW_BLOCK_OPS.include?(op)
|
848
871
|
set_missing_row_address worksheet, work, pos, len
|
@@ -16,6 +16,26 @@ module Biff5
|
|
16
16
|
length, = work.unpack fmt
|
17
17
|
work[count_length, length]
|
18
18
|
end
|
19
|
+
|
20
|
+
def read_range_address_list work, len
|
21
|
+
# Cell range address, BIFF2-BIFF5:
|
22
|
+
# Offset Size Contents
|
23
|
+
# 0 2 Index to first row
|
24
|
+
# 2 2 Index to last row
|
25
|
+
# 4 1 Index to first column
|
26
|
+
# 5 1 Index to last column
|
27
|
+
#
|
28
|
+
offset = 0, results = []
|
29
|
+
return results if len < 2
|
30
|
+
count = work[0..1].unpack('v').first
|
31
|
+
offset = 2
|
32
|
+
count.times do |i|
|
33
|
+
results << work[offset...offset+6].unpack('v2c2')
|
34
|
+
offset += 6
|
35
|
+
end
|
36
|
+
results
|
37
|
+
end
|
38
|
+
|
19
39
|
end
|
20
40
|
end
|
21
41
|
end
|
@@ -161,6 +161,27 @@ module Biff8
|
|
161
161
|
owing = chars - have_chrs
|
162
162
|
[chars, flagsize, wide, phonetic, richtext, avbl, owing, skip]
|
163
163
|
end
|
164
|
+
|
165
|
+
def read_range_address_list work, len
|
166
|
+
# Cell range address, BIFF8:
|
167
|
+
# Offset Size Contents
|
168
|
+
# 0 2 Index to first row
|
169
|
+
# 2 2 Index to last row
|
170
|
+
# 4 2 Index to first column
|
171
|
+
# 6 2 Index to last column
|
172
|
+
# ! In several cases, BIFF8 still writes the BIFF2-BIFF5 format of a cell range address
|
173
|
+
# (using 8-bit values for the column indexes). This will be mentioned at the respective place.
|
174
|
+
#
|
175
|
+
offset = 0, results = []
|
176
|
+
return results if len < 2
|
177
|
+
count = work[0..1].unpack('v').first
|
178
|
+
offset = 2
|
179
|
+
count.times do |i|
|
180
|
+
results << work[offset...offset+8].unpack('v4')
|
181
|
+
offset += 8
|
182
|
+
end
|
183
|
+
results
|
184
|
+
end
|
164
185
|
##
|
165
186
|
# Insert null-characters into a compressed UTF-16 string
|
166
187
|
def wide string
|
@@ -488,6 +488,7 @@ and minimal code that generates this warning. Thanks!
|
|
488
488
|
# ○○ SELECTION ➜ 5.93
|
489
489
|
# ○ STANDARDWIDTH ➜ 5.101
|
490
490
|
# ○○ MERGEDCELLS ➜ 5.67
|
491
|
+
write_merged_cells
|
491
492
|
# ○ LABELRANGES ➜ 5.64
|
492
493
|
# ○ PHONETIC ➜ 5.77
|
493
494
|
# ○ Conditional Formatting Table ➜ 4.12
|
@@ -837,6 +838,20 @@ and minimal code that generates this warning. Thanks!
|
|
837
838
|
data = [ flags, 0, 0, 0, 0, 0 ].pack binfmt(:window2)
|
838
839
|
write_op opcode(:window2), data
|
839
840
|
end
|
841
|
+
|
842
|
+
def write_merged_cells
|
843
|
+
return unless @worksheet.merged_cells.any?
|
844
|
+
# FIXME standards say the record is limited by 1027 records at once
|
845
|
+
# And no CONTINUE is supported
|
846
|
+
|
847
|
+
merge_cells = @worksheet.merged_cells.dup
|
848
|
+
while (window = merge_cells.slice!(0...1027)).any?
|
849
|
+
count = window.size
|
850
|
+
data = ([count] + window.flatten).pack('v2v*')
|
851
|
+
write_op opcode(:mergedcells), data
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
840
855
|
def write_wsbool
|
841
856
|
bits = [
|
842
857
|
# Bit Mask Contents
|
@@ -27,7 +27,7 @@ module Spreadsheet
|
|
27
27
|
include Spreadsheet::Encodings
|
28
28
|
include Enumerable
|
29
29
|
attr_accessor :name, :selected, :workbook
|
30
|
-
attr_reader :rows, :columns
|
30
|
+
attr_reader :rows, :columns, :merged_cells
|
31
31
|
def initialize opts={}
|
32
32
|
@default_format = nil
|
33
33
|
@selected = opts[:selected]
|
@@ -37,6 +37,7 @@ module Spreadsheet
|
|
37
37
|
@rows = []
|
38
38
|
@columns = []
|
39
39
|
@links = {}
|
40
|
+
@merged_cells = []
|
40
41
|
end
|
41
42
|
def active # :nodoc:
|
42
43
|
warn "Worksheet#active is deprecated. Please use Worksheet#selected instead."
|
@@ -251,6 +252,12 @@ module Spreadsheet
|
|
251
252
|
def []= row, column, value
|
252
253
|
row(row)[column] = value
|
253
254
|
end
|
255
|
+
##
|
256
|
+
# Merges multiple cells into one.
|
257
|
+
def merge_cells start_row, start_col, end_row, end_col
|
258
|
+
# FIXME enlarge or dup check
|
259
|
+
@merged_cells.push [start_row, end_row, start_col, end_col]
|
260
|
+
end
|
254
261
|
private
|
255
262
|
def index_of_first ary # :nodoc:
|
256
263
|
return unless ary
|
data/spreadsheet.gemspec
CHANGED
@@ -3,7 +3,7 @@ require "rake"
|
|
3
3
|
|
4
4
|
spec = Gem::Specification.new do |s|
|
5
5
|
s.name = "spreadsheet"
|
6
|
-
s.version = "0.6.
|
6
|
+
s.version = "0.6.7"
|
7
7
|
s.summary = "The Spreadsheet Library is designed to read and write Spreadsheet Documents"
|
8
8
|
s.description = "As of version 0.6.0, only Microsoft Excel compatible spreadsheets are supported"
|
9
9
|
s.author = "Masaomi Hatakeyama, Zeno R.R. Davatz"
|
Binary file
|
Binary file
|
@@ -18,6 +18,22 @@ class TestWorksheet < Test::Unit::TestCase
|
|
18
18
|
assert_equal true, sheet.need_number?(0.001)
|
19
19
|
assert_equal true, sheet.need_number?(10000000.0)
|
20
20
|
end
|
21
|
+
def test_write_merged_cells
|
22
|
+
# top/bottom/left/right cell of test range 1/2
|
23
|
+
r1t, r1b, r1l, r1r = 0, 0, 0, 1
|
24
|
+
r2t, r2b, r2l, r2r = 1, 2, 0, 0
|
25
|
+
book = Spreadsheet::Workbook.new
|
26
|
+
sheet = book.create_worksheet
|
27
|
+
sheet.merge_cells(r1t, r1l, r1b, r1r)
|
28
|
+
sheet.merge_cells(r2t, r2l, r2b, r2r)
|
29
|
+
assert_equal [[r1t, r1b, r1l, r1r], [r2t, r2b, r2l, r2r]], sheet.merged_cells
|
30
|
+
io = StringIO.new
|
31
|
+
book.write(io)
|
32
|
+
book2 = Spreadsheet.open(io)
|
33
|
+
sheet2 = book2.worksheet(0)
|
34
|
+
sheet2[0,0] # trigger read_worksheet
|
35
|
+
assert_equal [[r1t, r1b, r1l, r1r], [r2t, r2b, r2l, r2r]], sheet2.merged_cells
|
36
|
+
end
|
21
37
|
end
|
22
38
|
end
|
23
39
|
end
|
data/test/integration.rb
CHANGED
@@ -67,6 +67,29 @@ module Spreadsheet
|
|
67
67
|
assert_equal 0, sheet.column_count
|
68
68
|
assert_nothing_raised do sheet.inspect end
|
69
69
|
end
|
70
|
+
def test_version_excel97__excel2010__utf16
|
71
|
+
Spreadsheet.client_encoding = 'UTF-16LE'
|
72
|
+
assert_equal 'UTF-16LE', Spreadsheet.client_encoding
|
73
|
+
path = File.join @data, 'test_version_excel97_2010.xls'
|
74
|
+
book = Spreadsheet.open path
|
75
|
+
assert_instance_of Excel::Workbook, book
|
76
|
+
assert_equal 8, book.biff_version
|
77
|
+
assert_equal @@iconv.iconv('Microsoft Excel 97/2000/XP'),
|
78
|
+
book.version_string
|
79
|
+
enc = 'UTF-16LE'
|
80
|
+
if defined? Encoding
|
81
|
+
enc = Encoding.find enc
|
82
|
+
end
|
83
|
+
assert_equal enc, book.encoding
|
84
|
+
sheet = book.worksheet 0
|
85
|
+
row = sheet.row 9
|
86
|
+
assert_equal 0.00009, row[0]
|
87
|
+
link = row[1]
|
88
|
+
assert_instance_of Link, link
|
89
|
+
assert_equal @@iconv.iconv('Link-Text'), link
|
90
|
+
assert_equal @@iconv.iconv('http://scm.ywesee.com/spreadsheet'), link.url
|
91
|
+
assert_equal @@iconv.iconv('http://scm.ywesee.com/spreadsheet'), link.href
|
92
|
+
end
|
70
93
|
def test_version_excel97__ooffice__utf16
|
71
94
|
Spreadsheet.client_encoding = 'UTF-16LE'
|
72
95
|
assert_equal 'UTF-16LE', Spreadsheet.client_encoding
|
@@ -1307,5 +1330,13 @@ module Spreadsheet
|
|
1307
1330
|
book.write path
|
1308
1331
|
end
|
1309
1332
|
end
|
1333
|
+
def test_read_merged_cells
|
1334
|
+
path = File.join(@data, 'test_merged_cells.xls')
|
1335
|
+
book = Spreadsheet.open(path)
|
1336
|
+
assert_equal 8, book.biff_version
|
1337
|
+
sheet = book.worksheet(0)
|
1338
|
+
sheet[0,0] # trigger read_worksheet
|
1339
|
+
assert_equal [[2, 4, 1, 1], [3, 3, 2, 3]], sheet.merged_cells
|
1340
|
+
end
|
1310
1341
|
end
|
1311
1342
|
end
|
data/test/suite.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# suite.rb -- spreadsheet --
|
2
|
+
# suite.rb -- spreadsheet -- 22.12.2011 -- jsaak@napalm.hu
|
3
3
|
|
4
4
|
require 'find'
|
5
5
|
|
@@ -8,10 +8,8 @@ here = File.dirname(__FILE__)
|
|
8
8
|
$: << here
|
9
9
|
|
10
10
|
Find.find(here) do |file|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
require file
|
16
|
-
end
|
11
|
+
next if File.basename(file) == 'suite.rb'
|
12
|
+
if file =~ /\.rb$/o
|
13
|
+
require file[here.size+1..-1]
|
14
|
+
end
|
17
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.6.5.9
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
@@ -16,8 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
20
|
-
default_executable:
|
18
|
+
date: 2012-01-18 00:00:00 Z
|
21
19
|
dependencies:
|
22
20
|
- !ruby/object:Gem::Dependency
|
23
21
|
name: ruby-ole
|
@@ -35,21 +33,35 @@ dependencies:
|
|
35
33
|
type: :runtime
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
36
|
+
name: rdoc
|
39
37
|
prerelease: false
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
|
-
- -
|
41
|
+
- - ~>
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
43
|
+
hash: 19
|
46
44
|
segments:
|
47
|
-
-
|
48
|
-
-
|
49
|
-
|
50
|
-
version: 2.9.1
|
45
|
+
- 3
|
46
|
+
- 10
|
47
|
+
version: "3.10"
|
51
48
|
type: :development
|
52
49
|
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: hoe
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 27
|
59
|
+
segments:
|
60
|
+
- 2
|
61
|
+
- 12
|
62
|
+
version: "2.12"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
53
65
|
description: |-
|
54
66
|
The Spreadsheet Library is designed to read and write Spreadsheet Documents.
|
55
67
|
As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
|
@@ -118,10 +130,12 @@ files:
|
|
118
130
|
- test/data/test_empty.xls
|
119
131
|
- test/data/test_formula.xls
|
120
132
|
- test/data/test_long_sst_record.xls
|
133
|
+
- test/data/test_merged_cells.xls
|
121
134
|
- test/data/test_missing_row.xls
|
122
135
|
- test/data/test_version_excel5.xls
|
123
136
|
- test/data/test_version_excel95.xls
|
124
137
|
- test/data/test_version_excel97.xls
|
138
|
+
- test/data/test_version_excel97_2010.xls
|
125
139
|
- test/excel/row.rb
|
126
140
|
- test/excel/writer/workbook.rb
|
127
141
|
- test/excel/writer/worksheet.rb
|
@@ -132,7 +146,6 @@ files:
|
|
132
146
|
- test/workbook.rb
|
133
147
|
- test/worksheet.rb
|
134
148
|
- .gemtest
|
135
|
-
has_rdoc: true
|
136
149
|
homepage: http://spreadsheet.rubyforge.org
|
137
150
|
licenses: []
|
138
151
|
|
@@ -163,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
176
|
requirements: []
|
164
177
|
|
165
178
|
rubyforge_project: spreadsheet
|
166
|
-
rubygems_version: 1.
|
179
|
+
rubygems_version: 1.8.15
|
167
180
|
signing_key:
|
168
181
|
specification_version: 3
|
169
182
|
summary: The Spreadsheet Library is designed to read and write Spreadsheet Documents
|