spreadsheet_architect 2.0.2 → 2.1.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 +34 -26
- data/README.md +15 -15
- data/Rakefile +5 -3
- data/lib/spreadsheet_architect/class_methods/ods.rb +16 -2
- data/lib/spreadsheet_architect/monkey_patches/axlsx_column_width.rb +33 -3
- data/lib/spreadsheet_architect/utils/xlsx.rb +36 -18
- data/lib/spreadsheet_architect/version.rb +1 -1
- data/test/custom_assertions.rb +21 -0
- data/test/{rails_app → dummy_app}/Rakefile +3 -2
- data/test/{rails_app/public/apple-touch-icon-precomposed.png → dummy_app/app/assets/javascripts/application.js} +0 -0
- data/test/dummy_app/app/assets/stylesheets/application.css +3 -0
- data/test/{rails_app → dummy_app}/app/controllers/application_controller.rb +1 -1
- data/test/{rails_app → dummy_app}/app/controllers/spreadsheets_controller.rb +0 -0
- data/test/{rails_app → dummy_app}/app/models/active_model_object.rb +0 -0
- data/test/{rails_app → dummy_app}/app/models/application_record.rb +0 -0
- data/test/{rails_app → dummy_app}/app/models/bad_plain_ruby_object.rb +0 -0
- data/test/{rails_app → dummy_app}/app/models/custom_post.rb +2 -2
- data/test/{rails_app → dummy_app}/app/models/plain_ruby_object.rb +0 -0
- data/test/{rails_app → dummy_app}/app/models/post.rb +0 -0
- data/test/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/test/dummy_app/app/views/reports/sample.html.erb +1 -0
- data/test/dummy_app/config.ru +4 -0
- data/test/dummy_app/config/application.rb +69 -0
- data/test/dummy_app/config/boot.rb +10 -0
- data/test/dummy_app/config/database.yml +25 -0
- data/test/dummy_app/config/environment.rb +5 -0
- data/test/dummy_app/config/environments/development.rb +30 -0
- data/test/dummy_app/config/environments/production.rb +60 -0
- data/test/dummy_app/config/environments/test.rb +41 -0
- data/test/{rails_app → dummy_app}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/dummy_app/config/initializers/inflections.rb +10 -0
- data/test/{rails_app → dummy_app}/config/initializers/mime_types.rb +1 -0
- data/test/dummy_app/config/initializers/secret_token.rb +11 -0
- data/test/dummy_app/config/initializers/session_store.rb +8 -0
- data/test/dummy_app/config/initializers/spreadsheet_architect.rb +11 -0
- data/test/{rails_app → dummy_app}/config/initializers/wrap_parameters.rb +5 -5
- data/test/dummy_app/config/locales/en.yml +5 -0
- data/test/{rails_app → dummy_app}/config/routes.rb +1 -1
- data/test/{rails_app → dummy_app}/config/secrets.yml +4 -4
- data/test/{rails_app → dummy_app}/db/migrate/20170103234524_add_posts.rb +0 -0
- data/test/{rails_app → dummy_app}/db/schema.rb +4 -4
- data/test/{rails_app → dummy_app}/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/development.log +28 -0
- data/test/dummy_app/log/test.log +24564 -0
- data/test/dummy_app/tmp/active_model_object/csv.csv +21 -0
- data/test/dummy_app/tmp/active_model_object/ods.ods +0 -0
- data/test/dummy_app/tmp/active_model_object/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/custom_posts/csv.csv +6 -0
- data/test/dummy_app/tmp/custom_posts/empty.xlsx +0 -0
- data/test/dummy_app/tmp/custom_posts/ods.ods +0 -0
- data/test/dummy_app/tmp/custom_posts/xlsx.xlsx +0 -0
- data/test/{rails_app → dummy_app}/tmp/empty_model.csv +0 -0
- data/test/dummy_app/tmp/empty_model.xlsx +0 -0
- data/test/{rails_app → dummy_app}/tmp/empty_sa.csv +0 -0
- data/test/dummy_app/tmp/empty_sa.xlsx +0 -0
- data/test/dummy_app/tmp/extreme.xlsx +0 -0
- data/test/dummy_app/tmp/integration_tests/alt_xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/integration_tests/csv.csv +6 -0
- data/test/dummy_app/tmp/integration_tests/ods.ods +0 -0
- data/test/dummy_app/tmp/integration_tests/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/model.csv +6 -0
- data/test/dummy_app/tmp/model.xlsx +0 -0
- data/test/dummy_app/tmp/ods/empty_model.ods +0 -0
- data/test/{rails_app → dummy_app}/tmp/ods/empty_sa.ods +0 -0
- data/test/dummy_app/tmp/ods/model.ods +0 -0
- data/test/dummy_app/tmp/ods/model_options.ods +0 -0
- data/test/dummy_app/tmp/ods/sa.ods +0 -0
- data/test/dummy_app/tmp/options.csv +6 -0
- data/test/dummy_app/tmp/plain_ruby_object/csv.csv +4 -0
- data/test/dummy_app/tmp/plain_ruby_object/ods.ods +0 -0
- data/test/dummy_app/tmp/plain_ruby_object/xlsx.xlsx +0 -0
- data/test/dummy_app/tmp/posts/csv.csv +6 -0
- data/test/dummy_app/tmp/posts/empty.xlsx +0 -0
- data/test/dummy_app/tmp/posts/ods.ods +0 -0
- data/test/dummy_app/tmp/posts/xlsx.xlsx +0 -0
- data/test/{rails_app → dummy_app}/tmp/sa.csv +0 -0
- data/test/dummy_app/tmp/sa.xlsx +0 -0
- data/test/integration/application_test.rb +49 -0
- data/test/{rails_app/test/models → models}/active_model_object_test.rb +1 -4
- data/test/{rails_app/test/models → models}/bad_plain_ruby_object_test.rb +0 -2
- data/test/{rails_app/test/models → models}/csv_test.rb +5 -6
- data/test/{rails_app/test/models → models}/custom_post_test.rb +0 -3
- data/test/{rails_app/test/models → models}/ods_test.rb +6 -9
- data/test/{rails_app/test/models → models}/plain_ruby_object_test.rb +1 -4
- data/test/{rails_app/test/models → models}/post_test.rb +1 -4
- data/test/{rails_app/test/models → models}/spreadsheet_architect_utils_test.rb +0 -1
- data/test/{rails_app/test/models → models}/xlsx_test.rb +6 -7
- data/test/spreadsheet_architect_test.rb +11 -0
- data/test/test_helper.rb +35 -0
- metadata +186 -228
- data/test/rails_app/Gemfile +0 -17
- data/test/rails_app/Gemfile.lock +0 -176
- data/test/rails_app/README.md +0 -24
- data/test/rails_app/app/assets/config/manifest.js +0 -3
- data/test/rails_app/app/assets/javascripts/application.js +0 -16
- data/test/rails_app/app/assets/javascripts/cable.js +0 -13
- data/test/rails_app/app/assets/stylesheets/application.css +0 -15
- data/test/rails_app/app/channels/application_cable/channel.rb +0 -4
- data/test/rails_app/app/channels/application_cable/connection.rb +0 -4
- data/test/rails_app/app/helpers/application_helper.rb +0 -2
- data/test/rails_app/app/jobs/application_job.rb +0 -2
- data/test/rails_app/app/mailers/application_mailer.rb +0 -4
- data/test/rails_app/app/views/layouts/application.html.erb +0 -14
- data/test/rails_app/app/views/layouts/mailer.html.erb +0 -13
- data/test/rails_app/app/views/layouts/mailer.text.erb +0 -1
- data/test/rails_app/bin/bundle +0 -3
- data/test/rails_app/bin/rails +0 -9
- data/test/rails_app/bin/rake +0 -9
- data/test/rails_app/bin/setup +0 -34
- data/test/rails_app/bin/spring +0 -16
- data/test/rails_app/bin/update +0 -29
- data/test/rails_app/config.ru +0 -5
- data/test/rails_app/config/application.rb +0 -15
- data/test/rails_app/config/boot.rb +0 -3
- data/test/rails_app/config/cable.yml +0 -9
- data/test/rails_app/config/database.yml +0 -16
- data/test/rails_app/config/environment.rb +0 -5
- data/test/rails_app/config/environments/development.rb +0 -54
- data/test/rails_app/config/environments/production.rb +0 -86
- data/test/rails_app/config/environments/test.rb +0 -42
- data/test/rails_app/config/initializers/application_controller_renderer.rb +0 -6
- data/test/rails_app/config/initializers/assets.rb +0 -11
- data/test/rails_app/config/initializers/cookies_serializer.rb +0 -5
- data/test/rails_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/rails_app/config/initializers/inflections.rb +0 -16
- data/test/rails_app/config/initializers/new_framework_defaults.rb +0 -24
- data/test/rails_app/config/initializers/session_store.rb +0 -3
- data/test/rails_app/config/locales/en.yml +0 -23
- data/test/rails_app/db/development.sqlite3 +0 -0
- data/test/rails_app/db/seeds.rb +0 -7
- data/test/rails_app/log/development.log +0 -1195
- data/test/rails_app/log/test.log +0 -55339
- data/test/rails_app/public/404.html +0 -67
- data/test/rails_app/public/422.html +0 -67
- data/test/rails_app/public/500.html +0 -66
- 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 +0 -5
- data/test/rails_app/test/controllers/spreadsheets_controller_test.rb +0 -46
- data/test/rails_app/test/test_helper.rb +0 -21
- data/test/rails_app/tmp/active_model_object/csv.csv +0 -21
- 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 +0 -1
- 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 +0 -1
- 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.xlsx +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 +0 -1
- 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/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 +0 -1
- data/test/rails_app/tmp/plain_ruby_object/csv.csv +0 -4
- 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 +0 -1
- 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.xlsx +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332a260a2197fc58114223a6c5be628144e45042
|
4
|
+
data.tar.gz: 26a2abd7e96fc28512215f5e17be5dd5f52db9c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecbf18abbf5a5e307040615570590588a45bc9e82d90a069df701c5daa485a6b2fd4bb4010e61437bc7d164d83a72631960d5562fd34ab449ef15b6df8cf0f63
|
7
|
+
data.tar.gz: 9dd2c71d8ac044c704f028b778f0368991129e33db3ac93c6004f91a2cf7d376e3e68baf4b2f2e0cad7ecdc3613e6aa8078c864d98259ae9aa0233b61ecf0814
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
3
|
|
4
|
-
- **
|
4
|
+
- **2.1.0** - June 20, 2018
|
5
|
+
- PR #15 - Improved the method symbolize_keys. This method did not work properly for nested objects.
|
6
|
+
- PR #15 - Added the ability to pass `:text_wrap` option within the `:alignment` style
|
7
|
+
- Make axlsx styles higher precendence over Spreadsheet Architect style aliases
|
8
|
+
- Use `prepend` monkey patches in Ruby 2+ to avoid annoying overwrite warnings when using old `define_method` monkey patches
|
9
|
+
- Due to [RODF bug](https://github.com/thiagoarrais/rodf/issues/19) convert all Date and Time cells to String in ODS spreadsheets
|
10
|
+
- Improve test suite
|
11
|
+
- Dont test against Ruby versions that Rails no longer supports. Gem code should remain compatible with Ruby 1.9.3.
|
12
|
+
- **2.0.2** - July 14 2017
|
5
13
|
- Fix bug with range styles rows option not counting headers
|
6
14
|
- Fix bug with range styles rows :all option
|
7
|
-
- **
|
15
|
+
- **2.0.1** - February 16 2017
|
8
16
|
- Fix bug where `SpreadsheetArchitect.default_options` and `SPREADSHEET_OPTIONS` were being overwritten
|
9
17
|
- Fix bug where col_styles ignored previous styles on header when using `include_header` option
|
10
18
|
- Errors now try to provide which value is the cause
|
11
|
-
- **
|
19
|
+
- **2.0.0** - January 28 2017
|
12
20
|
- Add to xlsx: `merges`, `column_styles`, `range_styles`, `borders`, `column_widths` multi-row headers, date/time default format_code
|
13
21
|
- Add `column_types` option for xlsx and ods
|
14
22
|
- Add ability to make multi-sheet spreadsheets in XLSX & ODS
|
@@ -16,52 +24,52 @@ CHANGELOG
|
|
16
24
|
- Add Examples
|
17
25
|
- Add Axlsx Style Reference
|
18
26
|
- Refractor into smaller files
|
19
|
-
- **
|
27
|
+
- **1.4.8** - December 6 2016
|
20
28
|
- Lock `rodf` gem to v0.3.7 for last v1 version of this gem
|
21
|
-
- **
|
29
|
+
- **1.4.7** - November 7 2016
|
22
30
|
- Fix method arguments for `to_rodf_spreadsheet` method
|
23
|
-
- **
|
31
|
+
- **1.4.6** - May 16 2016
|
24
32
|
- Fix hash syntax for support of ruby v2.1 and below
|
25
|
-
- **
|
33
|
+
- **1.4.5** - May 4 2016
|
26
34
|
- Bug fixes
|
27
|
-
- **
|
35
|
+
- **1.4.4** - May 3 2016
|
28
36
|
- Add Ability to add format_code to all numbers body rows
|
29
|
-
- **
|
37
|
+
- **1.4.3** - May 3 2016
|
30
38
|
- Bug fixes
|
31
|
-
- **
|
39
|
+
- **1.4.2** - May 3 2016
|
32
40
|
- Add to_axlsx_package, to_rodf_spreadsheet methods for the item to be further manipulated. Ex. axlsx_styler
|
33
|
-
- **
|
41
|
+
- **1.4.1** - May 2 2016
|
34
42
|
- Add rails generator for project defaults initializer
|
35
|
-
- **
|
43
|
+
- **1.4.0** - April 29 2016
|
36
44
|
- Add to_xlsx, to_ods, & to_csv to SpreadsheetArchitect model for direct calling by passing in cell data
|
37
|
-
- **
|
45
|
+
- **1.3.0** - April 21 2016
|
38
46
|
- Add ability to create class/model and project option defaults
|
39
|
-
- **
|
47
|
+
- **1.2.5** - March 25 2016
|
40
48
|
- Fix each_with_index bug
|
41
|
-
- **
|
49
|
+
- **1.2.4** - March 24 2016
|
42
50
|
- Fix cell type logic for symbol methods
|
43
|
-
- **
|
51
|
+
- **1.2.3** - March 20 2016
|
44
52
|
- Fix cell type logic
|
45
|
-
- **
|
53
|
+
- **1.2.2** - March 19 2016
|
46
54
|
- Make cell type numeric if value is numeric
|
47
|
-
- **
|
55
|
+
- **1.2.1** - March 13 2016
|
48
56
|
- Better error reporting
|
49
57
|
- Fix for Plain ruby models
|
50
|
-
- **
|
58
|
+
- **1.2.0** - March 10 2016
|
51
59
|
- Fix Bug: first row data repeated for all records on custom values
|
52
|
-
- **
|
53
|
-
- Move spreadsheet_columns method from the class to the instance
|
60
|
+
- **1.1.0** - March 3 2016
|
61
|
+
- Breaking Change - Move spreadsheet_columns method from the class to the instance
|
54
62
|
- Fix Bug: remove default underline on cells
|
55
|
-
- **
|
63
|
+
- **1.0.4** - March 1 2016
|
56
64
|
- Extract helper methods to seperate module
|
57
65
|
- Improve readme
|
58
|
-
- **
|
66
|
+
- **1.0.3** - March 1 2016
|
59
67
|
- Fix/Improve renderers
|
60
68
|
- Fix header default background color
|
61
69
|
- Fix default columns
|
62
|
-
- **
|
70
|
+
- **1.0.2** - February 26 2016
|
63
71
|
- Enhance Style options
|
64
|
-
- **
|
72
|
+
- **1.0.1** - February 26 2016
|
65
73
|
- Fix bug in renderers
|
66
|
-
- **
|
74
|
+
- **1.0.0** - February 26 2016
|
67
75
|
- Gem Initial Release
|
data/README.md
CHANGED
@@ -92,7 +92,7 @@ class PostsController < ActionController::Base
|
|
92
92
|
respond_with @posts
|
93
93
|
end
|
94
94
|
|
95
|
-
# Using respond_with with custom options
|
95
|
+
# OR Using respond_with with custom options
|
96
96
|
def index
|
97
97
|
@posts = Post.order(published_at: :asc)
|
98
98
|
|
@@ -103,7 +103,7 @@ class PostsController < ActionController::Base
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
# Using responders
|
106
|
+
# OR Using responders
|
107
107
|
def index
|
108
108
|
@posts = Post.order(published_at: :asc)
|
109
109
|
|
@@ -115,7 +115,7 @@ class PostsController < ActionController::Base
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
# Using responders with custom options
|
118
|
+
# OR Using responders with custom options
|
119
119
|
def index
|
120
120
|
@posts = Post.order(published_at: :asc)
|
121
121
|
|
@@ -133,25 +133,25 @@ end
|
|
133
133
|
```ruby
|
134
134
|
# Ex. with ActiveRecord relation
|
135
135
|
File.open('path/to/file.xlsx', 'w+b') do |f|
|
136
|
-
f.write
|
136
|
+
f.write Post.order(published_at: :asc).to_xlsx
|
137
137
|
end
|
138
138
|
File.open('path/to/file.ods', 'w+b') do |f|
|
139
|
-
f.write
|
139
|
+
f.write Post.order(published_at: :asc).to_ods
|
140
140
|
end
|
141
141
|
File.open('path/to/file.csv', 'w+b') do |f|
|
142
|
-
f.write
|
142
|
+
f.write Post.order(published_at: :asc).to_csv
|
143
143
|
end
|
144
144
|
|
145
145
|
# Ex. with plain ruby class
|
146
146
|
File.open('path/to/file.xlsx', 'w+b') do |f|
|
147
|
-
f.write
|
147
|
+
f.write Post.to_xlsx(instances: posts_array)
|
148
148
|
end
|
149
149
|
|
150
150
|
# Ex. One time Usage
|
151
151
|
File.open('path/to/file.xlsx', 'w+b') do |f|
|
152
152
|
headers = ['Col 1','Col 2','Col 3']
|
153
153
|
data = [[1,2,3], [4,5,6], [7,8,9]]
|
154
|
-
f.write
|
154
|
+
f.write SpreadsheetArchitect::to_xlsx(data: data, headers: headers)
|
155
155
|
end
|
156
156
|
```
|
157
157
|
<br>
|
@@ -213,7 +213,7 @@ end
|
|
213
213
|
|**range_styles**<br>*Array*||[See this example for usage](https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)|
|
214
214
|
|**merges**<br>*Array*||Merge cells. [See this example for usage](https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)|
|
215
215
|
|**borders**<br>*Array*||[See this example for usage](https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb)|
|
216
|
-
|**column_types**<br>*Array*||Valid types for XLSX are :string, :integer, :float, :
|
216
|
+
|**column_types**<br>*Array*||Valid types for XLSX are :string, :integer, :float, :boolean, nil = auto determine.|
|
217
217
|
|**column_widths**<br>*Array*||Sometimes you may want explicit column widths. Use nil if you want a column to autofit again.|
|
218
218
|
|
219
219
|
<br>
|
@@ -227,7 +227,7 @@ end
|
|
227
227
|
|**sheet_name**<br>*String*|`Sheet1`||
|
228
228
|
|**header_style**<br>*Hash*|`{background_color: "AAAAAA", color: "FFFFFF", align: :center, font_size: 10, bold: true}`|Note: Currently ODS only supports these options|
|
229
229
|
|**row_style**<br>*Hash*|`{background_color: nil, color: "000000", align: :left, font_size: 10, bold: false}`|Styles for non-header rows. Currently ODS only supports these options|
|
230
|
-
|**column_types**<br>*Array*||Valid types for ODS are :string, :float, :date, :percent, :currency, nil = auto determine|
|
230
|
+
|**column_types**<br>*Array*||Valid types for ODS are :string, :float, :date, :time, :percent, :currency, nil = auto determine. Due to [RODF issue #19](https://github.com/thiagoarrais/rodf/issues/19), :date/:time will be converted to :string |
|
231
231
|
|
232
232
|
<br>
|
233
233
|
|
@@ -272,7 +272,7 @@ end
|
|
272
272
|
SpreadsheetArchitect.default_options = {
|
273
273
|
headers: true,
|
274
274
|
header_style: {background_color: 'AAAAAA', color: 'FFFFFF', align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
275
|
-
row_style: {background_color: nil, color: '
|
275
|
+
row_style: {background_color: nil, color: '000000', align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
|
276
276
|
sheet_name: 'My Project Export',
|
277
277
|
column_styles: [],
|
278
278
|
range_styles: [],
|
@@ -283,7 +283,7 @@ SpreadsheetArchitect.default_options = {
|
|
283
283
|
```
|
284
284
|
|
285
285
|
# Complex XLSX Example with Styling
|
286
|
-
See this example:
|
286
|
+
See this example: https://github.com/westonganger/spreadsheet_architect/blob/master/examples/complex_xlsx_styling.rb
|
287
287
|
|
288
288
|
|
289
289
|
# Multi Sheet XLSX or ODS spreadsheets
|
@@ -296,11 +296,11 @@ spreadsheet = SpreadsheetArchitect.to_rodf_spreadsheet({data: data, headers: hea
|
|
296
296
|
SpreadsheetArchitect.to_rodf_spreadsheet({data: data, headers: headers}, spreadsheet) # to combine two sheets to one file
|
297
297
|
```
|
298
298
|
|
299
|
-
See this example:
|
299
|
+
See this example: https://github.com/westonganger/spreadsheet_architect/blob/master/examples/multi_sheet_spreadsheets.rb
|
300
300
|
|
301
301
|
|
302
302
|
# Axlsx Style Reference
|
303
|
-
I have compiled a list of all available style options for
|
303
|
+
I have compiled a list of all available style options for axlsx here: https://github.com/westonganger/spreadsheet_architect/blob/master/docs/axlsx_style_reference.md
|
304
304
|
|
305
305
|
|
306
306
|
# Credits
|
@@ -308,4 +308,4 @@ Created by [@westonganger](https://github.com/westonganger)
|
|
308
308
|
|
309
309
|
For any consulting or contract work please contact me via my company website: [Solid Foundation Web Development](https://solidfoundationwebdev.com)
|
310
310
|
|
311
|
-
[![Solid Foundation Web Development Logo](https://solidfoundationwebdev.com/logo.png)](https://solidfoundationwebdev.com)
|
311
|
+
[![Solid Foundation Web Development Logo](https://solidfoundationwebdev.com/logo-sm.png)](https://solidfoundationwebdev.com)
|
data/Rakefile
CHANGED
@@ -3,10 +3,12 @@ require 'bundler/gem_tasks'
|
|
3
3
|
|
4
4
|
task :test do
|
5
5
|
require 'rake/testtask'
|
6
|
-
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << 'lib'
|
7
9
|
t.libs << 'test'
|
8
|
-
t.
|
9
|
-
t.verbose =
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
11
|
+
t.verbose = false
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
@@ -47,8 +47,22 @@ module SpreadsheetArchitect
|
|
47
47
|
|
48
48
|
options[:data].each_with_index do |row_data, index|
|
49
49
|
row do
|
50
|
-
row_data.each_with_index do |
|
51
|
-
|
50
|
+
row_data.each_with_index do |val, i|
|
51
|
+
if options[:types]
|
52
|
+
type = options[:types][i]
|
53
|
+
end
|
54
|
+
|
55
|
+
if type
|
56
|
+
if [:date, :time].include?(type)
|
57
|
+
type = :string
|
58
|
+
val = val.to_s
|
59
|
+
end
|
60
|
+
elsif val.respond_to?(:strftime)
|
61
|
+
type = :string
|
62
|
+
val = val.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
cell val, style: :row_style, type: (options[:types][i] if options[:types])
|
52
66
|
end
|
53
67
|
end
|
54
68
|
end
|
@@ -1,4 +1,33 @@
|
|
1
|
-
if
|
1
|
+
if RUBY_VERSION.to_f >= 2
|
2
|
+
|
3
|
+
module SpreadsheetArchitect
|
4
|
+
module AxlsxColumnWidthPatch
|
5
|
+
def initialize(*args)
|
6
|
+
@width = nil
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def width=(v)
|
11
|
+
if v.nil?
|
12
|
+
@custom_width = false
|
13
|
+
@width = nil
|
14
|
+
elsif @width.nil? || @width < v+5
|
15
|
+
@custom_width = true
|
16
|
+
@best_fit = true
|
17
|
+
@width = v + 5
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Axlsx
|
24
|
+
class Col
|
25
|
+
prepend ::SpreadsheetArchitect::AxlsxColumnWidthPatch
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
else
|
30
|
+
|
2
31
|
module Axlsx
|
3
32
|
class Col
|
4
33
|
original_initialize = instance_method(:initialize)
|
@@ -13,11 +42,12 @@ if defined? Axlsx
|
|
13
42
|
@custom_width = false
|
14
43
|
@width = nil
|
15
44
|
elsif @width.nil? || @width < v+5
|
16
|
-
@custom_width =
|
45
|
+
@custom_width = true
|
46
|
+
@best_fit = true
|
17
47
|
@width = v + 5
|
18
48
|
end
|
19
49
|
end
|
20
|
-
|
21
50
|
end
|
22
51
|
end
|
52
|
+
|
23
53
|
end
|
@@ -28,27 +28,48 @@ module SpreadsheetArchitect
|
|
28
28
|
styles = {} unless styles.is_a?(Hash)
|
29
29
|
styles = self.symbolize_keys(styles)
|
30
30
|
|
31
|
-
if styles[:
|
32
|
-
styles[:
|
31
|
+
if styles[:fg_color].nil?
|
32
|
+
if styles[:color].respond_to?(:sub) && !styles[:color].empty?
|
33
|
+
styles[:fg_color] = styles.delete(:color).sub('#','')
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
|
-
if styles[:
|
36
|
-
styles[:
|
37
|
+
if styles[:bg_color].nil?
|
38
|
+
if styles[:background_color].respond_to?(:sub) && !styles[:background_color].empty?
|
39
|
+
styles[:bg_color] = styles.delete(:background_color).sub('#','')
|
40
|
+
end
|
37
41
|
end
|
38
|
-
|
39
|
-
if styles[:align]
|
42
|
+
|
43
|
+
if styles[:alignment].nil? && styles[:align]
|
40
44
|
if styles[:align].is_a?(Hash)
|
41
|
-
styles[:alignment] = {
|
42
|
-
|
45
|
+
styles[:alignment] = {
|
46
|
+
horizontal: styles[:align][:horizontal],
|
47
|
+
vertical: styles[:align][:vertical],
|
48
|
+
wrap_text: styles[:align][:wrap_text]
|
49
|
+
}
|
43
50
|
else
|
44
51
|
styles[:alignment] = {horizontal: styles.delete(:align)}
|
45
52
|
end
|
53
|
+
|
54
|
+
styles.delete(:align)
|
55
|
+
end
|
56
|
+
|
57
|
+
if styles[:b].nil?
|
58
|
+
styles[:b] = styles.delete(:bold)
|
46
59
|
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
60
|
|
61
|
+
if styles[:sz].nil?
|
62
|
+
styles[:sz] = styles.delete(:font_size)
|
63
|
+
end
|
64
|
+
|
65
|
+
if styles[:i].nil?
|
66
|
+
styles[:i] = styles.delete(:italic)
|
67
|
+
end
|
68
|
+
|
69
|
+
if styles[:u].nil?
|
70
|
+
styles[:u] = styles.delete(:underline)
|
71
|
+
end
|
72
|
+
|
52
73
|
styles.delete_if{|k,v| v.nil?}
|
53
74
|
end
|
54
75
|
|
@@ -106,19 +127,16 @@ module SpreadsheetArchitect
|
|
106
127
|
|
107
128
|
private
|
108
129
|
|
109
|
-
# only converts the first 2 levels
|
110
130
|
def self.symbolize_keys(hash={})
|
111
131
|
new_hash = {}
|
112
|
-
hash.each do |k,v|
|
132
|
+
hash.each do |k, v|
|
113
133
|
if v.is_a?(Hash)
|
114
|
-
|
115
|
-
new_hash[k2.to_sym] = v2
|
116
|
-
end
|
134
|
+
new_hash[k.to_sym] = self.symbolize_keys(v)
|
117
135
|
else
|
118
136
|
new_hash[k.to_sym] = v
|
119
137
|
end
|
120
138
|
end
|
121
|
-
|
139
|
+
new_hash
|
122
140
|
end
|
123
141
|
|
124
142
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def assert_changed(expression, &block)
|
2
|
+
if expression.respond_to?(:call)
|
3
|
+
e = expression
|
4
|
+
else
|
5
|
+
e = lambda{ eval(expression, block.binding) }
|
6
|
+
end
|
7
|
+
old = e.call
|
8
|
+
block.call
|
9
|
+
assert_not_equal old, e.call
|
10
|
+
end
|
11
|
+
|
12
|
+
def assert_not_changed(expression, &block)
|
13
|
+
if expression.respond_to?(:call)
|
14
|
+
e = expression
|
15
|
+
else
|
16
|
+
e = lambda{ eval(expression, block.binding) }
|
17
|
+
end
|
18
|
+
old = e.call
|
19
|
+
block.call
|
20
|
+
assert_equal old, e.call
|
21
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
3
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
4
|
|
4
|
-
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
5
6
|
|
6
|
-
|
7
|
+
Dummy::Application.load_tasks
|
File without changes
|