spreadsheet_architect 1.4.8 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -2
- data/README.md +117 -98
- data/Rakefile +8 -1
- data/lib/generators/spreadsheet_architect/add_project_defaults_generator.rb +12 -3
- data/lib/spreadsheet_architect.rb +19 -330
- data/lib/spreadsheet_architect/action_controller_renderers.rb +9 -19
- data/lib/spreadsheet_architect/class_methods/csv.rb +22 -0
- data/lib/spreadsheet_architect/class_methods/ods.rb +61 -0
- data/lib/spreadsheet_architect/class_methods/xlsx.rb +162 -0
- data/lib/spreadsheet_architect/exceptions.rb +47 -0
- data/lib/spreadsheet_architect/{set_mime_types.rb → mime_types.rb} +0 -2
- data/lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb +23 -0
- data/lib/spreadsheet_architect/utils.rb +223 -0
- data/lib/spreadsheet_architect/utils/xlsx.rb +126 -0
- data/lib/spreadsheet_architect/version.rb +1 -1
- data/test/rails_app/Gemfile +17 -0
- data/test/rails_app/Gemfile.lock +176 -0
- data/test/rails_app/README.md +24 -0
- data/test/rails_app/Rakefile +6 -0
- data/test/rails_app/app/assets/config/manifest.js +3 -0
- data/test/rails_app/app/assets/javascripts/application.js +16 -0
- data/test/rails_app/app/assets/javascripts/cable.js +13 -0
- data/test/rails_app/app/assets/stylesheets/application.css +15 -0
- data/test/rails_app/app/channels/application_cable/channel.rb +4 -0
- data/test/rails_app/app/channels/application_cable/connection.rb +4 -0
- data/test/rails_app/app/controllers/application_controller.rb +3 -0
- data/test/rails_app/app/controllers/spreadsheets_controller.rb +74 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/jobs/application_job.rb +2 -0
- data/test/rails_app/app/mailers/application_mailer.rb +4 -0
- data/test/rails_app/app/models/active_model_object.rb +14 -0
- data/test/rails_app/app/models/application_record.rb +3 -0
- data/test/rails_app/app/models/bad_plain_ruby_object.rb +3 -0
- data/test/rails_app/app/models/custom_post.rb +15 -0
- data/test/rails_app/app/models/plain_ruby_object.rb +19 -0
- data/test/rails_app/app/models/post.rb +3 -0
- data/test/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app/app/views/layouts/mailer.html.erb +13 -0
- data/test/rails_app/app/views/layouts/mailer.text.erb +1 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +9 -0
- data/test/rails_app/bin/rake +9 -0
- data/test/rails_app/bin/setup +34 -0
- data/test/rails_app/bin/spring +16 -0
- data/test/rails_app/bin/update +29 -0
- data/test/rails_app/config.ru +5 -0
- data/test/rails_app/config/application.rb +15 -0
- data/test/rails_app/config/boot.rb +3 -0
- data/test/rails_app/config/cable.yml +9 -0
- data/test/rails_app/config/database.yml +16 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +54 -0
- data/test/rails_app/config/environments/production.rb +86 -0
- data/test/rails_app/config/environments/test.rb +42 -0
- data/test/rails_app/config/initializers/application_controller_renderer.rb +6 -0
- data/test/rails_app/config/initializers/assets.rb +11 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/cookies_serializer.rb +5 -0
- data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app/config/initializers/inflections.rb +16 -0
- data/test/rails_app/config/initializers/mime_types.rb +4 -0
- data/test/rails_app/config/initializers/new_framework_defaults.rb +24 -0
- data/test/rails_app/config/initializers/session_store.rb +3 -0
- data/test/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/test/rails_app/config/locales/en.yml +23 -0
- data/test/rails_app/config/routes.rb +7 -0
- data/test/rails_app/config/secrets.yml +22 -0
- data/test/{spreadsheet_architect.sqlite3.db → rails_app/db/development.sqlite3} +0 -0
- data/test/rails_app/db/migrate/20170103234524_add_posts.rb +10 -0
- data/test/rails_app/db/schema.rb +23 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/rails_app/db/test.sqlite3 +0 -0
- data/test/rails_app/log/development.log +1195 -0
- data/test/rails_app/log/test.log +52766 -0
- data/test/rails_app/public/404.html +67 -0
- data/test/rails_app/public/422.html +67 -0
- data/test/rails_app/public/500.html +66 -0
- data/test/rails_app/public/apple-touch-icon-precomposed.png +0 -0
- data/test/rails_app/public/apple-touch-icon.png +0 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/public/robots.txt +5 -0
- data/test/rails_app/test/controllers/spreadsheets_controller_test.rb +46 -0
- data/test/rails_app/test/models/active_model_object_test.rb +54 -0
- data/test/rails_app/test/models/bad_plain_ruby_object_test.rb +30 -0
- data/test/rails_app/test/models/csv_test.rb +60 -0
- data/test/rails_app/test/models/custom_post_test.rb +47 -0
- data/test/rails_app/test/models/ods_test.rb +68 -0
- data/test/rails_app/test/models/plain_ruby_object_test.rb +54 -0
- data/test/rails_app/test/models/post_test.rb +47 -0
- data/test/rails_app/test/models/spreadsheet_architect_utils_test.rb +68 -0
- data/test/rails_app/test/models/xlsx_test.rb +99 -0
- data/test/rails_app/test/test_helper.rb +21 -0
- data/test/rails_app/tmp/active_model_object/csv.csv +21 -0
- data/test/rails_app/tmp/active_model_object/ods.ods +0 -0
- data/test/rails_app/tmp/active_model_object/xlsx.xlsx +0 -0
- data/test/rails_app/tmp/controller_tests/alt_xlsx.xlsx +0 -0
- data/test/rails_app/tmp/controller_tests/csv.csv +1 -0
- data/test/rails_app/tmp/controller_tests/ods.ods +0 -0
- data/test/rails_app/tmp/controller_tests/xlsx.xlsx +0 -0
- data/test/rails_app/tmp/custom_posts/csv.csv +1 -0
- data/test/rails_app/tmp/custom_posts/empty.xlsx +0 -0
- data/test/rails_app/tmp/custom_posts/ods.ods +0 -0
- data/test/rails_app/tmp/custom_posts/xlsx.xlsx +0 -0
- data/test/rails_app/tmp/empty_model.csv +1 -0
- data/test/rails_app/tmp/empty_model.xlsx +0 -0
- data/test/rails_app/tmp/empty_sa.csv +0 -0
- data/test/rails_app/tmp/empty_sa.xlsx +0 -0
- data/test/rails_app/tmp/extreme.xlsx +0 -0
- data/test/rails_app/tmp/model.csv +1 -0
- data/test/rails_app/tmp/model.xlsx +0 -0
- data/test/rails_app/tmp/ods/empty_model.ods +0 -0
- data/test/rails_app/tmp/ods/empty_sa.ods +0 -0
- data/test/rails_app/tmp/ods/model.ods +0 -0
- data/test/rails_app/tmp/ods/model_options.ods +0 -0
- data/test/rails_app/tmp/ods/sa.ods +0 -0
- data/test/rails_app/tmp/options.csv +1 -0
- data/test/rails_app/tmp/plain_ruby_object/csv.csv +4 -0
- data/test/rails_app/tmp/plain_ruby_object/ods.ods +0 -0
- data/test/rails_app/tmp/plain_ruby_object/xlsx.xlsx +0 -0
- data/test/rails_app/tmp/posts/csv.csv +1 -0
- data/test/rails_app/tmp/posts/empty.xlsx +0 -0
- data/test/rails_app/tmp/posts/ods.ods +0 -0
- data/test/rails_app/tmp/posts/xlsx.xlsx +0 -0
- data/test/rails_app/tmp/sa.csv +4 -0
- data/test/rails_app/tmp/sa.xlsx +0 -0
- metadata +255 -21
- data/lib/spreadsheet_architect/axlsx_column_width_patch.rb +0 -13
- data/test/database.yml +0 -3
- data/test/helper.rb +0 -52
- data/test/tc_spreadsheet_architect.rb +0 -84
@@ -0,0 +1,126 @@
|
|
1
|
+
module SpreadsheetArchitect
|
2
|
+
module Utils
|
3
|
+
module XLSX
|
4
|
+
|
5
|
+
def self.get_type(value, type=nil)
|
6
|
+
return type unless (type.respond_to?(:empty?) ? type.empty? : type.nil?)
|
7
|
+
|
8
|
+
if value.is_a?(Numeric)
|
9
|
+
if value.is_a?(Float) || value.is_a?(BigDecimal)
|
10
|
+
type = :float
|
11
|
+
else
|
12
|
+
type = :integer
|
13
|
+
end
|
14
|
+
elsif value.respond_to?(:strftime)
|
15
|
+
if value.is_a?(DateTime) || value.is_a?(Time)
|
16
|
+
type = :time
|
17
|
+
else
|
18
|
+
type = :date
|
19
|
+
end
|
20
|
+
else
|
21
|
+
type = :string
|
22
|
+
end
|
23
|
+
|
24
|
+
return type
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.convert_styles_to_axlsx(styles={})
|
28
|
+
styles = {} unless styles.is_a?(Hash)
|
29
|
+
styles = self.symbolize_keys(styles)
|
30
|
+
|
31
|
+
if styles[:color].respond_to?(:sub) && !styles[:color].empty?
|
32
|
+
styles[:fg_color] = styles.delete(:color).sub('#','')
|
33
|
+
end
|
34
|
+
|
35
|
+
if styles[:background_color].respond_to?(:sub) && !styles[:background_color].empty?
|
36
|
+
styles[:bg_color] = styles.delete(:background_color).sub('#','')
|
37
|
+
end
|
38
|
+
|
39
|
+
if styles[:align]
|
40
|
+
if styles[:align].is_a?(Hash)
|
41
|
+
styles[:alignment] = {horizontal: styles[:align][:horizontal], vertical: styles[:align][:vertical]}
|
42
|
+
styles.delete(:align)
|
43
|
+
else
|
44
|
+
styles[:alignment] = {horizontal: styles.delete(:align)}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
styles[:b] = styles.delete(:bold) || styles[:b]
|
48
|
+
styles[:sz] = styles.delete(:font_size) || styles[:sz]
|
49
|
+
styles[:i] = styles.delete(:italic) || styles[:i]
|
50
|
+
styles[:u] = styles.delete(:underline) || styles[:u]
|
51
|
+
|
52
|
+
styles.delete_if{|k,v| v.nil?}
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.range_hash_to_str(hash, num_columns, num_rows, col_names=Array('A'..'ZZZ'))
|
56
|
+
case hash[:columns]
|
57
|
+
when Integer
|
58
|
+
start_col = end_col = col_names[hash[:columns]]
|
59
|
+
when Range
|
60
|
+
start_col = col_names[hash[:columns].first]
|
61
|
+
end_col = col_names[hash[:columns].last]
|
62
|
+
when Symbol
|
63
|
+
start_col = 'A'
|
64
|
+
end_col = col_names[num_columns-1]
|
65
|
+
else
|
66
|
+
raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError.new(:columns)
|
67
|
+
end
|
68
|
+
|
69
|
+
case hash[:rows]
|
70
|
+
when Integer
|
71
|
+
start_row = end_row = hash[:rows]
|
72
|
+
when Range
|
73
|
+
start_row = hash[:rows].first
|
74
|
+
end_row = hash[:rows].last
|
75
|
+
when Symbol
|
76
|
+
start_row = 0
|
77
|
+
end_row = num_rows-1
|
78
|
+
else
|
79
|
+
raise SpreadsheetArchitect::Exceptions::InvalidRangeStylesOptionError.new(:rows)
|
80
|
+
end
|
81
|
+
|
82
|
+
return "#{start_col}#{start_row}:#{end_col}#{end_row}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.verify_range(range, num_rows, col_names=Array('A'..'ZZZ'))
|
86
|
+
if range.is_a?(String)
|
87
|
+
if range.include?(':')
|
88
|
+
front, back = range.split(':')
|
89
|
+
start_col, start_row = front.scan(/\d+|\D+/)
|
90
|
+
end_col, end_row = back.scan(/\d+|\D+/)
|
91
|
+
|
92
|
+
unless col_names.include?(start_col) && col_names.include?(end_col)
|
93
|
+
raise SpreadsheetArchitect::Exceptions::BadRangeError.new(:columns)
|
94
|
+
end
|
95
|
+
|
96
|
+
unless start_row.to_i <= num_rows && end_row.to_i <= num_rows
|
97
|
+
raise SpreadsheetArchitect::Exceptions::BadRangeError.new(:rows)
|
98
|
+
end
|
99
|
+
else
|
100
|
+
raise SpreadsheetArchitect::Exceptions::BadRangeError.new(:format)
|
101
|
+
end
|
102
|
+
else
|
103
|
+
raise SpreadsheetArchitect::Exceptions::BadRangeError.new(:type)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
# only converts the first 2 levels
|
110
|
+
def self.symbolize_keys(hash={})
|
111
|
+
new_hash = {}
|
112
|
+
hash.each do |k,v|
|
113
|
+
if v.is_a?(Hash)
|
114
|
+
v.each do |k2,v2|
|
115
|
+
new_hash[k2.to_sym] = v2
|
116
|
+
end
|
117
|
+
else
|
118
|
+
new_hash[k.to_sym] = v
|
119
|
+
end
|
120
|
+
end
|
121
|
+
return new_hash
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
|
4
|
+
gem 'rails', '~> 5'
|
5
|
+
gem 'sqlite3'
|
6
|
+
|
7
|
+
gem 'spreadsheet_architect', path: '../../'
|
8
|
+
gem 'responders'
|
9
|
+
|
10
|
+
gem 'listen'
|
11
|
+
|
12
|
+
gem 'database_cleaner'
|
13
|
+
gem 'minitest-reporters'
|
14
|
+
gem 'minitest-rails'
|
15
|
+
gem 'rails-controller-testing'
|
16
|
+
gem 'better_errors'
|
17
|
+
gem 'binding_of_caller'
|
@@ -0,0 +1,176 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../../
|
3
|
+
specs:
|
4
|
+
spreadsheet_architect (2.0.0)
|
5
|
+
axlsx (>= 2.0)
|
6
|
+
axlsx_styler (>= 0.1.7)
|
7
|
+
rodf (>= 1.0.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actioncable (5.0.1)
|
13
|
+
actionpack (= 5.0.1)
|
14
|
+
nio4r (~> 1.2)
|
15
|
+
websocket-driver (~> 0.6.1)
|
16
|
+
actionmailer (5.0.1)
|
17
|
+
actionpack (= 5.0.1)
|
18
|
+
actionview (= 5.0.1)
|
19
|
+
activejob (= 5.0.1)
|
20
|
+
mail (~> 2.5, >= 2.5.4)
|
21
|
+
rails-dom-testing (~> 2.0)
|
22
|
+
actionpack (5.0.1)
|
23
|
+
actionview (= 5.0.1)
|
24
|
+
activesupport (= 5.0.1)
|
25
|
+
rack (~> 2.0)
|
26
|
+
rack-test (~> 0.6.3)
|
27
|
+
rails-dom-testing (~> 2.0)
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
29
|
+
actionview (5.0.1)
|
30
|
+
activesupport (= 5.0.1)
|
31
|
+
builder (~> 3.1)
|
32
|
+
erubis (~> 2.7.0)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
35
|
+
activejob (5.0.1)
|
36
|
+
activesupport (= 5.0.1)
|
37
|
+
globalid (>= 0.3.6)
|
38
|
+
activemodel (5.0.1)
|
39
|
+
activesupport (= 5.0.1)
|
40
|
+
activerecord (5.0.1)
|
41
|
+
activemodel (= 5.0.1)
|
42
|
+
activesupport (= 5.0.1)
|
43
|
+
arel (~> 7.0)
|
44
|
+
activesupport (5.0.1)
|
45
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
46
|
+
i18n (~> 0.7)
|
47
|
+
minitest (~> 5.1)
|
48
|
+
tzinfo (~> 1.1)
|
49
|
+
ansi (1.5.0)
|
50
|
+
arel (7.1.4)
|
51
|
+
axlsx (2.0.1)
|
52
|
+
htmlentities (~> 4.3.1)
|
53
|
+
nokogiri (>= 1.4.1)
|
54
|
+
rubyzip (~> 1.0.0)
|
55
|
+
axlsx_styler (0.1.7)
|
56
|
+
activesupport (>= 3.1)
|
57
|
+
axlsx (~> 2.0)
|
58
|
+
better_errors (2.1.1)
|
59
|
+
coderay (>= 1.0.0)
|
60
|
+
erubis (>= 2.6.6)
|
61
|
+
rack (>= 0.9.0)
|
62
|
+
binding_of_caller (0.7.2)
|
63
|
+
debug_inspector (>= 0.0.1)
|
64
|
+
builder (3.2.2)
|
65
|
+
coderay (1.1.1)
|
66
|
+
concurrent-ruby (1.0.4)
|
67
|
+
database_cleaner (1.5.3)
|
68
|
+
debug_inspector (0.0.2)
|
69
|
+
erubis (2.7.0)
|
70
|
+
ffi (1.9.14)
|
71
|
+
globalid (0.3.7)
|
72
|
+
activesupport (>= 4.1.0)
|
73
|
+
htmlentities (4.3.4)
|
74
|
+
i18n (0.7.0)
|
75
|
+
listen (3.1.5)
|
76
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
77
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
78
|
+
ruby_dep (~> 1.2)
|
79
|
+
loofah (2.0.3)
|
80
|
+
nokogiri (>= 1.5.9)
|
81
|
+
mail (2.6.4)
|
82
|
+
mime-types (>= 1.16, < 4)
|
83
|
+
method_source (0.8.2)
|
84
|
+
mime-types (3.1)
|
85
|
+
mime-types-data (~> 3.2015)
|
86
|
+
mime-types-data (3.2016.0521)
|
87
|
+
mini_portile2 (2.1.0)
|
88
|
+
minitest (5.10.1)
|
89
|
+
minitest-rails (3.0.0)
|
90
|
+
minitest (~> 5.8)
|
91
|
+
railties (~> 5.0)
|
92
|
+
minitest-reporters (1.1.13)
|
93
|
+
ansi
|
94
|
+
builder
|
95
|
+
minitest (>= 5.0)
|
96
|
+
ruby-progressbar
|
97
|
+
nio4r (1.2.1)
|
98
|
+
nokogiri (1.7.0)
|
99
|
+
mini_portile2 (~> 2.1.0)
|
100
|
+
rack (2.0.1)
|
101
|
+
rack-test (0.6.3)
|
102
|
+
rack (>= 1.0)
|
103
|
+
rails (5.0.1)
|
104
|
+
actioncable (= 5.0.1)
|
105
|
+
actionmailer (= 5.0.1)
|
106
|
+
actionpack (= 5.0.1)
|
107
|
+
actionview (= 5.0.1)
|
108
|
+
activejob (= 5.0.1)
|
109
|
+
activemodel (= 5.0.1)
|
110
|
+
activerecord (= 5.0.1)
|
111
|
+
activesupport (= 5.0.1)
|
112
|
+
bundler (>= 1.3.0, < 2.0)
|
113
|
+
railties (= 5.0.1)
|
114
|
+
sprockets-rails (>= 2.0.0)
|
115
|
+
rails-controller-testing (1.0.1)
|
116
|
+
actionpack (~> 5.x)
|
117
|
+
actionview (~> 5.x)
|
118
|
+
activesupport (~> 5.x)
|
119
|
+
rails-dom-testing (2.0.2)
|
120
|
+
activesupport (>= 4.2.0, < 6.0)
|
121
|
+
nokogiri (~> 1.6)
|
122
|
+
rails-html-sanitizer (1.0.3)
|
123
|
+
loofah (~> 2.0)
|
124
|
+
railties (5.0.1)
|
125
|
+
actionpack (= 5.0.1)
|
126
|
+
activesupport (= 5.0.1)
|
127
|
+
method_source
|
128
|
+
rake (>= 0.8.7)
|
129
|
+
thor (>= 0.18.1, < 2.0)
|
130
|
+
rake (12.0.0)
|
131
|
+
rb-fsevent (0.9.8)
|
132
|
+
rb-inotify (0.9.7)
|
133
|
+
ffi (>= 0.5.0)
|
134
|
+
responders (2.3.0)
|
135
|
+
railties (>= 4.2.0, < 5.1)
|
136
|
+
rodf (1.0.0)
|
137
|
+
activesupport (>= 3.0)
|
138
|
+
builder (>= 3.0)
|
139
|
+
rubyzip (>= 1.0)
|
140
|
+
ruby-progressbar (1.8.1)
|
141
|
+
ruby_dep (1.5.0)
|
142
|
+
rubyzip (1.0.0)
|
143
|
+
sprockets (3.7.1)
|
144
|
+
concurrent-ruby (~> 1.0)
|
145
|
+
rack (> 1, < 3)
|
146
|
+
sprockets-rails (3.2.0)
|
147
|
+
actionpack (>= 4.0)
|
148
|
+
activesupport (>= 4.0)
|
149
|
+
sprockets (>= 3.0.0)
|
150
|
+
sqlite3 (1.3.12)
|
151
|
+
thor (0.19.4)
|
152
|
+
thread_safe (0.3.5)
|
153
|
+
tzinfo (1.2.2)
|
154
|
+
thread_safe (~> 0.1)
|
155
|
+
websocket-driver (0.6.4)
|
156
|
+
websocket-extensions (>= 0.1.0)
|
157
|
+
websocket-extensions (0.1.2)
|
158
|
+
|
159
|
+
PLATFORMS
|
160
|
+
ruby
|
161
|
+
|
162
|
+
DEPENDENCIES
|
163
|
+
better_errors
|
164
|
+
binding_of_caller
|
165
|
+
database_cleaner
|
166
|
+
listen
|
167
|
+
minitest-rails
|
168
|
+
minitest-reporters
|
169
|
+
rails (~> 5)
|
170
|
+
rails-controller-testing
|
171
|
+
responders
|
172
|
+
spreadsheet_architect!
|
173
|
+
sqlite3
|
174
|
+
|
175
|
+
BUNDLED WITH
|
176
|
+
1.13.7
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require turbolinks
|
16
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class SpreadsheetsController < ApplicationController
|
2
|
+
|
3
|
+
respond_to :csv, :xlsx, :ods
|
4
|
+
|
5
|
+
def csv
|
6
|
+
render csv: Post.to_csv
|
7
|
+
end
|
8
|
+
|
9
|
+
def ods
|
10
|
+
render ods: Post.to_ods
|
11
|
+
end
|
12
|
+
|
13
|
+
def xlsx
|
14
|
+
render xlsx: Post.to_xlsx, filename: 'Posts'
|
15
|
+
end
|
16
|
+
|
17
|
+
def alt_xlsx
|
18
|
+
@posts = Post.all
|
19
|
+
respond_with @posts
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_xlsx
|
23
|
+
headers = [
|
24
|
+
['Latest Posts'],
|
25
|
+
['Title','Category','Author','Posted on','Earnings','Title','Category','Author','Posted on','Earnings']
|
26
|
+
]
|
27
|
+
|
28
|
+
data = 50.times.map{|x| ['Title','Category','Author','Posted on','Earnings','Title','Category','Author','Posted on','Earnings'] }
|
29
|
+
|
30
|
+
header_style = {}
|
31
|
+
|
32
|
+
row_style = {}
|
33
|
+
|
34
|
+
column_styles = [
|
35
|
+
{columns: 0, styles: {bold: true}},
|
36
|
+
{columns: (1..3), styles: {format_code: "$#,##0.00"}},
|
37
|
+
{columns: [4,9], include_header: true, styles: {italic: true}}
|
38
|
+
]
|
39
|
+
|
40
|
+
range_styles = [
|
41
|
+
{range: "B2:C4", styles: {background_color: "CCCCCC"}}
|
42
|
+
]
|
43
|
+
|
44
|
+
borders = [
|
45
|
+
{range: "B2:C4"},
|
46
|
+
{range: "D6:D7", border_styles: {style: :dashdot, color: "333333"}},
|
47
|
+
{rows: (2..11), border_styles: {edges: [:top,:bottom]}},
|
48
|
+
{rows: [1,3,5], columns: ('B'..'F')},
|
49
|
+
{rows: 1},
|
50
|
+
{columns: 0, border_styles: {edges: [:right], style: :thick}},
|
51
|
+
{columns: (1..2)},
|
52
|
+
{columns: ('D'..'F')},
|
53
|
+
{columns: [4,6,8]},
|
54
|
+
{columns: ['A','C','E']}
|
55
|
+
|
56
|
+
]
|
57
|
+
|
58
|
+
merges = [
|
59
|
+
{range: "A1:C1"}
|
60
|
+
]
|
61
|
+
|
62
|
+
render xlsx: SpreadsheetArchitect.to_xlsx({
|
63
|
+
headers: headers,
|
64
|
+
data: data,
|
65
|
+
header_style: header_style,
|
66
|
+
row_style: row_style,
|
67
|
+
column_styles: column_styles,
|
68
|
+
range_styles: range_styles,
|
69
|
+
borders: borders,
|
70
|
+
merges: merges
|
71
|
+
})
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|