ooxml_excel 0.0.3.3 → 0.0.3.4
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/ooxml_excel/sheet.rb +33 -28
- data/lib/ooxml_excel/styles.rb +5 -2
- data/lib/ooxml_excel/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20ed498375c405e27133da180b758ea5380dcd86
|
4
|
+
data.tar.gz: 1a15b0d9cac077fe649fe0f23dfb4a4d0e80471f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a283b2355dd5eb4fab3a6bfec94f0aaf79f74efe4fdf52b01057193883b44ffc5ed35f1e8d802287cd712ecdba096cfafdf23de366167e3c7ca5745ff4f14fb1
|
7
|
+
data.tar.gz: d12f8eec8217bb29f52d0af5d23daa787e23c2741146beb003adf9332ca2c39cfb5c2e1b35bb023266d6237394e31b65099a8200666b184695decdc5b5b82a0b
|
data/lib/ooxml_excel/sheet.rb
CHANGED
@@ -19,7 +19,7 @@ module OOXML
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def data_validation(cell_ref)
|
22
|
-
data_validations.find { |data_validation| data_validation.
|
22
|
+
data_validations.find { |data_validation| data_validation.in_sqref_range?(cell_ref)}
|
23
23
|
end
|
24
24
|
|
25
25
|
def column(id)
|
@@ -260,21 +260,12 @@ module OOXML
|
|
260
260
|
class DataValidation
|
261
261
|
attr_accessor :allow_blank, :prompt, :type, :sqref, :formula
|
262
262
|
|
263
|
-
def
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
splitted_by_space_sqref.map do |sqref|
|
270
|
-
split_sqref(sqref)
|
271
|
-
end
|
272
|
-
else
|
273
|
-
# "BH5:BH271"
|
274
|
-
split_sqref(splitted_by_space_sqref)
|
275
|
-
end
|
276
|
-
end.flatten.uniq
|
277
|
-
end
|
263
|
+
def in_sqref_range?(cell_id)
|
264
|
+
return if cell_id.blank?
|
265
|
+
cell_letter = cell_id.gsub(/[\d]/, '')
|
266
|
+
index = cell_id.gsub(/[^\d]/, '').to_i
|
267
|
+
range = sqref_range.find { |cell_letter_range, row_range| cell_letter_range.include?(cell_letter)}
|
268
|
+
range.last.include?(index) if range.present?
|
278
269
|
end
|
279
270
|
|
280
271
|
def self.load_from_node(data_validation_node)
|
@@ -296,20 +287,34 @@ module OOXML
|
|
296
287
|
attrs.each { |property, value| send("#{property}=", value)}
|
297
288
|
end
|
298
289
|
|
299
|
-
def
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
290
|
+
def sqref_range
|
291
|
+
@sqref_range ||= begin
|
292
|
+
# "BH5:BH271 BI5:BI271"
|
293
|
+
if !sqref.include?(':')
|
294
|
+
cell_letter = sqref.gsub(/[\d]/, '')
|
295
|
+
index = sqref.gsub(/[^\d]/, '').to_i
|
296
|
+
{ cell_letter => (index..index)}
|
297
|
+
else
|
298
|
+
sqref.split( ' ').map do |splitted_by_space_sqref|
|
299
|
+
# ["BH5:BH271, "BI5:BI271"]
|
300
|
+
if splitted_by_space_sqref.is_a?(Array)
|
301
|
+
splitted_by_space_sqref.map do |sqref|
|
302
|
+
build_range(splitted_by_space_sqref)
|
303
|
+
end
|
304
|
+
else
|
305
|
+
# "BH5:BH271"
|
306
|
+
build_range(splitted_by_space_sqref)
|
307
|
+
end
|
308
|
+
end.to_h
|
309
|
+
end
|
311
310
|
end
|
312
311
|
end
|
312
|
+
|
313
|
+
def build_range(sqref)
|
314
|
+
start_letter, end_letter = sqref.gsub(/[\d]/, '').split(':')
|
315
|
+
start_index, end_index = sqref.gsub(/[^\d:]/, '').split(':').map(&:to_i)
|
316
|
+
[(start_letter..end_letter),(start_index..end_index)]
|
317
|
+
end
|
313
318
|
end
|
314
319
|
end
|
315
320
|
end
|
data/lib/ooxml_excel/styles.rb
CHANGED
@@ -119,7 +119,7 @@ module OOXML
|
|
119
119
|
class Excel
|
120
120
|
class Styles
|
121
121
|
class Fill
|
122
|
-
attr_accessor :pattern_type, :fg_color, :fg_color_theme, :fg_color_tint, :bg_color_index, :bg_color
|
122
|
+
attr_accessor :pattern_type, :fg_color, :fg_color_theme, :fg_color_tint, :bg_color_index, :bg_color, :fg_color_index
|
123
123
|
|
124
124
|
def initialize(**attrs)
|
125
125
|
attrs.each { |property, value| send("#{property}=", value)}
|
@@ -131,12 +131,15 @@ module OOXML
|
|
131
131
|
if pattern_type == "solid"
|
132
132
|
fg_color = pattern_fill.at('fgColor')
|
133
133
|
bg_color = pattern_fill.at('bgColor')
|
134
|
+
fg_color_index = fg_color.class == Nokogiri::XML::Element ? fg_color.attributes["indexed"].try(:value) : nil
|
135
|
+
|
134
136
|
self.new(pattern_type: pattern_type,
|
135
137
|
fg_color: (fg_color.present?) ? fg_color.attributes["rgb"].try(:value) : nil,
|
136
138
|
fg_color_theme: (fg_color.present?) ? fg_color.attributes["theme"].try(:value) : nil,
|
137
139
|
fg_color_tint: (fg_color.present?) ? fg_color.attributes["tint"].try(:value) : nil,
|
138
140
|
bg_color: (bg_color.present?) ? bg_color.attributes["rgb"].try(:value) : nil,
|
139
|
-
bg_color_index: (bg_color.present?) ? bg_color.attributes["index"].try(:value) : nil
|
141
|
+
bg_color_index: (bg_color.present?) ? bg_color.attributes["index"].try(:value) : nil,
|
142
|
+
fg_color_index: fg_color_index)
|
140
143
|
else
|
141
144
|
self.new(pattern_type: pattern_type)
|
142
145
|
end
|
data/lib/ooxml_excel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooxml_excel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mones
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.4
|
147
|
+
rubygems_version: 2.6.4
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: OOXML Excel - Parse Excel Spreadsheets (xlsx, xlsm).
|