Created
March 7, 2016 20:06
-
-
Save zhangxu/9e1e64a6e2d6f0c35c41 to your computer and use it in GitHub Desktop.
Generate Xls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@sheets = [ | |
{ | |
:name => "s 1", | |
:headers => ["h11", "h12"], | |
:rows => [["s1r1c1", "s1r1c2"], ["s1r2c1", "s1r2c2"]] | |
}, | |
{ | |
:name => "s2", | |
:headers => ["h21", "h22"], | |
:rows => [["s2r1c1", "s2r1c2"], ["s2r2c1", "s2r2c2"]] | |
} | |
] | |
t = ERB.new File.new("#{Rails.root}/app/views/cals/index.xls.erb").read | |
File.open('/workspace/data/output.xls', 'w') { |file| file.write(t.result(binding())) } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment