rubyexcel 0.3.6 → 0.3.7
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/README.md +1 -0
- data/lib/rubyexcel.rb +7 -2
- data/lib/rubyexcel/excel_tools.rb +2 -7
- data/lib/rubyexcel/sheet.rb +24 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75b8ea393ff09d58583bf303db48f20701f1497a
|
4
|
+
data.tar.gz: 4ff035e0b2044679f01e555954e584654b3d199c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5f31688394d7a8ea42142736bb2768019c5850af22da19ca4b1e1bd7e327f74e7a94a8fb9dc3cc6b9be8540eb86ebc36328a294fc9b28ef9b65e5a545c1ae40
|
7
|
+
data.tar.gz: 3eb3b05e1913bc75ef784b46f61100358528119e50511dc20f5b62375ead84106839ab05761920813419615fae6186f5d77cbfb4fe561d490dc24e917bbd402b
|
data/README.md
CHANGED
@@ -235,6 +235,7 @@ wb.delete( 1 )
|
|
235
235
|
wb.delete( 'Sheet1' )
|
236
236
|
wb.delete( sheet1 )
|
237
237
|
wb.delete( /sheet1/i )
|
238
|
+
wb.delete { |sht| sht.name == 'Sheet1' }
|
238
239
|
|
239
240
|
#Import a WIN32OLE Workbook or Sheet, either by passing the Object or a Filename
|
240
241
|
#Parameters: WIN32OLE Object or Filename, SheetName or nil for all Sheets, true to keep Excel Formulas or omit to import Values.
|
data/lib/rubyexcel.rb
CHANGED
@@ -112,11 +112,16 @@ module RubyExcel
|
|
112
112
|
#
|
113
113
|
# Removes Sheet(s) from the Workbook
|
114
114
|
#
|
115
|
-
# @param [Fixnum, String, Regexp, RubyExcel::Sheet] ref the reference or object to remove
|
115
|
+
# @param [Fixnum, String, Regexp, RubyExcel::Sheet, NilClass] ref the reference or object to remove, or nil if passing a block
|
116
|
+
# @yield [RubyExcel::Sheet] yields each sheet, if there is no argument and a block is given
|
116
117
|
#
|
117
118
|
|
118
|
-
def delete( ref )
|
119
|
+
def delete( ref=nil, &block )
|
120
|
+
|
121
|
+
fail ArgumentError, 'Requires either an argument OR a block' if ref && block_given?
|
122
|
+
|
119
123
|
case ref
|
124
|
+
when nil ; @sheets.reject! { |sht| yield sht }
|
120
125
|
when Fixnum ; @sheets.delete_at( ref - 1 )
|
121
126
|
when String ; @sheets.reject! { |s| s.name == ref }
|
122
127
|
when Regexp ; @sheets.reject! { |s| s.name =~ ref }
|
@@ -247,13 +247,8 @@ module RubyExcel
|
|
247
247
|
#
|
248
248
|
|
249
249
|
def to_safe_format!
|
250
|
-
sheets
|
251
|
-
|
252
|
-
v[0] == '=' ? v.sub( /\A=/,"'=" ) : v
|
253
|
-
else
|
254
|
-
v.to_s
|
255
|
-
end
|
256
|
-
} } }; self
|
250
|
+
sheets &:to_safe_format!
|
251
|
+
self
|
257
252
|
end
|
258
253
|
|
259
254
|
end # Workbook
|
data/lib/rubyexcel/sheet.rb
CHANGED
@@ -542,6 +542,9 @@ module RubyExcel
|
|
542
542
|
sort_method = lambda { |array| idx_array.map { |idx| array[idx] } }
|
543
543
|
data.sort_by!( &sort_method )
|
544
544
|
self
|
545
|
+
rescue ArgumentError => err
|
546
|
+
raise( NoMethodError, 'Item not comparable in "' + headers.flatten.map(&:to_s).join(', ') + '"' ) if err.message == 'comparison of Array with Array failed'
|
547
|
+
raise err
|
545
548
|
end
|
546
549
|
|
547
550
|
#
|
@@ -638,6 +641,27 @@ module RubyExcel
|
|
638
641
|
data.map { |ar| ar.map { |v| v.to_s.gsub(/\t|\n|\r/,' ') }.join "\t" }.join( $/ )
|
639
642
|
end
|
640
643
|
|
644
|
+
# {Sheet#to_safe_format!}
|
645
|
+
|
646
|
+
def to_safe_format
|
647
|
+
dup.to_safe_format!
|
648
|
+
end
|
649
|
+
|
650
|
+
#
|
651
|
+
# Standardise the data for safe export to Excel.
|
652
|
+
# Set each cell contents to a string and remove leading equals signs.
|
653
|
+
#
|
654
|
+
|
655
|
+
def to_safe_format!
|
656
|
+
rows { |r| r.map! { |v|
|
657
|
+
if v.is_a?( String )
|
658
|
+
v[0] == '=' ? v.sub( /\A=/,"'=" ) : v
|
659
|
+
else
|
660
|
+
v.to_s
|
661
|
+
end
|
662
|
+
} }; self
|
663
|
+
end
|
664
|
+
|
641
665
|
#
|
642
666
|
# the Sheet as a TSV String
|
643
667
|
#
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyexcel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Pearson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A tabular data structure in Ruby, with header-based helper methods for
|
14
|
-
analysis and editing, and some of Excel's API style. Can output as 2D Array, HTML
|
15
|
-
CSV, TSV, or an Excel WIN32OLE Object
|
14
|
+
analysis and editing, and some of Excel's API style. Can output as 2D Array, HTML
|
15
|
+
Table, CSV, TSV, or an Excel WIN32OLE Object
|
16
16
|
email: VirtuosoJoel@gmail.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|