Rodrigo Bermejo wrote: > Pranjal Jain wrote: >> Hi I am new to Ruby. >> >> can any one suggest me how we can write the data into the Excel Sheet >> from the array. >> >> >> Can we use the command like this >> >> $worksheet.Range("b1:b12").Insert = a[k] >> >> Can I insert in excel sheet via the Insert command or some other command >> is used?? >> >> Thanks in advance. > > check this out: > http://rubyonwindows.blogspot.com/ > > $worksheet.Range("b1:b12").value=a[k] > > -r. Hi I tried the method told by you , but sorry to say it is writing only the last value in the excel sheet. The code is as follows : require 'watir' require 'test/unit' include Watir class ExcelTest $excel = WIN32OLE.new('excel.Application') $path = File.join('D:','Ruby','array.xls') $workbook = $excel.WorkBooks.Open($path) $worksheet = $workbook.WorkSheets("One") $worksheet.Select a = Array.new a = ["3118","2102","1789","1301","1302","1303","1304","1245","1230","121","4293","122","209","1235","1247","2104",] i = 0 until i > 15 puts a[i] $worksheet.Range("a1:a16").value = a[i] i += 1 end end The output coming is as follows: 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 2104 Thanks in advance. -- Posted via http://www.ruby-forum.com/.