to_spreadsheet 1.0.6 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 59db3fcd754f0a95dd09f3fe7ffae57462a002745b6993a9fc3baa84014378ed
|
4
|
+
data.tar.gz: 831e9e4a81117cb1904bf503a05d1e3bb24ed817f90de0f031d05cb292308143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efe03b92346c0fb021f2d5c4780966bb5267b448e0c209a48a14631af6b8031970d8e09f01c3b5594e72ead6aa89bae257e577ea9f9733bcba059795cbc96b37
|
7
|
+
data.tar.gz: '09271ae875d3d5e3ccddf69a5144afabdbf16e481b05633d4dfeb7aec2132fcea2024b233c65971a870c4d0fdc18ddea0bd4c3053c7d4eef10e178a5ec3d87b1'
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ In the controller:
|
|
17
17
|
```ruby
|
18
18
|
# my_thingies_controller.rb
|
19
19
|
class MyThingiesController < ApplicationController
|
20
|
-
respond_to :
|
20
|
+
respond_to :xlsx, :html
|
21
21
|
def index
|
22
22
|
@my_items = MyItem.all
|
23
23
|
respond_to do |format|
|
@@ -49,7 +49,7 @@ In the view partial:
|
|
49
49
|
|
50
50
|
In the XLSX view:
|
51
51
|
```haml
|
52
|
-
# index.
|
52
|
+
# index.xlsx.haml
|
53
53
|
= render 'my_items', my_items: @my_items
|
54
54
|
```
|
55
55
|
|
@@ -74,7 +74,7 @@ format_xls 'table.my-table' do
|
|
74
74
|
workbook use_autowidth: true
|
75
75
|
sheet orientation: landscape
|
76
76
|
format 'th', b: true # bold
|
77
|
-
format 'tbody tr', bg_color: lambda { |row| 'ddffdd' if row.
|
77
|
+
format 'tbody tr', bg_color: lambda { |row| 'ddffdd' if row.row_index.odd? }
|
78
78
|
format 'A3:B10', i: true # italic
|
79
79
|
format column: 0, width: 35
|
80
80
|
format 'td.custom', lambda { |cell| modify cell somehow.}
|
@@ -112,7 +112,7 @@ end
|
|
112
112
|
You can define themes, i.e. blocks of formatting code:
|
113
113
|
```ruby
|
114
114
|
ToSpreadsheet.theme :zebra do
|
115
|
-
format 'tr', bg_color: lambda { |row| 'ddffdd' if row.
|
115
|
+
format 'tr', bg_color: lambda { |row| 'ddffdd' if row.row_index.odd? }
|
116
116
|
end
|
117
117
|
```
|
118
118
|
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
ActionController::Renderers.add ToSpreadsheet.renderer do |template, options|
|
18
18
|
filename = options[:filename] || options[:template] || 'data'
|
19
19
|
data = ToSpreadsheet::Context.with_context ToSpreadsheet::Context.global.merge(ToSpreadsheet::Context.new) do |context|
|
20
|
-
html = render_to_string(template, options.merge(template: template.to_s, formats: [
|
20
|
+
html = render_to_string(template, options.merge(template: template.to_s, formats: [:xlsx, :html]))
|
21
21
|
ToSpreadsheet::Renderer.to_data(html, context)
|
22
22
|
end
|
23
23
|
send_data data, type: ToSpreadsheet.renderer, disposition: %(attachment; filename="#{filename}.xlsx")
|
@@ -8,7 +8,7 @@ module ToSpreadsheet
|
|
8
8
|
wb = sheet.workbook
|
9
9
|
case selector_type
|
10
10
|
when :css
|
11
|
-
css_match selector_query, context.to_xml_node(sheet) do |xml_node|
|
11
|
+
css_match selector_query, context.to_xml_node(sheet) do |xml_node|
|
12
12
|
add_and_apply_style wb, context, context.to_xls_entity(xml_node)
|
13
13
|
end
|
14
14
|
when :row
|
@@ -18,7 +18,7 @@ module ToSpreadsheet
|
|
18
18
|
sheet.col_style selector_query, inline_styles if inline_styles.present?
|
19
19
|
apply_col_info sheet.column_info[selector_query]
|
20
20
|
when :range
|
21
|
-
add_and_apply_style wb, range_match(
|
21
|
+
add_and_apply_style wb, range_match(selector_query, sheet), context
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/spec/format_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe ToSpreadsheet::Rule::Format do
|
|
6
6
|
:ruby
|
7
7
|
format_xls do
|
8
8
|
format column: 0, width: 25
|
9
|
-
format 'tr', fg_color: lambda { |row| 'cccccc' if row.
|
9
|
+
format 'tr', fg_color: lambda { |row| 'cccccc' if row.row_index.odd? }
|
10
10
|
format 'table' do |ws|
|
11
11
|
ws.name = 'Test'
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_spreadsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Mazovetskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: caxlsx
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -174,14 +174,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
|
178
|
-
rubygems_version: 2.4.8
|
177
|
+
rubygems_version: 3.1.2
|
179
178
|
signing_key:
|
180
179
|
specification_version: 4
|
181
180
|
summary: Render existing views as Excel documents with style!
|
182
181
|
test_files:
|
183
|
-
- spec/format_spec.rb
|
184
|
-
- spec/rails_integration_spec.rb
|
185
|
-
- spec/types_spec.rb
|
186
182
|
- spec/defaults_spec.rb
|
183
|
+
- spec/rails_integration_spec.rb
|
187
184
|
- spec/worksheets_spec.rb
|
185
|
+
- spec/format_spec.rb
|
186
|
+
- spec/types_spec.rb
|