README.md in spreadsheet_architect-1.2.6 vs README.md in spreadsheet_architect-1.3.0
- old
+ new
@@ -129,11 +129,10 @@
File.open('path/to/file.xlsx') do |f|
f.write{ Post.to_xlsx(data: posts_array) }
end
```
-
# Method Options
### to_xlsx, to_ods, to_csv
**data** - *Array* - Mainly for Plain Ruby objects pass in an array of instances. Optional for ActiveRecord relations, you can just chain the method to the end of your relation. If Plain Ruby object it defaults to the instances `to_a` method.
@@ -149,15 +148,48 @@
**row_style** - Hash - Default: `{background_color: nil, color: "FFFFFF", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false}`
### to_ods
**sheet_name** - *String*
-**header_style** - *Hash* - Default: {color: "000000", align: :center, font_size: 10, bold: true} - Note: Currently only supports these options
+**header_style** - *Hash* - Default: `{color: "000000", align: :center, font_size: 10, bold: true}` - Note: Currently only supports these options
-**row_style** - *Hash* - Default: {color: "000000", align: :left, font_size: 10, bold: false} - Note: Currently only supports these options
+**row_style** - *Hash* - Default: `{color: "000000", align: :left, font_size: 10, bold: false}` - Note: Currently only supports these options
### to_csv
Only the generic options
+
+
+# Change model default method options
+```ruby
+class Post
+ include SpreadsheetArchitect
+
+ def spreadsheet_columns
+ [:name, :content]
+ end
+
+ SPREADSHEET_OPTIONS = {
+ headers: true,
+ header_style: {background_color: "AAAAAA", color: "FFFFFF", align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
+ row_style: {background_color: nil, color: "FFFFFF", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
+ sheet_name: self.name
+ }
+end
+```
+
+# Change project wide default method options
+```ruby
+# config/initializers/spreadsheet_architect.rb
+
+SpreadsheetArchitect.module_eval do
+ set_const('SPREADSHEET_OPTIONS, {
+ headers: true,
+ header_style: {background_color: "AAAAAA", color: "FFFFFF", align: :center, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
+ row_style: {background_color: nil, color: "FFFFFF", align: :left, font_name: 'Arial', font_size: 10, bold: false, italic: false, underline: false},
+ sheet_name: 'My Project Export'
+ })
+end
+```
# Credits
Created by Weston Ganger - @westonganger