Created
December 29, 2021 15:26
-
-
Save KakoozaJerry/ec90d77b892d61ee3404da469d275f08 to your computer and use it in GitHub Desktop.
to run do >>>>>> rake excel:export
This file contains 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
namespace :excel do | |
desc "This task will export posts to excel sheet" | |
task export: :environment do | |
book = Spreadsheet::Workbook.new | |
sheet = book.create_worksheet :name => 'Jobs' | |
posts = Job.all | |
posts.each_with_index do |post, i| | |
sheet.row(i).push post.id, post.title, post.location, post.description | |
end | |
book.write 'Jobs.xls' | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment