rubyexcel 0.2.7 → 0.2.8
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 +10 -1
- data/lib/rubyexcel/data.rb +5 -3
- data/lib/rubyexcel/excel_tools.rb +1 -1
- data/lib/rubyexcel/section.rb +1 -1
- data/lib/rubyexcel/sheet.rb +18 -1
- data/lib/rubyexcel.rb +1 -0
- 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: 05baad4d95550fd8ad617defee125d098768f039
|
4
|
+
data.tar.gz: 38bde97de67d3a586ef3b7eab6d00be2e0e98651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66b83ff4c9629ffe1a07ea06b7baac4e432a550ee46d15ab3fa884fadf5d713025cbcef52b1a298548793d5a658b7498e8553aece4e6a12fdfe49cd51c06cf36
|
7
|
+
data.tar.gz: 5c40988dfe369886aebf048a1e2bf97ce807f97094e76c8dafcafcfd4ddb69075b6028ec33bd168fd898b5a22c20dac5b563a1517ee27f84a404e3f0dd4491e3
|
data/README.md
CHANGED
@@ -193,6 +193,15 @@ wb.sheets( 'Type3' ).to_excel
|
|
193
193
|
#If you feel the need to delete everything between a set of rows:
|
194
194
|
s.rows(2, 4).reverse_each &:delete
|
195
195
|
|
196
|
+
#Gather text files containing string versions of RubyExcel::Sheet into a Workbook
|
197
|
+
wb = RubyExcel::Workbook.new
|
198
|
+
Dir.glob( '*.txt' ) do |f|
|
199
|
+
data = File.read(f).split($/).map { |r| r.split("\t") }
|
200
|
+
s = wb.add( f.chomp('.txt') )
|
201
|
+
s.load data
|
202
|
+
end
|
203
|
+
|
204
|
+
|
196
205
|
```
|
197
206
|
|
198
207
|
Workbook
|
@@ -719,4 +728,4 @@ Todo List
|
|
719
728
|
|
720
729
|
Copyright (c) 2013, Joel Pearson and Contributors. All Rights Reserved.
|
721
730
|
|
722
|
-
This project is licenced under the [MIT License](LICENSE.md).
|
731
|
+
This project is licenced under the [MIT License](https://github.com/VirtuosoJoel/RubyExcel/blob/master/LICENSE.md).
|
data/lib/rubyexcel/data.rb
CHANGED
@@ -254,8 +254,8 @@ require_relative 'address.rb'
|
|
254
254
|
headers = headers.flatten
|
255
255
|
hrow = sheet.header_rows - 1
|
256
256
|
ensure_shape
|
257
|
-
@data = @data.transpose.select{ |col| headers.include?(
|
258
|
-
@data = @data.sort_by{ |col| headers.index( col[hrow] ) ||
|
257
|
+
@data = @data.transpose.select{ |col| col[0..hrow].any?{ |val| headers.include?( val ) } }
|
258
|
+
@data = @data.sort_by{ |col| headers.index( col[0..hrow].select { |val| headers.include?( val ) }.first ) || headers.length }.transpose
|
259
259
|
calc_dimensions
|
260
260
|
end
|
261
261
|
|
@@ -419,7 +419,9 @@ require_relative 'address.rb'
|
|
419
419
|
private
|
420
420
|
|
421
421
|
def calc_dimensions
|
422
|
-
@rows
|
422
|
+
@rows = ( @data.length rescue 0 )
|
423
|
+
@cols = ( @data.max_by { |row| row.length }.length rescue 0 )
|
424
|
+
self
|
423
425
|
end
|
424
426
|
|
425
427
|
def ensure_shape
|
data/lib/rubyexcel/section.rb
CHANGED
data/lib/rubyexcel/sheet.rb
CHANGED
@@ -277,6 +277,7 @@ module RubyExcel
|
|
277
277
|
#
|
278
278
|
|
279
279
|
def filter!( header, &block )
|
280
|
+
return to_enum( :filter!, header ) unless block_given?
|
280
281
|
data.filter!( header, &block ); self
|
281
282
|
end
|
282
283
|
|
@@ -544,6 +545,14 @@ module RubyExcel
|
|
544
545
|
data.all
|
545
546
|
end
|
546
547
|
|
548
|
+
#
|
549
|
+
# The Sheet as a CSV String
|
550
|
+
#
|
551
|
+
|
552
|
+
def to_csv
|
553
|
+
CSV.generate { |csv| to_a.each { |r| csv << r } }
|
554
|
+
end
|
555
|
+
|
547
556
|
#
|
548
557
|
# The Sheet as a WIN32OLE Excel Workbook
|
549
558
|
# @note This requires Windows and MS Excel
|
@@ -562,13 +571,21 @@ module RubyExcel
|
|
562
571
|
end
|
563
572
|
|
564
573
|
#
|
565
|
-
# The Sheet as a Tab Seperated Value String
|
574
|
+
# The Sheet as a Tab Seperated Value String (Strips extra whitespace)
|
566
575
|
#
|
567
576
|
|
568
577
|
def to_s
|
569
578
|
data.map { |ar| ar.map { |v| v.to_s.gsub(/\t|\n|\r/,' ') }.join "\t" }.join( $/ )
|
570
579
|
end
|
571
580
|
|
581
|
+
#
|
582
|
+
# the Sheet as a TSV String
|
583
|
+
#
|
584
|
+
|
585
|
+
def to_tsv
|
586
|
+
CSV.generate( :col_sep => "\t" ) { |csv| to_a.each { |r| csv << r } }
|
587
|
+
end
|
588
|
+
|
572
589
|
#
|
573
590
|
# Remove any Rows with duplicate values within a Column
|
574
591
|
#
|
data/lib/rubyexcel.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyexcel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
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-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A tabular data structure in Ruby, with header-based helper methods for
|
14
14
|
analysis and editing, and some of Excel's API style. Can output as 2D Array, Excel,
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
50
|
rubyforge_project:
|
51
|
-
rubygems_version: 2.0.
|
51
|
+
rubygems_version: 2.0.4
|
52
52
|
signing_key:
|
53
53
|
specification_version: 4
|
54
54
|
summary: Spreadsheets in Ruby
|