微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby 操作excel Spreadsheet

#encoding:utf-8
require "spreadsheet/excel"
Spreadsheet.client_encoding="utf-8"
book=Spreadsheet::Workbook.new
sheet1=book.create_worksheet :name => "test1"
sheet1.row(0)[0]="姓名"
sheet1.row(0)[1]="爱好"
sheet1.row(0)[2]="国家"
5.times do |i|
    sheet1.row(i+1)[0]="张山#{i}"
    sheet1.row(i+1)[1]="爱好#{i}"
    sheet1.row(i+1)[2]="国家#{i}"
end
#在指定路径下面创建test1.xls表格,并写book对象
book.write "test1.xls"

  

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐