to_xls-rails 1.1.2 → 1.2.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4e3872cd4da07e76c95e6f9619262db4a388719e
4
+ data.tar.gz: 3f58f79a31b88b2eac730f9bb7f8ec76aa401925
5
+ SHA512:
6
+ metadata.gz: a7b9f585130e7838272d8ec883278f395ddb6ed29278c6adb8b4045c481a8434ddd3c18bfb4a1601c7e12762161f3fa27ebcd64149a3e6b65dcb02dd46b2a744
7
+ data.tar.gz: 8f34f161c72dc3cfd31238b9ba1be419cf544b73335120690770039f9f4a1af644cd135d47770909988f7633a882aaa354118c5e6221e2df1bc675b9a2230ee0
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in refinerycms-multisite.gemspec
4
4
  gemspec
5
5
 
6
- gem 'spreadsheet', '~> 0.6.5'
6
+ gem 'spreadsheet', '>= 0.8.5'
@@ -3,10 +3,38 @@
3
3
  This simple plugin gives you the ability to call to_xls to a collection of activerecords for Rails.
4
4
 
5
5
 
6
- == Install
7
- gem install spreadsheet
6
+ In your Gemfile:
7
+
8
+ gem 'to_xls-rails'# Last officially released gem
9
+ # gem "to_xls-rails", :git => "git://github.com/liangwenke/to_xls-rails.git" # Track git repo
10
+
11
+ or, to install as a gem:
12
+
8
13
  gem install to_xls-rails
9
14
 
15
+ or, to install as a plugin:
16
+
17
+ rails plugin install git://github.com/liangwenke/to_xls-rails.git
18
+
19
+ In your controller:
20
+
21
+ def index
22
+ @posts = Post.all
23
+
24
+ respond_to do |format|
25
+ format.html
26
+ format.xls { send_data(@posts.to_xls) }
27
+ # format.xls {
28
+ # filename = "Posts-#{Time.now.strftime("%Y%m%d%H%M%S")}.xls"
29
+ # send_data(@posts.to_xls, :type => "text/xls; charset=utf-8; header=present", :filename => filename)
30
+ # }
31
+ end
32
+ end
33
+
34
+ In your view:
35
+
36
+ <%= link_to 'Excel Download', posts_path(:format => :xls %>
37
+
10
38
 
11
39
  == Usage
12
40
 
@@ -32,6 +60,9 @@ This simple plugin gives you the ability to call to_xls to a collection of activ
32
60
  # Translation of a column-value
33
61
  @posts.to_xls{|column, value, row_index| column==:salutation ? t(value) + " at #{row_index}" : value}
34
62
 
63
+ # Added width options
64
+ @posts.to_xls(:column_width => [17,15,15,40,25,37])
65
+
35
66
 
36
67
  == Example
37
68
 
@@ -42,7 +73,7 @@ This simple plugin gives you the ability to call to_xls to a collection of activ
42
73
  respond_to do |format|
43
74
  format.xls { send_data(@posts.to_xls) }
44
75
  # format.xls {
45
- # filename = "posts-#{Time.now.strftime("%Y%m%d%H%M%S")}.xls"
76
+ # filename = "posts-#{Time.now.strftime("%Y%m%d%H%M%S")}.xls"
46
77
  # send_data(@posts.to_xls, :type => "application/excel; charset=utf-8; header=present", :filename => filename)
47
78
  # }
48
79
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.2.3
@@ -10,6 +10,9 @@ class Array
10
10
  options.reverse_merge!(:header => true)
11
11
 
12
12
  xls_report = StringIO.new
13
+
14
+ Spreadsheet.client_encoding = options[:client_encoding] || "UTF-8"
15
+
13
16
  book = Spreadsheet::Workbook.new
14
17
  sheet = book.create_worksheet
15
18
 
@@ -35,6 +38,10 @@ class Array
35
38
  sheet_index += 1
36
39
  end
37
40
 
41
+ if options[:column_width]
42
+ options[:column_width].each_index {|index| sheet.column(index).width = options[:column_width][index]}
43
+ end
44
+
38
45
  self.each_with_index do |obj, index|
39
46
  if block
40
47
  sheet.row(sheet_index).replace(columns.map { |column| block.call(column, obj.send(column), index) })
@@ -10,11 +10,11 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/liangwenke/to_xls-rails"
11
11
  s.summary = "Export Rails ActiveRecord data to excel file"
12
12
  s.description = "This simple plugin gives you the ability to call to_xls to a collection of activerecords for Rails."
13
-
13
+
14
14
  s.files = Dir["{lib,test}/**/*", "[a-zA-Z]*", "init.rb"] - ["Gemfile.lock"]
15
15
  s.require_path = "lib"
16
-
17
- s.add_dependency('spreadsheet', '~> 0.6.5')
16
+
17
+ s.add_dependency('spreadsheet', '>= 0.8.5')
18
18
 
19
19
  s.platform = Gem::Platform::RUBY
20
20
  s.required_rubygems_version = ">= 1.3.4"
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_xls-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
5
- prerelease:
4
+ version: 1.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mike Liang
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-01-14 00:00:00.000000000 Z
11
+ date: 2013-05-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: spreadsheet
16
- requirement: &70151257218860 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 0.6.5
19
+ version: 0.8.5
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70151257218860
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.5
25
27
  description: This simple plugin gives you the ability to call to_xls to a collection
26
28
  of activerecords for Rails.
27
29
  email: liangwenke.com@gmail.com
@@ -30,7 +32,6 @@ extensions: []
30
32
  extra_rdoc_files: []
31
33
  files:
32
34
  - lib/to_xls-rails.rb
33
- - CHANGELOG
34
35
  - Gemfile
35
36
  - init.rb
36
37
  - MIT-LICENSE
@@ -40,26 +41,25 @@ files:
40
41
  - VERSION
41
42
  homepage: http://github.com/liangwenke/to_xls-rails
42
43
  licenses: []
44
+ metadata: {}
43
45
  post_install_message:
44
46
  rdoc_options: []
45
47
  require_paths:
46
48
  - lib
47
49
  required_ruby_version: !ruby/object:Gem::Requirement
48
- none: false
49
50
  requirements:
50
- - - ! '>='
51
+ - - '>='
51
52
  - !ruby/object:Gem::Version
52
53
  version: '0'
53
54
  required_rubygems_version: !ruby/object:Gem::Requirement
54
- none: false
55
55
  requirements:
56
- - - ! '>='
56
+ - - '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: 1.3.4
59
59
  requirements: []
60
60
  rubyforge_project:
61
- rubygems_version: 1.8.12
61
+ rubygems_version: 2.0.0
62
62
  signing_key:
63
- specification_version: 3
63
+ specification_version: 4
64
64
  summary: Export Rails ActiveRecord data to excel file
65
65
  test_files: []
data/CHANGELOG DELETED
@@ -1,21 +0,0 @@
1
- 0.1.0
2
- First commit
3
-
4
- 0.1.1
5
- Added gem dependency on gemspec file
6
-
7
- 0.1.2
8
- Update README.rdoc
9
-
10
- 1.0.0
11
- Fixed typo
12
-
13
- 1.1.0
14
- Translation of a column-value
15
- Added options :header
16
-
17
- 1.1.1
18
- Added options :header_columns
19
-
20
- 1.1.2
21
- Added prepend option. Prepend some data above header and access current array element index in &block