spreadsheet 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +5 -5
- data/History.md +41 -0
- data/Rakefile +1 -1
- data/bin/xlsopcodes +14 -13
- data/lib/spreadsheet/excel/internals.rb +1 -1
- data/lib/spreadsheet/excel/reader.rb +7 -5
- data/lib/spreadsheet/worksheet.rb +16 -12
- data/lib/spreadsheet.rb +1 -1
- data/spreadsheet.gemspec +3 -4
- data/test/integration.rb +7 -7
- data/test/worksheet.rb +21 -4
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 153daf0819e113f6da9726a43b23494e30497ae3
|
4
|
+
data.tar.gz: 811ecec4ac2a63d3c431ed6dc324ff69c9a189ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc43a69c6d5817d2132f05a9544546b070e5512c19c002aa7280ab2879a8b3f0297890f9bea890efe6a082b69a59a226313f4df47e4b5e65e7a08fb81ed894b
|
7
|
+
data.tar.gz: 2ea734d18f429276707f0823f2703cda52fcc057d6aa04eea4b065db1f08299c3f2a94fc4fb1b61fde2080d5a63fe479ecf857bc14d47d92fa7b1a1331537c02
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
hoe (3.
|
5
|
-
rake (>= 0.8, <
|
4
|
+
hoe (3.17.1)
|
5
|
+
rake (>= 0.8, < 13.0)
|
6
6
|
minitest (5.8.2)
|
7
7
|
power_assert (0.2.4)
|
8
|
-
rake (10.
|
9
|
-
ruby-ole (1.2.
|
8
|
+
rake (10.5.0)
|
9
|
+
ruby-ole (1.2.12.1)
|
10
10
|
test-unit (3.1.5)
|
11
11
|
power_assert
|
12
12
|
|
@@ -20,4 +20,4 @@ DEPENDENCIES
|
|
20
20
|
test-unit
|
21
21
|
|
22
22
|
BUNDLED WITH
|
23
|
-
1.
|
23
|
+
1.17.2
|
data/History.md
CHANGED
@@ -1,3 +1,44 @@
|
|
1
|
+
### 1.2.0 17.2.2019
|
2
|
+
Author: James McLaren <jamesmclaren555@gmail.com>
|
3
|
+
* spreadsheet-1.2.0.gem released
|
4
|
+
|
5
|
+
### 1.1.9 26.1.2019
|
6
|
+
Author: Nick Weiland <nickweiland@gmail.com>
|
7
|
+
* spreadsheet-1.1.9.gem released.
|
8
|
+
|
9
|
+
### 1.1.8 / 20.08.2018
|
10
|
+
Author: VitaliyAdamkov <adamkov@tex.ua>
|
11
|
+
Date: Mon Aug 20 09:48:31 2018 +0300
|
12
|
+
|
13
|
+
* Cancel :lazy usage
|
14
|
+
* Use lazy select to speed up a little
|
15
|
+
* Omit rails :try usage
|
16
|
+
* stub for :postread_worksheet method
|
17
|
+
* sometimes it selects empty array..
|
18
|
+
|
19
|
+
Author: 545ch4 <s@rprojekt.org>
|
20
|
+
Date: Wed Mar 28 15:33:04 2018 +0200
|
21
|
+
|
22
|
+
* [ruby-2.4] Fix weird first line of spreadsheet.gemspec
|
23
|
+
* Doesn't seem to be a valid .gemspec command/field.
|
24
|
+
|
25
|
+
### 1.1.7 / 15.03.2018
|
26
|
+
|
27
|
+
Author: Maarten Brouwers <github@murb.nl>
|
28
|
+
Date: Thu Mar 15 15:10:23 2018 +0100
|
29
|
+
|
30
|
+
* shadowing outer local variable - i
|
31
|
+
|
32
|
+
* Running rake resulted in the following warning: `lib/spreadsheet/worksheet.rb:345: warning: shadowing outer local variable - i`; this patch fixes that.
|
33
|
+
|
34
|
+
### 1.1.6 / 12.03.2018
|
35
|
+
|
36
|
+
Author: Todd Hambley <thambley@travelleaders.com>
|
37
|
+
Date: Mon Mar 12 14:20:39 2018 -0400
|
38
|
+
|
39
|
+
* fix reject for ruby 1.8.7
|
40
|
+
* fix using invalid code pages when writing workbook
|
41
|
+
|
1
42
|
### 1.1.5 / 20.11.2017
|
2
43
|
|
3
44
|
Author: Paco Guzmán <pacoguzman@users.noreply.github.com>
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ ENV['RDOCOPT'] = '-c utf8'
|
|
13
13
|
Hoe.plugin :git
|
14
14
|
|
15
15
|
Hoe.spec('spreadsheet') do |p|
|
16
|
-
|
16
|
+
p.developer('Hannes F. Wyss, Masaomi Hatakeyama, Zeno R.R. Davatz','hannes.wyss@gmail.com, mhatakeyama@ywesee.com, zdavatz@ywesee.com')
|
17
17
|
p.remote_rdoc_dir = 'spreadsheet'
|
18
18
|
p.extra_deps << ['ruby-ole', '>=1.0']
|
19
19
|
p.email = "zdavatz@ywesee.com"
|
data/bin/xlsopcodes
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
#
|
4
|
-
# This file was generated by Bundler.
|
5
|
-
#
|
6
|
-
# The application 'xlsopcodes' is installed as part of a gem, and
|
7
|
-
# this file is here to facilitate running it.
|
8
|
-
#
|
9
2
|
|
10
|
-
require
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
-
Pathname.new(__FILE__).realpath)
|
3
|
+
require 'spreadsheet'
|
13
4
|
|
14
|
-
|
15
|
-
require "bundler/setup"
|
5
|
+
source, target = ARGV
|
16
6
|
|
17
|
-
|
7
|
+
if source.nil?
|
8
|
+
puts "Usage: #{$0} <source> [<target>]"
|
9
|
+
exit -1
|
10
|
+
end
|
11
|
+
|
12
|
+
target = target ? File.open(target, 'w') : STDOUT
|
13
|
+
|
14
|
+
reader = Spreadsheet::Excel::Reader.new :print_opcodes => target
|
15
|
+
reader.setup File.open(source)
|
16
|
+
|
17
|
+
while tuple = reader.get_next_chunk
|
18
|
+
end
|
@@ -54,7 +54,7 @@ module Internals
|
|
54
54
|
32768 => "MACROMAN",
|
55
55
|
32769 => "WINDOWS-1252", #(Latin I) (BIFF2-BIFF3)
|
56
56
|
}
|
57
|
-
SEGAPEDOC = CODEPAGES.invert
|
57
|
+
SEGAPEDOC = CODEPAGES.reject { |k, _v| k >= 21010 }.invert
|
58
58
|
# color_codes according to http://support.softartisans.com/kbview_1205.aspx
|
59
59
|
# synonyms are in comments when reverse lookup
|
60
60
|
COLOR_CODES = {
|
@@ -125,11 +125,12 @@ class Reader
|
|
125
125
|
#So link the noteObject(text) to the note (with author, position)
|
126
126
|
#TODO
|
127
127
|
@noteList.each do |i|
|
128
|
-
|
129
|
-
if
|
128
|
+
matching_objs = @noteObjList.select { |j| j.objID == i.objID }
|
129
|
+
if matching_objs.length > 1
|
130
130
|
puts "ERROR - more than one matching object ID!"
|
131
131
|
end
|
132
|
-
|
132
|
+
matching_obj = matching_objs.first
|
133
|
+
i.text = matching_obj.nil? ? '' : matching_obj.text
|
133
134
|
worksheet.add_note i.row, i.col, i.text
|
134
135
|
end
|
135
136
|
end
|
@@ -398,10 +399,10 @@ class Reader
|
|
398
399
|
end
|
399
400
|
formula.value = value
|
400
401
|
elsif rtype == 0
|
401
|
-
pos, op,
|
402
|
+
pos, op, _len, work = get_next_chunk
|
402
403
|
if op == :sharedfmla
|
403
404
|
## TODO: formula-support in 0.8.0
|
404
|
-
pos, op,
|
405
|
+
pos, op, _len, work = get_next_chunk
|
405
406
|
end
|
406
407
|
if op == :string
|
407
408
|
formula.value = client read_string(work, 2), @workbook.encoding
|
@@ -851,6 +852,7 @@ class Reader
|
|
851
852
|
@detected_rows = {}
|
852
853
|
@noteObjList = []
|
853
854
|
@noteList = []
|
855
|
+
@noteObject = nil
|
854
856
|
previous = nil
|
855
857
|
while tuple = get_next_chunk
|
856
858
|
pos, op, len, work = tuple
|
@@ -153,9 +153,13 @@ module Spreadsheet
|
|
153
153
|
# If the argument skip is given, #each iterates from that row until but
|
154
154
|
# omitting the first unused Row, effectively skipping the first _skip_ Rows
|
155
155
|
# from the top of the Worksheet.
|
156
|
-
def each
|
157
|
-
skip.upto(dimensions[1] - 1)
|
158
|
-
|
156
|
+
def each(skip=dimensions[0], &block)
|
157
|
+
rows = skip.upto(dimensions[1] - 1).map { |index| row(index) }.to_enum
|
158
|
+
|
159
|
+
if block_given?
|
160
|
+
rows.each(&block)
|
161
|
+
else
|
162
|
+
rows
|
159
163
|
end
|
160
164
|
end
|
161
165
|
def encoding # :nodoc:
|
@@ -314,7 +318,7 @@ module Spreadsheet
|
|
314
318
|
|
315
319
|
def compact!
|
316
320
|
recalculate_dimensions
|
317
|
-
|
321
|
+
|
318
322
|
# detect first non-nil non-empty row if given first row is empty or nil
|
319
323
|
if row(@dimensions[0]).empty? || row(@dimensions[0]).compact.join('').empty?
|
320
324
|
(@dimensions[0]...@dimensions[1]).each do |i|
|
@@ -325,19 +329,19 @@ module Spreadsheet
|
|
325
329
|
|
326
330
|
# detect last non-nil non-empty row if given last row is empty or nil
|
327
331
|
if row(@dimensions[1] - 1).empty? || row(@dimensions[1] - 1).compact.join('').empty?
|
328
|
-
|
332
|
+
row_size = @dimensions[1] - 1
|
329
333
|
@dimensions[1] = @dimensions[0]
|
330
334
|
# divide and conquer
|
331
|
-
while(
|
332
|
-
if row(
|
333
|
-
|
335
|
+
while(row_size - @dimensions[1] > 1) do
|
336
|
+
if row(row_size).empty? || row(row_size).compact.join('').empty?
|
337
|
+
row_size = @dimensions[1] + (((row_size - @dimensions[1]) + 1) / 2).to_i
|
334
338
|
else
|
335
|
-
_i = ((
|
336
|
-
@dimensions[1] =
|
337
|
-
|
339
|
+
_i = ((row_size - @dimensions[1]) / 2).to_i + 1
|
340
|
+
@dimensions[1] = row_size
|
341
|
+
row_size = row_size + _i
|
338
342
|
end
|
339
343
|
end
|
340
|
-
@dimensions[1] =
|
344
|
+
@dimensions[1] = row_size + 1
|
341
345
|
end
|
342
346
|
|
343
347
|
# detect first non-empty non-nil column if first column is empty or nil
|
data/lib/spreadsheet.rb
CHANGED
data/spreadsheet.gemspec
CHANGED
@@ -3,14 +3,14 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'spreadsheet'
|
5
5
|
|
6
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "spreadsheet"
|
8
8
|
spec.version = Spreadsheet::VERSION
|
9
9
|
spec.homepage = "https://github.com/zdavatz/spreadsheet"
|
10
10
|
spec.summary = "The Spreadsheet Library is designed to read and write Spreadsheet Documents"
|
11
11
|
spec.description = "As of version 0.6.0, only Microsoft Excel compatible spreadsheets are supported"
|
12
|
-
spec.author = "Masaomi Hatakeyama, Zeno R.R. Davatz"
|
13
|
-
spec.email = "mhatakeyama@ywesee.com, zdavatz@ywesee.com"
|
12
|
+
spec.author = "Hannes F. Wyss, Masaomi Hatakeyama, Zeno R.R. Davatz"
|
13
|
+
spec.email = "hannes.wyss@gmail.com, mhatakeyama@ywesee.com, zdavatz@ywesee.com"
|
14
14
|
spec.platform = Gem::Platform::RUBY
|
15
15
|
spec.license = "GPL-3.0"
|
16
16
|
spec.files = Dir.glob("{bin,lib,test}/**/*") + Dir.glob("*.txt")
|
@@ -22,4 +22,3 @@ spec = Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.homepage = 'https://github.com/zdavatz/spreadsheet/'
|
24
24
|
end
|
25
|
-
|
data/test/integration.rb
CHANGED
@@ -70,7 +70,7 @@ module Spreadsheet
|
|
70
70
|
def test_missing_format
|
71
71
|
path = File.join @data, 'test_missing_format.xls'
|
72
72
|
assert_nothing_thrown do
|
73
|
-
|
73
|
+
Spreadsheet.open(path, "rb")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
def test_version_excel97__excel2010__utf16
|
@@ -749,7 +749,7 @@ module Spreadsheet
|
|
749
749
|
sheet1 = book.create_worksheet
|
750
750
|
str1 = 'My Shared String'
|
751
751
|
str2 = 'Another Shared String'
|
752
|
-
assert_equal 1, (str1.size + str2.size) % 2,
|
752
|
+
assert_equal 1, (str1.size + str2.size) % 2,
|
753
753
|
"str3 should start at an odd offset to test splitting of wide strings"
|
754
754
|
str3 = '–––––––––– ' * 1000
|
755
755
|
str4 = '1234567890 ' * 1000
|
@@ -1211,8 +1211,8 @@ module Spreadsheet
|
|
1211
1211
|
book = Spreadsheet::Workbook.new
|
1212
1212
|
sheet = book.create_worksheet
|
1213
1213
|
(0..200).each { |i| sheet.row(i).push "ëçáéíóú" }
|
1214
|
-
assert_nothing_raised do
|
1215
|
-
book.write StringIO.new("", "w+")
|
1214
|
+
assert_nothing_raised do
|
1215
|
+
book.write StringIO.new("", "w+")
|
1216
1216
|
end
|
1217
1217
|
end
|
1218
1218
|
|
@@ -1257,7 +1257,7 @@ module Spreadsheet
|
|
1257
1257
|
str1 = "Frozen String.".freeze
|
1258
1258
|
sheet1[0,0] = str1
|
1259
1259
|
sheet1.row(0).push str1
|
1260
|
-
assert_nothing_raised do
|
1260
|
+
assert_nothing_raised do
|
1261
1261
|
book.write path
|
1262
1262
|
end
|
1263
1263
|
end
|
@@ -1290,7 +1290,7 @@ module Spreadsheet
|
|
1290
1290
|
sheet1 = book.create_worksheet
|
1291
1291
|
(sheet1.row(0).format 0).border = :hair
|
1292
1292
|
(sheet1.row(0).format 0).border_color = :brown
|
1293
|
-
assert_nothing_raised do
|
1293
|
+
assert_nothing_raised do
|
1294
1294
|
book.write path
|
1295
1295
|
end
|
1296
1296
|
book2 = Spreadsheet.open path
|
@@ -1391,7 +1391,7 @@ module Spreadsheet
|
|
1391
1391
|
path = File.join @var, 'test_write_worksheet_visibility.xls'
|
1392
1392
|
sheet1 = book.create_worksheet
|
1393
1393
|
sheet1.visibility = :hidden
|
1394
|
-
|
1394
|
+
_sheet2 = book.create_worksheet
|
1395
1395
|
assert_nothing_raised do
|
1396
1396
|
book.write path
|
1397
1397
|
end
|
data/test/worksheet.rb
CHANGED
@@ -108,18 +108,35 @@ module Spreadsheet
|
|
108
108
|
assert_equal 6, @book.formats.length
|
109
109
|
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def test_freeze_panel!
|
113
113
|
assert_equal 0, @sheet.froze_top
|
114
114
|
assert_equal 0, @sheet.froze_left
|
115
115
|
assert_equal false, @sheet.has_frozen_panel?
|
116
|
-
|
116
|
+
|
117
117
|
@sheet.freeze!(2, 3)
|
118
118
|
assert_equal 2, @sheet.froze_top
|
119
119
|
assert_equal 3, @sheet.froze_left
|
120
120
|
assert_equal true, @sheet.has_frozen_panel?
|
121
|
-
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_each_with_skip
|
125
|
+
@sheet[0, 0] = 'foo'
|
126
|
+
@sheet[1, 0] = 'bar'
|
127
|
+
|
128
|
+
assert_equal @sheet.each(1).count, 1
|
129
|
+
assert_equal @sheet.each(1).first[0], 'bar'
|
122
130
|
end
|
123
|
-
|
131
|
+
|
132
|
+
def test_each_with_index
|
133
|
+
@sheet[0, 0] = 'foo'
|
134
|
+
@sheet[1, 0] = 'bar'
|
135
|
+
|
136
|
+
@sheet.each.with_index do |row, index|
|
137
|
+
assert_equal row[0], @sheet[index, 0]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
124
141
|
end
|
125
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
7
|
+
- Hannes F. Wyss, Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-ole
|
@@ -28,30 +28,36 @@ dependencies:
|
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '7'
|
34
37
|
type: :development
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '4.0'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '7'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: hoe
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
53
|
+
version: '3.17'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
60
|
+
version: '3.17'
|
55
61
|
description: |-
|
56
62
|
The Spreadsheet Library is designed to read and write Spreadsheet Documents.
|
57
63
|
As of version 0.6.0, only Microsoft Excel compatible spreadsheets are
|