rubyexcel 0.1.6 → 0.1.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.
- data/lib/rubyexcel/excel_tools.rb +17 -2
- data/lib/rubyexcel/section.rb +1 -0
- data/lib/rubyexcel.rb +8 -4
- metadata +2 -2
|
@@ -118,11 +118,11 @@ module RubyExcel
|
|
|
118
118
|
#
|
|
119
119
|
|
|
120
120
|
def to_excel( invisible = false )
|
|
121
|
-
self.sheets.count ==
|
|
121
|
+
self.sheets.count == sheets.map(&:name).uniq.length or fail NoMethodError, 'Duplicate sheet name'
|
|
122
122
|
wb = get_workbook( nil, true )
|
|
123
123
|
wb.parent.displayAlerts = false
|
|
124
124
|
first_time = true
|
|
125
|
-
|
|
125
|
+
each do |s|
|
|
126
126
|
sht = ( first_time ? wb.sheets(1) : wb.sheets.add( { 'after' => wb.sheets( wb.sheets.count ) } ) ); first_time = false
|
|
127
127
|
sht.name = s.name
|
|
128
128
|
make_sheet_pretty( dump_to_sheet( s.to_a, sht ) )
|
|
@@ -132,6 +132,21 @@ module RubyExcel
|
|
|
132
132
|
wb
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
+
# {Workbook#to_safe_format!}
|
|
136
|
+
|
|
137
|
+
def to_safe_format
|
|
138
|
+
dup.to_safe_format!
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
#
|
|
142
|
+
# Standardise the data for safe export to Excel.
|
|
143
|
+
# Set each cell contents to a string and remove leading equals signs.
|
|
144
|
+
#
|
|
145
|
+
|
|
146
|
+
def to_safe_format!
|
|
147
|
+
sheets { |s| s.rows { |r| r.map! { |v| v.to_s.sub( /^=/,"'=" ) } } }; self
|
|
148
|
+
end
|
|
149
|
+
|
|
135
150
|
end # Workbook
|
|
136
151
|
|
|
137
152
|
end # RubyExcel
|
data/lib/rubyexcel/section.rb
CHANGED
data/lib/rubyexcel.rb
CHANGED
|
@@ -3,13 +3,17 @@ require 'cgi'
|
|
|
3
3
|
|
|
4
4
|
#
|
|
5
5
|
# Ruby's standard Regexp class.
|
|
6
|
-
# Regexp#to_proc is a bit of "syntactic sugar" which allows shorthand Regexp blocks
|
|
7
|
-
#
|
|
8
|
-
# @example
|
|
9
|
-
# sheet.filter!( 'Part', &/Type[13]/ )
|
|
10
6
|
#
|
|
11
7
|
|
|
12
8
|
class Regexp
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# A bit of "syntactic sugar" which allows shorthand Regexp blocks
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# sheet.filter!( 'Part', &/Type[13]/ )
|
|
15
|
+
#
|
|
16
|
+
|
|
13
17
|
def to_proc
|
|
14
18
|
proc { |s| self =~ s.to_s }
|
|
15
19
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubyexcel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-05-
|
|
12
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: A tabular data structure in Ruby, with header-based helper methods and
|
|
15
15
|
some of Excel's API style. Designed for Windows + Excel.
|