saxlsx 1.7.1 → 1.8.0
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 +4 -4
- data/lib/saxlsx/rows_collection.rb +1 -15
- data/lib/saxlsx/rows_collection_count_parser.rb +37 -0
- data/lib/saxlsx/style_collection_parser.rb +1 -1
- data/lib/saxlsx/version.rb +1 -1
- data/spec/data/SpecSloppy.xlsx +0 -0
- data/spec/sheet_spec.rb +13 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f695e5e0a2470321d739c99840624c0e0e52808b
|
4
|
+
data.tar.gz: eb92f3e6bec02f95a642274511dc4d4b1abf052a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484bab7c1138454a5a6bcd6cd60e021bb0b2fc58bac5489af6e369b6733ca8804f1c53dce1d95a3c12693b86355c032cdcf73ece0b04167c36a82fc3b24a2845
|
7
|
+
data.tar.gz: 26ba631f53a1d194ff8dbc7c2baedfb366387d66ebc68940f49bb4ca7acc8adf0569c3be6114d710d6850b5882b3a4ac829114063e2a5c52f7ff03d8593e2109
|
@@ -16,21 +16,7 @@ module Saxlsx
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def count
|
19
|
-
|
20
|
-
@count = 0
|
21
|
-
begin
|
22
|
-
@sheet.each_line('>') do |line|
|
23
|
-
matches = line.match(/<dimension ref="[^:]+:[A-Z]*(\d+)"/)
|
24
|
-
if matches
|
25
|
-
@count = matches[1].to_i
|
26
|
-
break if @count
|
27
|
-
end
|
28
|
-
end
|
29
|
-
ensure
|
30
|
-
@sheet.rewind
|
31
|
-
end
|
32
|
-
end
|
33
|
-
@count
|
19
|
+
@count ||= RowsCollectionCountParser.count @sheet
|
34
20
|
end
|
35
21
|
|
36
22
|
alias :size :count
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Saxlsx
|
3
|
+
class RowsCollectionCountParser < Ox::Sax
|
4
|
+
def self.count(data, &block)
|
5
|
+
parser = new
|
6
|
+
catch :abort do
|
7
|
+
SaxParser.parse parser, data
|
8
|
+
end
|
9
|
+
parser.count
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :count
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@count = 0
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_element(name)
|
19
|
+
@current_element = name
|
20
|
+
if name == :row
|
21
|
+
@count += 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def attr(name, value)
|
26
|
+
if @current_element == :dimension
|
27
|
+
if name == :ref && value
|
28
|
+
matches = value.match(/[^:]+:[A-Z]*(\d+)/)
|
29
|
+
if matches
|
30
|
+
@count = matches[1].to_i
|
31
|
+
throw :abort
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/saxlsx/version.rb
CHANGED
Binary file
|
data/spec/sheet_spec.rb
CHANGED
@@ -93,6 +93,19 @@ describe Sheet do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
it 'Handle missing fonts and dimension tags' do
|
97
|
+
filename = "#{File.dirname(__FILE__)}/data/SpecSloppy.xlsx"
|
98
|
+
|
99
|
+
Workbook.open filename do |w|
|
100
|
+
w.sheets[0].rows.count.should eq 85
|
101
|
+
headers = w.sheets[0].rows.first
|
102
|
+
headers.count.should eq 52
|
103
|
+
headers.each do |str|
|
104
|
+
str.should eq "X"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
96
109
|
context 'with 1904 date system' do
|
97
110
|
let(:filename) { "#{File.dirname(__FILE__)}/data/Spec1904.xlsx" }
|
98
111
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saxlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgars Beigarts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/saxlsx/column_name_generator.rb
|
115
115
|
- lib/saxlsx/file_system.rb
|
116
116
|
- lib/saxlsx/rows_collection.rb
|
117
|
+
- lib/saxlsx/rows_collection_count_parser.rb
|
117
118
|
- lib/saxlsx/rows_collection_parser.rb
|
118
119
|
- lib/saxlsx/sax_parser.rb
|
119
120
|
- lib/saxlsx/shared_string_collection.rb
|
@@ -132,6 +133,7 @@ files:
|
|
132
133
|
- spec/data/Spec1904.xlsx
|
133
134
|
- spec/data/SpecInlineStrings.xlsx
|
134
135
|
- spec/data/SpecNumberFormat.xlsx
|
136
|
+
- spec/data/SpecSloppy.xlsx
|
135
137
|
- spec/sheet_spec.rb
|
136
138
|
- spec/spec_helper.rb
|
137
139
|
- spec/workbook_spec.rb
|
@@ -166,6 +168,7 @@ test_files:
|
|
166
168
|
- spec/data/Spec1904.xlsx
|
167
169
|
- spec/data/SpecInlineStrings.xlsx
|
168
170
|
- spec/data/SpecNumberFormat.xlsx
|
171
|
+
- spec/data/SpecSloppy.xlsx
|
169
172
|
- spec/sheet_spec.rb
|
170
173
|
- spec/spec_helper.rb
|
171
174
|
- spec/workbook_spec.rb
|