oxcelix 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -1,2 +1,2 @@
1
- --protected
1
+ --protected
2
2
  --private
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.3.3
2
+ * Will not terminate it a directory called 'tmp' already exists in the current directory.
3
+ Thanks to bhavinkamani for pointing this out.
4
+ * Corrected type in xlsheet parser: empty cells near to non-empty ones will now be correctly handled
5
+
1
6
  0.3.2
2
7
  * The numeric method in numformats will now try to gsub the correct format value and not the format index.
3
8
  * Required rubyzip version number is now >=1.1.0. 0.9.9 which was apparently
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 gbiczo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 gbiczo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,70 +1,70 @@
1
- Oxcelix
2
- =======
3
- <a href="http://badge.fury.io/rb/oxcelix"><img src="https://badge.fury.io/rb/oxcelix@2x.png" alt="Gem Version" height="18"></a>
4
-
5
- Oxcelix - A fast and simple .xlsx file parser
6
-
7
- Description
8
- -----------
9
-
10
- Oxcelix is an xlsx (Excel 2007/2010) parser. The result of the parsing is a
11
- Workbook which is an array of Sheet objects, which in turn store the data in
12
- Matrix objects. Matrices consist of Cell objects to maintain comments and
13
- formatting/style data
14
-
15
- Oxcelix uses the great Ox gem (http://rubygems.org/gems/ox) for fast SAX-parsing.
16
-
17
- Synopsis
18
- --------
19
-
20
- To process an xlsx file:
21
-
22
- `require 'oxcelix'`
23
- `w = Oxcelix::Workbook.new('whatever.xlsx')`
24
-
25
- To omit certain sheets:
26
-
27
- `w = Oxcelix::Workbook.new('whatever.xlsx', :exclude => ['sheet1', 'sheet2'])`
28
-
29
- Include only some of the sheets:
30
-
31
- `w = Oxcelix::Workbook.new('whatever.xlsx', :include => ['sheet1', 'sheet2', 'sheet3'])`
32
-
33
- To have the values of the merged cells copied over the mergegroup:
34
-
35
- `w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)`
36
-
37
- Convert a Sheet object into a collection of ruby values or formatted ruby strings:
38
-
39
- `require 'oxcelix'`
40
- `w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)`
41
- `w.sheets[0].to_ru # returns a Matrix of DateTime, Integer, etc objects`
42
- `w.sheets[0].to_fmt # returns a Matrix of formatted Strings based on the above.`
43
-
44
- Installation
45
- ------------
46
-
47
- `gem install oxcelix`
48
-
49
-
50
- Advantages over other Excel parsers
51
- -----------------------------------
52
-
53
- Excel file processing involves XML document parsing. Usually, this is achieved by DOM-parsing the data with a suitable XML library.
54
-
55
- The main drawbacks of this approach are memory usage and speed. The resulting object tree will be roughly as big as the original file, and during the parsing, they will both be stored in the memory, which can cause quite some complications when processing huge files. Also, interpreting every bit of an excel spreadsheet will slow down unnecessarily the process, if we only need the data stored in that file.
56
-
57
- The solution for the memory-consumption problem is SAX stream parsing. This ensures that only the relevant XML elements get processed,
58
- without having to load the whole XML file in memory.
59
-
60
- Oxcelix uses the SAX parser offered by Peter Ohler's Ox gem. I found Ox SAX parser quite fast, so to further speed up the parsing.
61
-
62
- For a comparison of XML parsers, please consult the Ox homepage[http://www.ohler.com/dev/xml_with_ruby/xml_with_ruby.html].
63
-
64
- TODO
65
- ----
66
- * Implement RawWorkbook, ValueWorkbook, FormattedWorkbook
67
- * include/exclude mechanism should extend to cell areas inside Sheet objects
68
- * Possible speedups
69
- * Further improvement to the formatting algorithms. Theoretically, to_fmt should be able to
70
- split conditional-formatting strings and to display e.g. thousands separated number strings
1
+ Oxcelix
2
+ =======
3
+ <a href="http://badge.fury.io/rb/oxcelix"><img src="https://badge.fury.io/rb/oxcelix@2x.png" alt="Gem Version" height="18"></a>
4
+
5
+ Oxcelix - A fast and simple .xlsx file parser
6
+
7
+ Description
8
+ -----------
9
+
10
+ Oxcelix is an xlsx (Excel 2007/2010) parser. The result of the parsing is a
11
+ Workbook which is an array of Sheet objects, which in turn store the data in
12
+ Matrix objects. Matrices consist of Cell objects to maintain comments and
13
+ formatting/style data
14
+
15
+ Oxcelix uses the great Ox gem (http://rubygems.org/gems/ox) for fast SAX-parsing.
16
+
17
+ Synopsis
18
+ --------
19
+
20
+ To process an xlsx file:
21
+
22
+ `require 'oxcelix'`
23
+ `w = Oxcelix::Workbook.new('whatever.xlsx')`
24
+
25
+ To omit certain sheets:
26
+
27
+ `w = Oxcelix::Workbook.new('whatever.xlsx', :exclude => ['sheet1', 'sheet2'])`
28
+
29
+ Include only some of the sheets:
30
+
31
+ `w = Oxcelix::Workbook.new('whatever.xlsx', :include => ['sheet1', 'sheet2', 'sheet3'])`
32
+
33
+ To have the values of the merged cells copied over the mergegroup:
34
+
35
+ `w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)`
36
+
37
+ Convert a Sheet object into a collection of ruby values or formatted ruby strings:
38
+
39
+ `require 'oxcelix'`
40
+ `w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)`
41
+ `w.sheets[0].to_ru # returns a Matrix of DateTime, Integer, etc objects`
42
+ `w.sheets[0].to_fmt # returns a Matrix of formatted Strings based on the above.`
43
+
44
+ Installation
45
+ ------------
46
+
47
+ `gem install oxcelix`
48
+
49
+
50
+ Advantages over other Excel parsers
51
+ -----------------------------------
52
+
53
+ Excel file processing involves XML document parsing. Usually, this is achieved by DOM-parsing the data with a suitable XML library.
54
+
55
+ The main drawbacks of this approach are memory usage and speed. The resulting object tree will be roughly as big as the original file, and during the parsing, they will both be stored in the memory, which can cause quite some complications when processing huge files. Also, interpreting every bit of an excel spreadsheet will slow down unnecessarily the process, if we only need the data stored in that file.
56
+
57
+ The solution for the memory-consumption problem is SAX stream parsing. This ensures that only the relevant XML elements get processed,
58
+ without having to load the whole XML file in memory.
59
+
60
+ Oxcelix uses the SAX parser offered by Peter Ohler's Ox gem. I found Ox SAX parser quite fast, so to further speed up the parsing.
61
+
62
+ For a comparison of XML parsers, please consult the Ox homepage[http://www.ohler.com/dev/xml_with_ruby/xml_with_ruby.html].
63
+
64
+ TODO
65
+ ----
66
+ * Implement RawWorkbook, ValueWorkbook, FormattedWorkbook
67
+ * include/exclude mechanism should extend to cell areas inside Sheet objects
68
+ * Possible speedups
69
+ * Further improvement to the formatting algorithms. Theoretically, to_fmt should be able to
70
+ split conditional-formatting strings and to display e.g. thousands separated number strings
@@ -1,62 +1,62 @@
1
- = \Oxcelix - A fast .xlsx file parser
2
-
3
- {<img src="https://badge.fury.io/rb/oxcelix.png" alt="Gem Version" />}[http://badge.fury.io/rb/oxcelix]
4
-
5
- == Description
6
-
7
- Oxcelix is an xlsx (Excel 2007/2010) parser. The result of the parsing is a
8
- Workbook which is an array of Sheet objects, which in turn store the data in
9
- Matrix objects. Matrices consist of Cell objects to maintain comments and
10
- formatting/style data.
11
-
12
- Oxcelix uses the great Ox gem (http://rubygems.org/gems/ox) for fast SAX-parsing.
13
-
14
- == Synopsis
15
-
16
- To process an xlsx file:
17
-
18
- require 'oxcelix'
19
-
20
- w = Oxcelix::Workbook.new('whatever.xlsx')
21
-
22
- To omit certain sheets to be processed:
23
-
24
- w = Oxcelix::Workbook.new('whatever.xlsx', :exclude => ['sheet1', 'sheet2'])
25
-
26
- Include only some of the sheets:
27
-
28
- w = Oxcelix::Workbook.new('whatever.xlsx', :include => ['sheet1', 'sheet2', 'sheet3'])
29
-
30
- To have the values of the merged cells copied over the mergegroup:
31
-
32
- w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)
33
-
34
- Convert a Sheet object into a collection of ruby values or formatted ruby strings:
35
- require 'oxcelix'
36
- w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)
37
- w.sheets[0].to_ru # returns a Matrix of DateTime, Integer, etc objects
38
- w.sheets[0].to_fmt # returns a Matrix of formatted Strings based on the above.
39
-
40
- == Installation
41
-
42
- gem install oxcelix
43
-
44
- == Advantages over other Excel parsers
45
-
46
- Excel file processing involves XML document parsing. Usually, this is achieved by DOM-parsing the data with a suitable XML library.
47
-
48
- The main drawbacks of this approach are memory usage and speed. The resulting object tree will be roughly as big as the original file, and during the parsing, they will both be stored in the memory, which can cause quite some complications when processing huge files. Also, interpreting every bit of an excel spreadsheet will slow down unnecessarily the process, if we only need the data stored in that file.
49
-
50
- The solution for the memory-consumption problem is SAX stream parsing. This ensures that only the relevant XML elements get processed,
51
- without having to load the whole XML file in memory.
52
-
53
- Oxcelix uses the SAX parser offered by Peter Ohler's Ox gem. I found Ox SAX parser quite fast, so to further speed up the parsing.
54
-
55
- For a comparison of XML parsers, please consult the Ox homepage[http://www.ohler.com/dev/xml_with_ruby/xml_with_ruby.html].
56
-
57
- == TODO
58
- * Implement RawWorkbook, ValueWorkbook, FormattedWorkbook
59
- * include/exclude mechanism should extend to cell areas inside Sheet objects
60
- * Possible speedups
61
- * Further improvement to the formatting algorithms. Theoretically, to_fmt should be able to
1
+ = \Oxcelix - A fast .xlsx file parser
2
+
3
+ {<img src="https://badge.fury.io/rb/oxcelix.png" alt="Gem Version" />}[http://badge.fury.io/rb/oxcelix]
4
+
5
+ == Description
6
+
7
+ Oxcelix is an xlsx (Excel 2007/2010) parser. The result of the parsing is a
8
+ Workbook which is an array of Sheet objects, which in turn store the data in
9
+ Matrix objects. Matrices consist of Cell objects to maintain comments and
10
+ formatting/style data.
11
+
12
+ Oxcelix uses the great Ox gem (http://rubygems.org/gems/ox) for fast SAX-parsing.
13
+
14
+ == Synopsis
15
+
16
+ To process an xlsx file:
17
+
18
+ require 'oxcelix'
19
+
20
+ w = Oxcelix::Workbook.new('whatever.xlsx')
21
+
22
+ To omit certain sheets to be processed:
23
+
24
+ w = Oxcelix::Workbook.new('whatever.xlsx', :exclude => ['sheet1', 'sheet2'])
25
+
26
+ Include only some of the sheets:
27
+
28
+ w = Oxcelix::Workbook.new('whatever.xlsx', :include => ['sheet1', 'sheet2', 'sheet3'])
29
+
30
+ To have the values of the merged cells copied over the mergegroup:
31
+
32
+ w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)
33
+
34
+ Convert a Sheet object into a collection of ruby values or formatted ruby strings:
35
+ require 'oxcelix'
36
+ w = Oxcelix::Workbook.new('whatever.xlsx', :copymerge => true)
37
+ w.sheets[0].to_ru # returns a Matrix of DateTime, Integer, etc objects
38
+ w.sheets[0].to_fmt # returns a Matrix of formatted Strings based on the above.
39
+
40
+ == Installation
41
+
42
+ gem install oxcelix
43
+
44
+ == Advantages over other Excel parsers
45
+
46
+ Excel file processing involves XML document parsing. Usually, this is achieved by DOM-parsing the data with a suitable XML library.
47
+
48
+ The main drawbacks of this approach are memory usage and speed. The resulting object tree will be roughly as big as the original file, and during the parsing, they will both be stored in the memory, which can cause quite some complications when processing huge files. Also, interpreting every bit of an excel spreadsheet will slow down unnecessarily the process, if we only need the data stored in that file.
49
+
50
+ The solution for the memory-consumption problem is SAX stream parsing. This ensures that only the relevant XML elements get processed,
51
+ without having to load the whole XML file in memory.
52
+
53
+ Oxcelix uses the SAX parser offered by Peter Ohler's Ox gem. I found Ox SAX parser quite fast, so to further speed up the parsing.
54
+
55
+ For a comparison of XML parsers, please consult the Ox homepage[http://www.ohler.com/dev/xml_with_ruby/xml_with_ruby.html].
56
+
57
+ == TODO
58
+ * Implement RawWorkbook, ValueWorkbook, FormattedWorkbook
59
+ * include/exclude mechanism should extend to cell areas inside Sheet objects
60
+ * Possible speedups
61
+ * Further improvement to the formatting algorithms. Theoretically, to_fmt should be able to
62
62
  split conditional-formatting strings and to display e.g. thousands separated number strings
@@ -1,47 +1,47 @@
1
- require 'ox'
2
- require 'find'
3
- require 'matrix'
4
- require 'fileutils'
5
- require 'zip'
6
- require 'oxcelix/cellhelper'
7
- require 'oxcelix/numformats'
8
- require 'oxcelix/nf'
9
- require 'oxcelix/cell'
10
- require 'oxcelix/sheet'
11
- require 'oxcelix/workbook'
12
- require 'oxcelix/sax/sharedstrings'
13
- require 'oxcelix/sax/comments'
14
- require 'oxcelix/sax/xlsheet'
15
- require 'oxcelix/sax/styles'
16
-
17
- class String
18
- # Returns true if the given String represents a numeric value
19
- # @return [Bool] true if the string represents a numeric value, false if it doesn't.
20
- def numeric?
21
- Float(self) != nil rescue false
22
- end
23
- end
24
-
25
- class Matrix
26
- # Set the cell value i,j to x, where i=row, and j=column.
27
- # @param i [Integer] Row
28
- # @param j [Integer] Column
29
- # @param x [Object] New cell value
30
- def []=(i, j, x)
31
- @rows[i][j]=x
32
- end
33
- end
34
-
35
- class Fixnum
36
- # Returns the column name corresponding to the given number. e.g: 1.col_name => 'B'
37
- # @return [String]
38
- def col_name
39
- val=self/26
40
- (val > 0 ? (val - 1).col_name : "") + (self % 26 + 65).chr
41
- end
42
- end
43
-
44
- # The namespace for all classes and modules included in Oxcelix.
45
- module Oxcelix
46
-
47
- end
1
+ require 'ox'
2
+ require 'find'
3
+ require 'matrix'
4
+ require 'fileutils'
5
+ require 'zip'
6
+ require 'oxcelix/cellhelper'
7
+ require 'oxcelix/numformats'
8
+ require 'oxcelix/nf'
9
+ require 'oxcelix/cell'
10
+ require 'oxcelix/sheet'
11
+ require 'oxcelix/workbook'
12
+ require 'oxcelix/sax/sharedstrings'
13
+ require 'oxcelix/sax/comments'
14
+ require 'oxcelix/sax/xlsheet'
15
+ require 'oxcelix/sax/styles'
16
+
17
+ class String
18
+ # Returns true if the given String represents a numeric value
19
+ # @return [Bool] true if the string represents a numeric value, false if it doesn't.
20
+ def numeric?
21
+ Float(self) != nil rescue false
22
+ end
23
+ end
24
+
25
+ class Matrix
26
+ # Set the cell value i,j to x, where i=row, and j=column.
27
+ # @param i [Integer] Row
28
+ # @param j [Integer] Column
29
+ # @param x [Object] New cell value
30
+ def []=(i, j, x)
31
+ @rows[i][j]=x
32
+ end
33
+ end
34
+
35
+ class Fixnum
36
+ # Returns the column name corresponding to the given number. e.g: 1.col_name => 'B'
37
+ # @return [String]
38
+ def col_name
39
+ val=self/26
40
+ (val > 0 ? (val - 1).col_name : "") + (self % 26 + 65).chr
41
+ end
42
+ end
43
+
44
+ # The namespace for all classes and modules included in Oxcelix.
45
+ module Oxcelix
46
+
47
+ end
@@ -1,22 +1,22 @@
1
- module Oxcelix
2
- # Simple class representing an excel cell.
3
- # @!attribute [rw] xlcoords
4
- # @return [String] The Excel-style coordinates of the cell object
5
- # @!attribute [rw] type
6
- # @return [String] Cell content type
7
- # @!attribute [rw] value
8
- # @return [String] the type of the cell
9
- # @!attribute [rw] comment
10
- # @return [String] Comment text
11
- # @!attribute [rw] style
12
- # @return [String] Excel style attribute
13
- # @!attribute [rw] numformat
14
- # @return [String] Excel style number formatting
15
-
16
- class Cell
17
- attr_accessor :xlcoords, :type, :value, :comment, :style, :numformat
18
- include Cellhelper
19
- include Cellvalues
20
- include Numberhelper
21
- end
22
- end
1
+ module Oxcelix
2
+ # Simple class representing an excel cell.
3
+ # @!attribute [rw] xlcoords
4
+ # @return [String] The Excel-style coordinates of the cell object
5
+ # @!attribute [rw] type
6
+ # @return [String] Cell content type
7
+ # @!attribute [rw] value
8
+ # @return [String] the type of the cell
9
+ # @!attribute [rw] comment
10
+ # @return [String] Comment text
11
+ # @!attribute [rw] style
12
+ # @return [String] Excel style attribute
13
+ # @!attribute [rw] numformat
14
+ # @return [String] Excel style number formatting
15
+
16
+ class Cell
17
+ attr_accessor :xlcoords, :type, :value, :comment, :style, :numformat
18
+ include Cellhelper
19
+ include Cellvalues
20
+ include Numberhelper
21
+ end
22
+ end