read_xls 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e0b7f7a9fe0bc349e97f2bfebdd52f667d66b0d
4
- data.tar.gz: d17fcbb0b353a085527b1c99e718541c973a7e3e
3
+ metadata.gz: 7359733a668f39eb9e9ac53611cdb4554dd61dac
4
+ data.tar.gz: 8626e2e68bd9182d18eb12563dbe9acaf6e1cd50
5
5
  SHA512:
6
- metadata.gz: 077662dd44d4b1aaef8fc044977762a895cda469664ac310f2c425ec6b375b27f4fafcfa0b5bec8a5c6c0b4e66fcba618eb7a5ae1870f4e3cf04f90da4659155
7
- data.tar.gz: 64d26284538dcafc6f09de637ba807068f1e490c6ef22021dd05e8dd8c4b1ac8be82a6c5ee4bf79dd075a4fb1602175a7b7347a5b57b73db6faf5662c2bc4335
6
+ metadata.gz: 4e12ef70d72a370ae60c1b81a5b5d757b64bc363b6b5cec2eeb89beaaa54f30cf687eca3876c07647ef42fc88d8c2a7f035e4a1b86b93e64be3799bfd934d635
7
+ data.tar.gz: 6d9ac42b3e7cb4ad3ce8cd0600bcd31831f55a3ff94fc90478ae65a4c6bdff9133c0ac2ebde31be3e17bf084afb9cac35048b8d3d05608fb77449cdfdaf18425
data/README.md CHANGED
@@ -39,7 +39,7 @@ end
39
39
 
40
40
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
41
 
42
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+ To install this gem onto your local machine, run `bundle exec rake install`.
43
43
 
44
44
  ## Contributing
45
45
 
@@ -122,6 +122,7 @@ module ReadXls
122
122
  BOOKEXT = 0x0863
123
123
  COMPRESSPICTURES = 0x089b
124
124
  COMPAT12 = 0x088c
125
+ STANDARDWIDTH = 0x0099
125
126
  UNKNOWN1 = 0x105c
126
127
  UNKNOWN2 = 0x08d6
127
128
  UNKNOWN3 = 0x00ef
@@ -218,10 +219,15 @@ module ReadXls
218
219
  BOOKEXT => Skip,
219
220
  COMPRESSPICTURES => Skip,
220
221
  COMPAT12 => Skip,
222
+ STANDARDWIDTH => Skip,
223
+ MULBLANK => Skip,
224
+ SCL => Skip,
225
+ MERGEDCELLS => Skip,
226
+ SUPBOOK => Skip,
227
+ EXTERNSHEET => Skip,
221
228
  UNKNOWN1 => Skip,
222
229
  UNKNOWN2 => Skip,
223
230
  UNKNOWN3 => Skip,
224
- MULBLANK => Skip,
225
231
 
226
232
  ARRAY => NotImplemented,
227
233
  SHRFMLA => NotImplemented,
@@ -232,7 +238,6 @@ module ReadXls
232
238
  EOF => NotImplemented,
233
239
  HLINK => NotImplemented,
234
240
  LABEL => NotImplemented,
235
- MERGEDCELLS => NotImplemented,
236
241
  RSTRING => NotImplemented,
237
242
  SHAREDFMLA => NotImplemented,
238
243
  UNCALCED => NotImplemented,
@@ -240,13 +245,10 @@ module ReadXls
240
245
  SCENPROTECT => NotImplemented,
241
246
  WRITEPROT => NotImplemented,
242
247
  FILESHARING => NotImplemented,
243
- SUPBOOK => NotImplemented,
244
248
  EXTERNNAME => NotImplemented,
245
249
  XCT => NotImplemented,
246
250
  CRN => NotImplemented,
247
- EXTERNSHEET => NotImplemented,
248
251
  NAME => NotImplemented,
249
- SCL => NotImplemented,
250
252
  PANE => NotImplemented,
251
253
  SORT => NotImplemented,
252
254
  NOTE => NotImplemented,
@@ -1,8 +1,6 @@
1
1
  module ReadXls
2
2
  module RecordHandler
3
3
  class Boundsheet < ::ReadXls::RecordHandler::Base
4
- BYTE_LENGTH = 2
5
-
6
4
  attr_accessor :position
7
5
 
8
6
  def call
@@ -29,15 +27,15 @@ module ReadXls
29
27
  end
30
28
 
31
29
  def read_data(bytes)
32
- val = biff[position, bytes]
30
+ val = biff.byteslice(position, bytes)
33
31
  self.position += bytes
34
32
  val
35
33
  end
36
34
 
37
35
 
38
36
  def read_byte
39
- val = biff[position, BYTE_LENGTH].unpack("v")
40
- self.position += BYTE_LENGTH
37
+ val = biff.byteslice(position, 2).unpack("v")
38
+ self.position += 2
41
39
  val.first || raise(ParsingFailedError, "expected to get value, got nil")
42
40
  end
43
41
  end
@@ -1,10 +1,9 @@
1
1
  module ReadXls
2
2
  class Spreadsheet
3
- ParsingFailedError = Class.new(StandardError)
4
- BYTE_LENGTH = 2
5
-
6
3
  attr_accessor :biff, :position, :workbook
7
4
 
5
+ ParsingFailedError = Class.new(StandardError)
6
+
8
7
  def self.parse(xls_file_path)
9
8
  new(
10
9
  Ole::Storage.open(xls_file_path, "rb+")
@@ -27,10 +26,10 @@ module ReadXls
27
26
  workbook_builder = WorkbookBuilder.new(biff)
28
27
 
29
28
  loop do
30
- record_number = read_byte
29
+ record_number = read_word
31
30
  break if record_number == ::ReadXls::RecordHandler::EOF
32
31
 
33
- record_length = read_byte
32
+ record_length = read_word
34
33
  record_data = read_data(record_length)
35
34
 
36
35
  ::ReadXls::RecordHandler.call(
@@ -45,15 +44,14 @@ module ReadXls
45
44
  end
46
45
 
47
46
  def read_data(bytes)
48
- val = biff[position, bytes]
47
+ val = biff.byteslice(position, bytes)
49
48
  self.position += bytes
50
49
  val
51
50
  end
52
51
 
53
-
54
- def read_byte
55
- val = biff[position, BYTE_LENGTH].unpack("v")
56
- self.position += BYTE_LENGTH
52
+ def read_word
53
+ val = biff.byteslice(position, 2).unpack("v")
54
+ self.position += 2
57
55
  val.first || raise(ParsingFailedError, "expected to get value, got nil")
58
56
  end
59
57
  end
@@ -1,3 +1,3 @@
1
1
  module ReadXls
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: read_xls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - P2Binvestor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-ole
@@ -77,6 +77,7 @@ files:
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
79
  - CODE_OF_CONDUCT.md
80
+ - Excel97-2007BinaryFileFormat.xls.Specification.pdf
80
81
  - Gemfile
81
82
  - LICENSE
82
83
  - README.md