ooxl 0.0.1.4.8.4 → 0.0.1.4.9
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/ooxl/ooxl.rb +1 -1
- data/lib/ooxl/version.rb +1 -1
- data/lib/ooxl/xl_objects/cell.rb +8 -0
- data/lib/ooxl/xl_objects/row.rb +18 -3
- data/lib/ooxl/xl_objects/sheet.rb +11 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48275946ae01a29a5f56c0c1bc561e66650977bb
|
4
|
+
data.tar.gz: 6d2a8a0cbbb736813eef27b018195b851098afad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4682b4a534e2334eaf1bd697e05c3adcc521fed4866219269a919bb501dace8621915ab904474a5ab6134457f6271565f6a48edf7e373cc540ef99d435e31b
|
7
|
+
data.tar.gz: 64131b1a33db9784767a7f9721dbf97ffa5b44b55fff7ab612191c090480d52fdd3337e051bb89151ca889d11d151a2d0711952371b3edb843d265a9ac4a5ac1
|
data/lib/ooxl/ooxl.rb
CHANGED
@@ -76,7 +76,7 @@ class OOXL
|
|
76
76
|
case entry.name
|
77
77
|
when /xl\/worksheets\/sheet(\d+)?\.xml/
|
78
78
|
sheet_id = entry.name.scan(/xl\/worksheets\/sheet(\d+)?\.xml/).flatten.first
|
79
|
-
@sheets[sheet_id] = OOXL::Sheet.new(entry.get_input_stream.read, shared_strings)
|
79
|
+
@sheets[sheet_id] = OOXL::Sheet.new(entry.get_input_stream.read, shared_strings, @options)
|
80
80
|
when /xl\/styles\.xml/
|
81
81
|
@styles = OOXL::Styles.load_from_stream(entry.get_input_stream.read)
|
82
82
|
when /xl\/comments(\d+)?\.xml/
|
data/lib/ooxl/version.rb
CHANGED
data/lib/ooxl/xl_objects/cell.rb
CHANGED
@@ -25,6 +25,14 @@ class OOXL
|
|
25
25
|
attrs.each { |property, value| send("#{property}=", value)}
|
26
26
|
end
|
27
27
|
|
28
|
+
def column
|
29
|
+
@column ||= id.gsub(/\d+/, '')
|
30
|
+
end
|
31
|
+
|
32
|
+
def row
|
33
|
+
@row ||= id.gsub(/[^\d+]/, '')
|
34
|
+
end
|
35
|
+
|
28
36
|
def next_id(offset: 1, location: "bottom")
|
29
37
|
_, column_letter, column_index = id.partition(/[A-Z]+/)
|
30
38
|
|
data/lib/ooxl/xl_objects/row.rb
CHANGED
@@ -4,7 +4,8 @@ class OOXL
|
|
4
4
|
attr_accessor :id, :spans, :cells
|
5
5
|
|
6
6
|
def initialize(**attrs)
|
7
|
-
attrs.each { |property, value| send("#{property}=", value)}
|
7
|
+
attrs.each { |property, value| property == :options ? instance_variable_set("@#{property}", value) : send("#{property}=", value)}
|
8
|
+
@options ||= {}
|
8
9
|
end
|
9
10
|
|
10
11
|
def [](id)
|
@@ -16,6 +17,19 @@ class OOXL
|
|
16
17
|
(cell.present?) ? cell : BlankCell.new(id)
|
17
18
|
end
|
18
19
|
|
20
|
+
def cells
|
21
|
+
if @options[:padded_cells]
|
22
|
+
unless @cells.blank?
|
23
|
+
'A'.upto(@cells.last.column).map do |column_letter|
|
24
|
+
cell = @cells.find { |cell| cell.column == column_letter}
|
25
|
+
(cell.blank?) ? BlankCell.new("#{column_letter}#{id}") : cell
|
26
|
+
end
|
27
|
+
end
|
28
|
+
else
|
29
|
+
@cells
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
19
33
|
def cell(cell_id)
|
20
34
|
cell_final_id = cell_id[/[A-Z]{1,}\d+/] ? cell_id : "#{cell_id}#{id}"
|
21
35
|
cells.find { |cell| cell.id == cell_final_id}
|
@@ -25,10 +39,11 @@ class OOXL
|
|
25
39
|
cells.each { |cell| yield cell }
|
26
40
|
end
|
27
41
|
|
28
|
-
def self.load_from_node(row_node, shared_strings, styles)
|
42
|
+
def self.load_from_node(row_node, shared_strings, styles, options)
|
29
43
|
new(id: row_node.attributes["r"].try(:value),
|
30
44
|
spans: row_node.attributes["spans"].try(:value),
|
31
|
-
cells: row_node.xpath('c').map { |cell_node| OOXL::Cell.load_from_node(cell_node, shared_strings, styles)
|
45
|
+
cells: row_node.xpath('c').map { |cell_node| OOXL::Cell.load_from_node(cell_node, shared_strings, styles)},
|
46
|
+
options: options )
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
@@ -6,13 +6,14 @@ class OOXL
|
|
6
6
|
attr_reader :columns, :data_validations, :shared_strings
|
7
7
|
attr_accessor :comments, :styles, :defined_names, :name
|
8
8
|
|
9
|
-
def initialize(xml, shared_strings)
|
9
|
+
def initialize(xml, shared_strings, options={})
|
10
10
|
@xml = Nokogiri.XML(xml).remove_namespaces!
|
11
11
|
@shared_strings = shared_strings
|
12
12
|
@comments = {}
|
13
13
|
@defined_names = {}
|
14
14
|
@styles = []
|
15
15
|
@loaded_cache = {}
|
16
|
+
@options = options
|
16
17
|
end
|
17
18
|
|
18
19
|
def code_name
|
@@ -80,7 +81,7 @@ class OOXL
|
|
80
81
|
def rows
|
81
82
|
@rows ||= begin
|
82
83
|
all_rows = @xml.xpath('//sheetData/row').map do |row_node|
|
83
|
-
row = Row.load_from_node(row_node, @shared_strings, styles)
|
84
|
+
row = Row.load_from_node(row_node, @shared_strings, @styles, @options)
|
84
85
|
yield row if block_given?
|
85
86
|
row
|
86
87
|
end
|
@@ -90,7 +91,14 @@ class OOXL
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def each
|
93
|
-
|
94
|
+
if @options[:padded_rows]
|
95
|
+
(1.upto(rows.size)).each do |row_index|
|
96
|
+
row = row(row_index)
|
97
|
+
yield (row.blank?) ? Row.new(id: "#{row_index}", cells: []) : row
|
98
|
+
end
|
99
|
+
else
|
100
|
+
rows { |row| yield row }
|
101
|
+
end
|
94
102
|
end
|
95
103
|
|
96
104
|
def font(cell_reference)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooxl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.4.
|
4
|
+
version: 0.0.1.4.9
|
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-10-
|
11
|
+
date: 2016-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|