spreadsheet 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +7 -0
- data/README.md +1 -1
- data/lib/spreadsheet.rb +1 -1
- data/lib/spreadsheet/excel/internals.rb +6 -0
- data/lib/spreadsheet/excel/reader.rb +3 -2
- data/lib/spreadsheet/excel/writer/workbook.rb +2 -1
- data/lib/spreadsheet/worksheet.rb +3 -0
- data/test/integration.rb +23 -0
- metadata +66 -87
data/History.md
CHANGED
data/README.md
CHANGED
@@ -69,7 +69,7 @@ You will get a deprecated warning about iconv when using spreadsheet with Ruby
|
|
69
69
|
|
70
70
|
## Examples
|
71
71
|
|
72
|
-
* Have a look at the GUIDE: https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.
|
72
|
+
* Have a look at the GUIDE: https://github.com/zdavatz/spreadsheet/blob/master/GUIDE.md
|
73
73
|
* Also look at: https://gist.github.com/phollyer/1214475
|
74
74
|
|
75
75
|
## Installation
|
data/lib/spreadsheet.rb
CHANGED
@@ -262,6 +262,12 @@ module Internals
|
|
262
262
|
:bold => 700,
|
263
263
|
:normal => 400,
|
264
264
|
}
|
265
|
+
WORKSHEET_VISIBILITIES = {
|
266
|
+
0x00 => :visible,
|
267
|
+
0x01 => :hidden,
|
268
|
+
0x02 => :strong_hidden
|
269
|
+
}
|
270
|
+
SEITILIBISIV_TEEHSKROW = WORKSHEET_VISIBILITIES.invert
|
265
271
|
LEAP_ERROR = Date.new 1900, 2, 28
|
266
272
|
OPCODES = {
|
267
273
|
:blank => 0x0201, # BLANK ➜ 6.7
|
@@ -178,7 +178,7 @@ class Reader
|
|
178
178
|
# 6 var. Sheet name: BIFF5/BIFF7: Byte string,
|
179
179
|
# 8-bit string length (➜ 3.3)
|
180
180
|
# BIFF8: Unicode string, 8-bit string length (➜ 3.4)
|
181
|
-
offset,
|
181
|
+
offset, visibility, _ = work.unpack("VC2")
|
182
182
|
name = client read_string(work[6..-1]), @workbook.encoding
|
183
183
|
if @boundsheets
|
184
184
|
@boundsheets[0] += 1
|
@@ -190,7 +190,8 @@ class Reader
|
|
190
190
|
@workbook.add_worksheet Worksheet.new(:name => name,
|
191
191
|
:ole => @book,
|
192
192
|
:offset => offset,
|
193
|
-
:reader => self
|
193
|
+
:reader => self,
|
194
|
+
:visibility => WORKSHEET_VISIBILITIES[visibility])
|
194
195
|
end
|
195
196
|
def read_codepage work, pos, len
|
196
197
|
codepage, _ = work.unpack 'v'
|
@@ -147,11 +147,12 @@ class Workbook < Spreadsheet::Writer
|
|
147
147
|
offset += worksheet.boundsheet_size
|
148
148
|
end
|
149
149
|
worksheets.each do |worksheet|
|
150
|
+
visibility = SEITILIBISIV_TEEHSKROW[worksheet.worksheet.visibility]
|
150
151
|
data = [
|
151
152
|
offset, # Absolute stream position of the BOF record of the sheet
|
152
153
|
# represented by this record. This field is never encrypted
|
153
154
|
# in protected files.
|
154
|
-
|
155
|
+
visibility, # Visibility: 0x00 = Visible
|
155
156
|
# 0x01 = Hidden
|
156
157
|
# 0x02 = Strong hidden (see below)
|
157
158
|
0x00, # Sheet type: 0x00 = Worksheet
|
@@ -26,9 +26,11 @@ module Spreadsheet
|
|
26
26
|
# default.
|
27
27
|
class Worksheet
|
28
28
|
include Spreadsheet::Encodings
|
29
|
+
include Spreadsheet::Datatypes
|
29
30
|
include Enumerable
|
30
31
|
attr_accessor :name, :selected, :workbook, :password_hash
|
31
32
|
attr_reader :rows, :columns, :merged_cells, :margins, :pagesetup
|
33
|
+
enum :visibility, :visible, :hidden, :strong_hidden
|
32
34
|
def initialize opts={}
|
33
35
|
@default_format = nil
|
34
36
|
@selected = opts[:selected]
|
@@ -52,6 +54,7 @@ module Spreadsheet
|
|
52
54
|
@merged_cells = []
|
53
55
|
@protected = false
|
54
56
|
@password_hash = 0
|
57
|
+
@visibility = opts[:visibility]
|
55
58
|
end
|
56
59
|
def active # :nodoc:
|
57
60
|
warn "Worksheet#active is deprecated. Please use Worksheet#selected instead."
|
data/test/integration.rb
CHANGED
@@ -1327,6 +1327,29 @@ module Spreadsheet
|
|
1327
1327
|
assert_equal(3.0, sheet2.margins[:left])
|
1328
1328
|
end
|
1329
1329
|
|
1330
|
+
def test_read_worksheet_visibility
|
1331
|
+
path = File.join @data, 'test_worksheet_visibility.xls'
|
1332
|
+
book = Spreadsheet.open path
|
1333
|
+
assert_instance_of Excel::Workbook, book
|
1334
|
+
assert_equal(:visible, book.worksheet(0).visibility)
|
1335
|
+
assert_equal(:hidden, book.worksheet(1).visibility)
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
def test_write_worksheet_visibility
|
1339
|
+
book = Spreadsheet::Workbook.new
|
1340
|
+
path = File.join @var, 'test_write_worksheet_visibility.xls'
|
1341
|
+
sheet1 = book.create_worksheet
|
1342
|
+
sheet1.visibility = :hidden
|
1343
|
+
sheet2 = book.create_worksheet
|
1344
|
+
assert_nothing_raised do
|
1345
|
+
book.write path
|
1346
|
+
end
|
1347
|
+
book2 = Spreadsheet.open path
|
1348
|
+
assert_instance_of Excel::Workbook, book2
|
1349
|
+
assert_equal(:hidden, book2.worksheet(0).visibility)
|
1350
|
+
assert_equal(:visible, book2.worksheet(1).visibility)
|
1351
|
+
end
|
1352
|
+
|
1330
1353
|
private
|
1331
1354
|
|
1332
1355
|
# Validates the workbook's SST
|
metadata
CHANGED
@@ -1,86 +1,74 @@
|
|
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
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
- 0
|
10
|
-
version: 0.9.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
type: :runtime
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 15
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
version: "1.0"
|
32
|
-
requirement: *id001
|
33
|
-
prerelease: false
|
12
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
34
15
|
name: ruby-ole
|
35
|
-
|
36
|
-
type: :development
|
37
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
38
17
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
- 4
|
45
|
-
- 0
|
46
|
-
version: "4.0"
|
47
|
-
requirement: *id002
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
48
23
|
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
49
31
|
name: rdoc
|
50
|
-
|
51
|
-
type: :development
|
52
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
53
33
|
none: false
|
54
|
-
requirements:
|
34
|
+
requirements:
|
55
35
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 3
|
60
|
-
- 6
|
61
|
-
version: "3.6"
|
62
|
-
requirement: *id003
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.10'
|
38
|
+
type: :development
|
63
39
|
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.10'
|
46
|
+
- !ruby/object:Gem::Dependency
|
64
47
|
name: hoe
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.13'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.13'
|
62
|
+
description: ''
|
63
|
+
email:
|
72
64
|
- mhatakeyama@ywesee.com, zdavatz@ywesee.com
|
73
|
-
executables:
|
65
|
+
executables:
|
74
66
|
- xlsopcodes
|
75
67
|
extensions: []
|
76
|
-
|
77
|
-
extra_rdoc_files:
|
78
|
-
- GUIDE.md
|
79
|
-
- History.md
|
68
|
+
extra_rdoc_files:
|
80
69
|
- LICENSE.txt
|
81
70
|
- Manifest.txt
|
82
|
-
|
83
|
-
files:
|
71
|
+
files:
|
84
72
|
- .gitignore
|
85
73
|
- .travis.yml
|
86
74
|
- GUIDE.md
|
@@ -161,39 +149,30 @@ files:
|
|
161
149
|
- test/workbook_protection.rb
|
162
150
|
- test/worksheet.rb
|
163
151
|
- .gemtest
|
164
|
-
homepage:
|
152
|
+
homepage:
|
165
153
|
licenses: []
|
166
|
-
|
167
154
|
post_install_message:
|
168
|
-
rdoc_options:
|
155
|
+
rdoc_options:
|
169
156
|
- --main
|
170
|
-
- README.
|
171
|
-
require_paths:
|
157
|
+
- README.txt
|
158
|
+
require_paths:
|
172
159
|
- lib
|
173
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
161
|
none: false
|
175
|
-
requirements:
|
176
|
-
- -
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
|
179
|
-
|
180
|
-
- 0
|
181
|
-
version: "0"
|
182
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
167
|
none: false
|
184
|
-
requirements:
|
185
|
-
- -
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
|
188
|
-
segments:
|
189
|
-
- 0
|
190
|
-
version: "0"
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
191
172
|
requirements: []
|
192
|
-
|
193
173
|
rubyforge_project: spreadsheet
|
194
174
|
rubygems_version: 1.8.25
|
195
175
|
signing_key:
|
196
176
|
specification_version: 3
|
197
|
-
summary:
|
177
|
+
summary: ''
|
198
178
|
test_files: []
|
199
|
-
|