spreadsheet_architect 4.1.0 → 4.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -16
- data/README.md +15 -14
- data/lib/spreadsheet_architect/utils.rb +18 -15
- data/lib/spreadsheet_architect/utils/xlsx.rb +32 -24
- data/lib/spreadsheet_architect/version.rb +1 -1
- data/test/dummy_app/app/controllers/spreadsheets_controller.rb +5 -2
- data/test/dummy_app/config/application.rb +1 -1
- data/test/dummy_app/config/environments/test.rb +1 -1
- data/test/dummy_app/db/migrate/20170103234524_add_posts.rb +1 -1
- data/test/dummy_app/log/test.log +7467 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/options_test.rb +9 -0
- data/test/unit/utils_test.rb +8 -1
- metadata +18 -4
- data/test/unit/regressions_test.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f453f3bd541db38744f93c7803a473dea7f8dee0c9c45ab86523992c78bd6317
|
4
|
+
data.tar.gz: 5c92d3ac4e35db0c17bd4da1e4325d08700decf476546fde20a66aa6057dacdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e89d0f1f1968275084495fdd420af039b61d7033606be0d9b63428fc3aab944baf82377103057fbf1ec43c91c02a7c48210bd81617ba55893ef998c3848265c0
|
7
|
+
data.tar.gz: ddfdcd2c578a1aa10dd2839368cdf99b897a49abf1a888bae40dbd08ad310f4ee26a5bc93ce9fdd484092b5f32ee4d5195c7cb5bdb466fcdf5dec6250e79603e
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,23 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
3
|
|
4
|
-
- **Unreleased**
|
4
|
+
- **Unreleased** - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v4.2.0...master)
|
5
5
|
- Nothing yet
|
6
|
-
|
6
|
+
|
7
|
+
- **4.2.0** - May 27, 2021 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v4.1.0...v4.2.0)
|
8
|
+
- Add option `:skip_defaults` which removes the defaults and default styles. Particularily useful for heavily customized spreadsheets where the default styles get in the way.
|
9
|
+
- Fix bug where styles werent being un-applied when using the `false` value.
|
10
|
+
- Add style aliases for `:valign` and `:wrap_text`
|
11
|
+
- Fix error with `headers: false`, previously had to use `headers: []`
|
12
|
+
|
13
|
+
- **4.1.0** - Nov 20, 2020 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v4.0.1...v4.1.0)
|
7
14
|
- Raise ArgumentError when invalid option names are given
|
8
|
-
|
15
|
+
|
16
|
+
- **4.0.1** - Nov 20, 2020 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v4.0.0...v4.0.1)
|
9
17
|
- Fix bug with `headers: false` where a blank header row is still added
|
10
18
|
- Fix Bug for older version of `caxlsx` v2.0.2
|
11
|
-
|
19
|
+
|
20
|
+
- **4.0.0** - Mar 3, 2020 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v3.3.1...v4.0.0)
|
12
21
|
- Switch to the `caxlsx` gem (Community Axlsx) from the legacy unmaintained `axlsx` gem. Axlsx has had a long history of being poorly maintained so this community gem improves the situation.
|
13
22
|
- Require Ruby 2.3+
|
14
23
|
- Ensure all options using Hash are automatically converted to symbol only hashes
|
@@ -16,29 +25,35 @@ CHANGELOG
|
|
16
25
|
- Add XLSX option `:freeze_headers` to freeze the headers of your spreadsheet
|
17
26
|
- Remove old Axlsx patch for column width
|
18
27
|
- Backport new code for `string_width` calculations to Axlsx 3.0.1 and below.
|
19
|
-
|
28
|
+
|
29
|
+
- **3.3.1** - Dec 2, 2019 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v3.3.0...v3.3.1)
|
20
30
|
- [Issue #30](https://github.com/westonganger/spreadsheet_architect/issues/30) - Fix duplicate constant warning for XLSX_COLUMN_TYPES
|
21
|
-
|
31
|
+
|
32
|
+
- **3.3.0** - Nov 28, 2019 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v3.2.1...v3.3.0)
|
22
33
|
- Fix `:borders` option, was broken in v3.2.1
|
23
34
|
- Fix bug when passing `false` to `:headers` option
|
24
35
|
- Raise error when unsupported column type is passed
|
25
36
|
- Remove claimed support for `:currency` and `:percent` for ODS spreadsheets as they were not working. PR Wanted.
|
26
|
-
|
37
|
+
|
38
|
+
- **3.2.1** - April 10, 2019 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v3.2.0...v3.2.1)
|
27
39
|
- Fix bug when using `column_style` option with `include_header: true` & letter based column numbering
|
28
|
-
|
40
|
+
|
41
|
+
- **3.2.0** - September 14, 2018 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v3.1.0...v3.2.0)
|
29
42
|
- Change implementation of `:column_styles` option to utilize `axlsx_styler` instead of the built-in axlsx `col_style` method. The reason for the switch is that `col_style` would overwrite all previously set styles. `axlsx_styler` already has the ability to add onto existing styles and is what is currently utilized by `range_styles`.
|
30
43
|
- Date / Time formatting is now set per cell instead of on the entire column.
|
31
44
|
- Default Date formatting for `xlsx` changed from `m/d/yyyy` to `yyyy-mm-dd`
|
32
45
|
- Default Time/DateTime formatting for `xlsx` changed from `yyyy/m/d h:mm AM/PM` to `yyyy-mm-dd h:mm AM/PM`
|
33
46
|
- Fix bug where the ActionController::Renderer `:filename` option was ignored when an AR::Relation passed directly to the renderer without first calling `to_#{format}`
|
34
|
-
|
47
|
+
|
48
|
+
- **3.1.0** - August 19, 2018 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v3.0.0...v3.1.0)
|
35
49
|
- Add new option `:conditional_row_styles` to `to_xlsx`.
|
36
50
|
- Add ability to pass an alternative method name as a Symbol/String to the `:spreadsheet_columns` option.
|
37
51
|
- Replace all usage of the legacy method `instance_eval` with the proper method `send`.
|
38
52
|
- [#23](https://github.com/westonganger/spreadsheet_architect/issues/23#issuecomment-412803761) - Fix bug where custom `columns_widths` in xlsx spreadsheets might not get set correctly.
|
39
53
|
- All exceptions now inherit from the appropriate ruby core exception classes
|
40
54
|
- `SpreadsheetArchitect::Exceptions::InvalidOptionError` renamed to `SpreadsheetArchitect::Exceptions::OptionTypeError`
|
41
|
-
|
55
|
+
|
56
|
+
- **3.0.0** - July 6, 2018 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v2.1.2...v3.0.0)
|
42
57
|
- [#16](https://github.com/westonganger/spreadsheet_architect/issues/16) - Add ability to pass :instances option to SpreadsheetArchitect class methods
|
43
58
|
- [#16](https://github.com/westonganger/spreadsheet_architect/issues/16) - Remove Plain Ruby syntax `Post.to_xlsx(instances: posts_array)` in favor of `SpreadsheetArchitect.to_xlsx(instance: posts_array)`. However, it may still work at this time if configured correctly.
|
44
59
|
- Fix project-wide and model-level defaults before only `header_style`, `row_style`, & `sheet_name` were being utilized.
|
@@ -53,12 +68,15 @@ CHANGELOG
|
|
53
68
|
- Remove all Rails generators `spreadsheet_architect:add_default_options`. No need since its just as easy to copy from the README
|
54
69
|
- Major overhaul of test suite, add a ton more tests, for DRYness use resursion for tests when appropriate
|
55
70
|
- Use appraisal to test various `axlsx` versions
|
56
|
-
|
71
|
+
|
72
|
+
- **2.1.2** - July 6, 2018 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v2.1.1...v2.1.2)
|
57
73
|
- Fix bug where everything was underlined by default in Excel (LibreOffice was working correctly). For some reason, `false` in `:u` or `:underline` was incorrectly being treated as `true` but only within Excel. Now anytime `false` is encountered for either `:u` or `:underline` it is now converted to `nil`
|
58
74
|
- Fix bug where empty xlsx spreadsheets were corrupt when trying to open with Excel (LibreOffice was working correctly). This only occured when containing no headers and empty `:data` option which resulted in a package with no sheets.
|
59
|
-
|
75
|
+
|
76
|
+
- **2.1.1** - July 4, 2018 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v2.1.0...v2.1.1)
|
60
77
|
- [#18](https://github.com/westonganger/spreadsheet_architect/pull/18) - Fix controller bug when using an non-ActiveRecord ORM only within Rails
|
61
|
-
|
78
|
+
|
79
|
+
- **2.1.0** - June 20, 2018 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v2.0.2...v2.1.0)
|
62
80
|
- [#15](https://github.com/westonganger/spreadsheet_architect/pull/15) - Improved the method symbolize_keys. This method did not work properly for nested objects.
|
63
81
|
- [PR #15](https://github.com/westonganger/spreadsheet_architect/pull/15) - Added the ability to pass `:text_wrap` option within the `:alignment` style
|
64
82
|
- Make axlsx styles higher precendence over Spreadsheet Architect style aliases
|
@@ -66,14 +84,17 @@ CHANGELOG
|
|
66
84
|
- Due to [RODF bug](https://github.com/thiagoarrais/rodf/issues/19) convert all Date and Time cells to String in ODS spreadsheets
|
67
85
|
- Improve test suite
|
68
86
|
- Dont test against Ruby versions that Rails no longer supports. Gem code should remain compatible with Ruby 1.9.3.
|
69
|
-
|
87
|
+
|
88
|
+
- **2.0.2** - July 14 2017 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v2.0.1...v2.0.2)
|
70
89
|
- Fix bug with range styles rows option not counting headers
|
71
90
|
- Fix bug with range styles rows :all option
|
72
|
-
|
91
|
+
|
92
|
+
- **2.0.1** - February 16 2017 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v2.0.0...v2.0.1)
|
73
93
|
- Fix bug where `SpreadsheetArchitect.default_options` and `SPREADSHEET_OPTIONS` were being overwritten
|
74
94
|
- Fix bug where col_styles ignored previous styles on header when using `include_header` option
|
75
95
|
- Errors now try to provide which value is the cause
|
76
|
-
|
96
|
+
|
97
|
+
- **2.0.0** - January 28 2017 - [View Diff](https://github.com/westonganger/spreadsheet_architect/compare/v1.4.8...v2.0.0)
|
77
98
|
- Add to xlsx: `merges`, `column_styles`, `range_styles`, `borders`, `column_widths` multi-row headers, date/time default format_code
|
78
99
|
- Add `column_types` option for xlsx and ods
|
79
100
|
- Add ability to make multi-sheet spreadsheets in XLSX & ODS
|
@@ -81,52 +102,74 @@ CHANGELOG
|
|
81
102
|
- Add Examples
|
82
103
|
- Add Axlsx Style Reference
|
83
104
|
- Refractor into smaller files
|
105
|
+
|
84
106
|
- **1.4.8** - December 6 2016
|
85
107
|
- Lock `rodf` gem to v0.3.7 for last v1 version of this gem
|
108
|
+
|
86
109
|
- **1.4.7** - November 7 2016
|
87
110
|
- Fix method arguments for `to_rodf_spreadsheet` method
|
111
|
+
|
88
112
|
- **1.4.6** - May 16 2016
|
89
113
|
- Fix hash syntax for support of ruby v2.1 and below
|
114
|
+
|
90
115
|
- **1.4.5** - May 4 2016
|
91
116
|
- Bug fixes
|
117
|
+
|
92
118
|
- **1.4.4** - May 3 2016
|
93
119
|
- Add Ability to add format_code to all numbers body rows
|
120
|
+
|
94
121
|
- **1.4.3** - May 3 2016
|
95
122
|
- Bug fixes
|
123
|
+
|
96
124
|
- **1.4.2** - May 3 2016
|
97
125
|
- Add to_axlsx_package, to_rodf_spreadsheet methods for the item to be further manipulated. Ex. axlsx_styler
|
126
|
+
|
98
127
|
- **1.4.1** - May 2 2016
|
99
128
|
- Add rails generator for project defaults initializer
|
129
|
+
|
100
130
|
- **1.4.0** - April 29 2016
|
101
131
|
- Add to_xlsx, to_ods, & to_csv to SpreadsheetArchitect model for direct calling by passing in cell data
|
132
|
+
|
102
133
|
- **1.3.0** - April 21 2016
|
103
134
|
- Add ability to create class/model and project option defaults
|
135
|
+
|
104
136
|
- **1.2.5** - March 25 2016
|
105
137
|
- Fix each_with_index bug
|
138
|
+
|
106
139
|
- **1.2.4** - March 24 2016
|
107
140
|
- Fix cell type logic for symbol methods
|
141
|
+
|
108
142
|
- **1.2.3** - March 20 2016
|
109
143
|
- Fix cell type logic
|
144
|
+
|
110
145
|
- **1.2.2** - March 19 2016
|
111
146
|
- Make cell type numeric if value is numeric
|
147
|
+
|
112
148
|
- **1.2.1** - March 13 2016
|
113
149
|
- Better error reporting
|
114
150
|
- Fix for Plain ruby models
|
151
|
+
|
115
152
|
- **1.2.0** - March 10 2016
|
116
153
|
- Fix Bug: first row data repeated for all records on custom values
|
154
|
+
|
117
155
|
- **1.1.0** - March 3 2016
|
118
156
|
- Breaking Change - Move spreadsheet_columns method from the class to the instance
|
119
157
|
- Fix Bug: remove default underline on cells
|
158
|
+
|
120
159
|
- **1.0.4** - March 1 2016
|
121
160
|
- Extract helper methods to seperate module
|
122
161
|
- Improve readme
|
162
|
+
|
123
163
|
- **1.0.3** - March 1 2016
|
124
164
|
- Fix/Improve renderers
|
125
165
|
- Fix header default background color
|
126
166
|
- Fix default columns
|
167
|
+
|
127
168
|
- **1.0.2** - February 26 2016
|
128
169
|
- Enhance Style options
|
170
|
+
|
129
171
|
- **1.0.1** - February 26 2016
|
130
172
|
- Fix bug in renderers
|
173
|
+
|
131
174
|
- **1.0.0** - February 26 2016
|
132
175
|
- Gem Initial Release
|
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# Spreadsheet Architect
|
2
2
|
|
3
3
|
<a href="https://badge.fury.io/rb/spreadsheet_architect" target="_blank"><img height="21" style='border:0px;height:21px;' border='0' src="https://badge.fury.io/rb/spreadsheet_architect.svg" alt="Gem Version"></a>
|
4
|
-
<a href='https://
|
4
|
+
<a href='https://github.com/westonganger/spreadsheet_architect/actions' target='_blank'><img src="https://github.com/westonganger/spreadsheet_architect/workflows/Tests/badge.svg" style="max-width:100%;" height='21' style='border:0px;height:21px;' border='0' alt="CI Status"></a>
|
5
5
|
<a href='https://rubygems.org/gems/spreadsheet_architect' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://ruby-gem-downloads-badge.herokuapp.com/spreadsheet_architect?label=rubygems&type=total&total_label=downloads&color=brightgreen' border='0' alt='RubyGems Downloads' /></a>
|
6
|
-
<a href='https://ko-fi.com/A5071NK' target='_blank'><img height='22' style='border:0px;height:22px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=a' border='0' alt='Buy Me a Coffee' /></a>
|
7
6
|
|
8
7
|
Spreadsheet Architect is a library that allows you to create XLSX, ODS, or CSV spreadsheets super easily from ActiveRecord relations, plain Ruby objects, or tabular data.
|
9
8
|
|
@@ -190,7 +189,7 @@ File.open('path/to/multi_sheet_file.xlsx', 'w+b') do |f|
|
|
190
189
|
end
|
191
190
|
```
|
192
191
|
|
193
|
-
See this file for more details:
|
192
|
+
See this file for more details: [test/unit/multi_sheet_test.rb](./test/unit/multi_sheet_test.rb)
|
194
193
|
|
195
194
|
### ODS
|
196
195
|
```ruby
|
@@ -202,7 +201,7 @@ File.open('path/to/multi_sheet_file.ods', 'w+b') do |f|
|
|
202
201
|
end
|
203
202
|
```
|
204
203
|
|
205
|
-
See this file for more details:
|
204
|
+
See this file for more details: [test/unit/multi_sheet_test.rb](./test/unit/multi_sheet_test.rb)
|
206
205
|
|
207
206
|
# Methods
|
208
207
|
|
@@ -215,17 +214,18 @@ See this file for more details: https://github.com/westonganger/spreadsheet_arch
|
|
215
214
|
|**spreadsheet_columns**<br>*Proc/Symbol/String*| Use this option to override or define the spreadsheet columns. Normally, if this option is not specified and are using the instances option/ActiveRecord relation, it uses the classes custom `spreadsheet_columns` method or any custom defaults defined.<br>If neither of those and is an ActiveRecord model, then it will falls back to the models `self.column_names` | Cannot be used with the `:data` option.<br><br>If a Proc value is passed it will be evaluated on the instance object.<br><br>If a Symbol or String value is passed then it will search the instance for a method name that matches and call it. |
|
216
215
|
|**headers**<br>*Array / 2D Array*| |Data for the header row cells. If using on a class/relation, this defaults to the ones provided via `spreadsheet_columns`. Pass `false` to skip the header row. |
|
217
216
|
|**sheet_name**<br>*String*|`Sheet1`||
|
218
|
-
|**header_style**<br>*Hash*|`{background_color: "AAAAAA", color: "FFFFFF", align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false}`|See all available style options [here](
|
219
|
-
|**row_style**<br>*Hash*|`{background_color: nil, color: "000000", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false, format_code: nil}`|Styles for non-header rows. See all available style options [here](
|
220
|
-
|**column_styles**<br>*Array*||[See this example for usage](
|
221
|
-
|**range_styles**<br>*Array*||[See this example for usage](
|
222
|
-
|**conditional_row_styles**<br>*Array*||[See this example for usage](
|
223
|
-
|**merges**<br>*Array*||Merge cells. [See this example for usage](
|
224
|
-
|**borders**<br>*Array*||[See this example for usage](
|
217
|
+
|**header_style**<br>*Hash*|`{background_color: "AAAAAA", color: "FFFFFF", align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false}`|See all available style options [here](./docs/axlsx_style_reference.md)|
|
218
|
+
|**row_style**<br>*Hash*|`{background_color: nil, color: "000000", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false, format_code: nil}`|Styles for non-header rows. See all available style options [here](./docs/axlsx_style_reference.md)|
|
219
|
+
|**column_styles**<br>*Array*||[See this example for usage](./test/unit/kitchen_sink_test.rb)|
|
220
|
+
|**range_styles**<br>*Array*||[See this example for usage](./test/unit/kitchen_sink_test.rb)|
|
221
|
+
|**conditional_row_styles**<br>*Array*||[See this example for usage](./test/unit/kitchen_sink_test.rb). The if/unless proc will called with the following args: `row_index`, `row_data`|
|
222
|
+
|**merges**<br>*Array*||Merge cells. [See this example for usage](./test/unit/kitchen_sink_test.rb). Warning merges cannot overlap eachother, if you attempt to do so Excel will claim your spreadsheet is corrupt and refuse to open your spreadsheet.|
|
223
|
+
|**borders**<br>*Array*||[See this example for usage](./test/unit/kitchen_sink_test.rb)|
|
225
224
|
|**column_types**<br>*Array*||Valid types for XLSX are :string, :integer, :float, :date, :time, :boolean, nil = auto determine.|
|
226
225
|
|**column_widths**<br>*Array*||Sometimes you may want explicit column widths. Use nil if you want a column to autofit again.|
|
227
226
|
|**freeze_headers**<br>*Boolean*||Make all header rows frozen/fixed so they do not scroll.|
|
228
|
-
|**freeze**<br>*
|
227
|
+
|**freeze**<br>*Hash*|`{rows: (1..4), columns: :all}`|Make all specified rows and columns frozen/fixed so they do not scroll.|
|
228
|
+
|**skip_defaults**<br>*Boolean*|`false`|Removes defaults and default styles. Particularily useful for heavily customized spreadsheets where the default styles get in the way.|
|
229
229
|
|
230
230
|
## `to_axlsx_spreadsheet(options={}, axlsx_package_to_join=nil)`
|
231
231
|
Same options as `to_xlsx`
|
@@ -242,6 +242,7 @@ Same options as `to_xlsx`
|
|
242
242
|
|**header_style**<br>*Hash*|`{background_color: "AAAAAA", color: "FFFFFF", align: :center, font_size: 10, bold: true}`|Note: Currently ODS only supports these options|
|
243
243
|
|**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|
|
244
244
|
|**column_types**<br>*Array*||Valid types for ODS are :string, :float, :date, :time, :boolean, nil = auto determine. Due to [RODF Issue #19](https://github.com/thiagoarrais/rodf/issues/19), :date/:time will be converted to :string |
|
245
|
+
|**skip_defaults**<br>*Boolean*|`false`|Skip defaults and default styles. Particularily useful for heavily customized spreadsheets where the default styles get in the way.|
|
245
246
|
|
246
247
|
## `to_rodf_spreadsheet(options={}, spreadsheet_to_join=nil)`
|
247
248
|
Same options as `to_ods`
|
@@ -306,11 +307,11 @@ SpreadsheetArchitect.default_options = {
|
|
306
307
|
```
|
307
308
|
|
308
309
|
# Kitchen Sink Examples with Styling for XLSX and ODS
|
309
|
-
See this example:
|
310
|
+
See this example: [test/unit/kitchen_sink_test.rb](./test/unit/kitchen_sink_test.rb)
|
310
311
|
|
311
312
|
# Axlsx Style Reference
|
312
313
|
|
313
|
-
I have compiled a list of all available style options for axlsx here:
|
314
|
+
I have compiled a list of all available style options for axlsx here: [docs/axlsx_style_reference.md](./docs/axlsx_style_reference.md)
|
314
315
|
|
315
316
|
# Testing / Validating your Spreadsheets
|
316
317
|
|
@@ -112,24 +112,22 @@ module SpreadsheetArchitect
|
|
112
112
|
def self.get_options(options, klass)
|
113
113
|
verify_option_types(options)
|
114
114
|
|
115
|
-
if options[:
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
klass::SPREADSHEET_OPTIONS.merge(options)
|
123
|
-
)
|
115
|
+
if !options[:skip_defaults]
|
116
|
+
if defined?(klass::SPREADSHEET_OPTIONS)
|
117
|
+
if klass::SPREADSHEET_OPTIONS.is_a?(Hash)
|
118
|
+
defaults = SpreadsheetArchitect.default_options.merge(klass::SPREADSHEET_OPTIONS)
|
119
|
+
else
|
120
|
+
raise SpreadsheetArchitect::Exceptions::OptionTypeError.new("#{klass}::SPREADSHEET_OPTIONS constant")
|
121
|
+
end
|
124
122
|
else
|
125
|
-
|
123
|
+
defaults = SpreadsheetArchitect.default_options
|
126
124
|
end
|
127
|
-
|
128
|
-
options =
|
125
|
+
|
126
|
+
options = defaults.merge(options)
|
129
127
|
end
|
130
128
|
|
131
129
|
if !options[:headers]
|
132
|
-
options
|
130
|
+
options.delete(:header_style)
|
133
131
|
end
|
134
132
|
|
135
133
|
if !options[:sheet_name]
|
@@ -144,8 +142,12 @@ module SpreadsheetArchitect
|
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
147
|
-
if options[:freeze]
|
148
|
-
|
145
|
+
if options[:freeze]
|
146
|
+
if options[:freeze_headers]
|
147
|
+
raise SpreadsheetArchitect::Exceptions::ArgumentError.new('Cannot use both :freeze and :freeze_headers options at the same time')
|
148
|
+
elsif options[:freeze].is_a?(Hash) && !options[:freeze][:rows]
|
149
|
+
raise SpreadsheetArchitect::Exceptions::ArgumentError.new('Must provide a :rows key when passing a hash to the :freeze option')
|
150
|
+
end
|
149
151
|
end
|
150
152
|
|
151
153
|
return options
|
@@ -284,6 +286,7 @@ module SpreadsheetArchitect
|
|
284
286
|
instances: Array,
|
285
287
|
merges: Array,
|
286
288
|
range_styles: Array,
|
289
|
+
skip_defaults: [TrueClass, FalseClass],
|
287
290
|
row_style: Hash,
|
288
291
|
sheet_name: String,
|
289
292
|
spreadsheet_columns: [Proc, Symbol, String],
|
@@ -25,10 +25,30 @@ module SpreadsheetArchitect
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.convert_styles_to_axlsx(styles={})
|
28
|
-
|
28
|
+
if [nil, false, true].include?(styles)
|
29
|
+
return {}
|
30
|
+
end
|
29
31
|
|
30
32
|
styles = SpreadsheetArchitect::Utils.symbolize_keys(styles)
|
31
33
|
|
34
|
+
### BOOLEAN VALUES
|
35
|
+
if styles[:b].nil? && styles.has_key?(:bold)
|
36
|
+
styles[:b] = !!styles.delete(:bold)
|
37
|
+
end
|
38
|
+
|
39
|
+
if styles[:i].nil? && styles.has_key?(:italic)
|
40
|
+
styles[:i] = !!styles.delete(:italic)
|
41
|
+
end
|
42
|
+
|
43
|
+
if styles[:u].nil? && styles.has_key?(:underline)
|
44
|
+
styles[:u] = !!styles.delete(:underline)
|
45
|
+
end
|
46
|
+
|
47
|
+
### OTHER VALUES
|
48
|
+
if styles[:sz].nil? && !styles[:font_size].nil?
|
49
|
+
styles[:sz] = styles.delete(:font_size)
|
50
|
+
end
|
51
|
+
|
32
52
|
if styles[:fg_color].nil? && styles[:color] && styles[:color].respond_to?(:sub) && !styles[:color].empty?
|
33
53
|
styles[:fg_color] = styles.delete(:color).sub('#','')
|
34
54
|
end
|
@@ -37,7 +57,7 @@ module SpreadsheetArchitect
|
|
37
57
|
styles[:bg_color] = styles.delete(:background_color).sub('#','')
|
38
58
|
end
|
39
59
|
|
40
|
-
if styles[:alignment].nil? &&
|
60
|
+
if styles[:alignment].nil? && [:align, :valign, :wrap_text].any?{|k| styles.has_key?(k) }
|
41
61
|
if styles[:align].is_a?(Hash)
|
42
62
|
styles[:alignment] = {
|
43
63
|
horizontal: styles[:align][:horizontal],
|
@@ -45,34 +65,22 @@ module SpreadsheetArchitect
|
|
45
65
|
wrap_text: styles[:align][:wrap_text]
|
46
66
|
}
|
47
67
|
else
|
48
|
-
styles[:alignment] = {horizontal:
|
68
|
+
styles[:alignment] = {horizontal: styles.delete(:align), vertical: styles.delete(:valign), wrap_text: styles.delete(:wrap_text) }.compact
|
49
69
|
end
|
50
|
-
|
51
|
-
styles.delete(:align)
|
52
|
-
end
|
53
|
-
|
54
|
-
if styles[:b].nil?
|
55
|
-
styles[:b] = styles.delete(:bold) || nil
|
56
|
-
end
|
57
|
-
|
58
|
-
if styles[:sz].nil?
|
59
|
-
styles[:sz] = styles.delete(:font_size) || nil
|
60
|
-
end
|
61
|
-
|
62
|
-
if styles[:i].nil?
|
63
|
-
styles[:i] = styles.delete(:italic) || nil
|
64
|
-
end
|
65
|
-
|
66
|
-
if styles[:u].nil?
|
67
|
-
styles[:u] = styles.delete(:underline) || nil
|
68
70
|
end
|
69
71
|
|
72
|
+
### COMMENT SEEMS WRONG, TO BE RECONFIRMED
|
70
73
|
### If `:u` is false instead of nil, it may be incorrectly rendered as true in Excel
|
71
|
-
if styles[:u] == false
|
72
|
-
|
74
|
+
#if styles[:u] == false
|
75
|
+
# styles[:u] = nil
|
76
|
+
#end
|
77
|
+
|
78
|
+
### ENSURE CLEANUP OF ALL ALIAS KEYS
|
79
|
+
[:bold, :font_size, :italic, :underline, :align, :valign, :wrap_text, :color, :background_color].each do |k|
|
80
|
+
styles.delete(k)
|
73
81
|
end
|
74
82
|
|
75
|
-
styles
|
83
|
+
return styles
|
76
84
|
end
|
77
85
|
|
78
86
|
def self.range_hash_to_str(hash, num_columns, num_rows)
|
@@ -58,7 +58,7 @@ module Dummy
|
|
58
58
|
|
59
59
|
if ActiveRecord.respond_to?(:gem_version)
|
60
60
|
gem_version = ActiveRecord.gem_version
|
61
|
-
if gem_version.to_s.
|
61
|
+
if gem_version.to_s.start_with?("5.2.")
|
62
62
|
config.active_record.sqlite3.represent_boolean_as_integer = true
|
63
63
|
end
|
64
64
|
end
|
@@ -9,7 +9,7 @@ Dummy::Application.configure do
|
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
11
|
config.serve_static_files = true
|
12
|
-
config.public_file_server.
|
12
|
+
config.public_file_server.enabled = true
|
13
13
|
|
14
14
|
# Log error messages when you accidentally call methods on nil
|
15
15
|
config.whiny_nils = true
|