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.
@@ -118,11 +118,11 @@ module RubyExcel
118
118
  #
119
119
 
120
120
  def to_excel( invisible = false )
121
- self.sheets.count == self.sheets.map(&:name).uniq.length or fail NoMethodError, 'Duplicate sheet name'
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
- self.each do |s|
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
@@ -147,6 +147,7 @@ module RubyExcel
147
147
  return to_enum( :map_without_headers! ) unless block_given?
148
148
  each_address( false ) { |addr| data[addr] = ( yield data[addr] ) }
149
149
  end
150
+ alias map_wh! map_without_headers!
150
151
 
151
152
  #
152
153
  # Read a value by address
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.6
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-14 00:00:00.000000000 Z
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.