From 4d16bfc43780e5d3f7368625700b583e3e98217a Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 27 Nov 2011 18:11:42 +0900 Subject: adding in row_style and col_style methods to worksheet and active record 'acts_as_axlsx' to provide to_xlsx. --- doc/Axlsx/Ar/SingletonMethods.html | 199 +++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 doc/Axlsx/Ar/SingletonMethods.html (limited to 'doc/Axlsx/Ar/SingletonMethods.html') diff --git a/doc/Axlsx/Ar/SingletonMethods.html b/doc/Axlsx/Ar/SingletonMethods.html new file mode 100644 index 00000000..9781895c --- /dev/null +++ b/doc/Axlsx/Ar/SingletonMethods.html @@ -0,0 +1,199 @@ + + + + + + Module: Axlsx::Ar::SingletonMethods + + — AXLSX + + + + + + + + + + + + + + + + + + + + + + +

Module: Axlsx::Ar::SingletonMethods + + + +

+ +
+ + + + + + + + +
Defined in:
+
lib/axlsx/ar.rb
+ +
+
+ + + + + + + +

+ Instance Method Summary + (collapse) +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + - (Object) to_xlsx(number = :all, options = {}) + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+
+
# File 'lib/axlsx/ar.rb', line 22
+
+def to_xlsx(number = :all, options = {})
+  row_style = options.delete(:style)
+  header_style = options.delete(:header_style) || row_style
+  types = options.delete(:types)
+
+  data = [*find(number, options)]
+  data.compact!
+  data.flatten!
+  columns = data.first.attributes.keys
+  p = Package.new
+  row_style = p.workbook.styles.add_style(row_style) unless row_style.nil?
+  header_style = p.workbook.styles.add_style(header_style) unless header_style.nil?
+  
+  p.workbook.add_worksheet(:name=>table_name.humanize) do |sheet|
+    sheet.add_row columns, :style=>header_style
+    data.each do |r|
+      sheet.add_row r.attributes.values, :style=>row_style, :types=>types
+    end
+  end
+  p
+end
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file -- cgit v1.2.3