美文网首页
excel的简单操作

excel的简单操作

作者: 黑夜的眸 | 来源:发表于2016-08-28 22:27 被阅读0次

    ruby操作EXCEL的简单示例

    require 'win32ole'

    excel = WIN32OLE.new("excel.application")

    workbook = excel.Workbooks.Open('D:/test1.xls')

    worksheet = workbook.Worksheets("test1")

    worksheet.Select

    row = worksheet.usedrange.rows.count

    column = worksheet.usedrange.columns.count

    worksheet.usedrange.each{|cell|

    puts cell.value

    }

    for i in 1..row do

    for j in 1..column do

    puts worksheet.usedrange.cells(i,j).value

    end

    end

    workbook.close

    excel.Quit

    相关文章

      网友评论

          本文标题:excel的简单操作

          本文链接:https://www.haomeiwen.com/subject/tkcxettx.html