Hi,
Why isn't this working as expected?
require 'win32ole'
data1 = []
100.times { data1 << rand(100) }
excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Add
worksheet = workbook.Worksheets(1)
worksheet.Select # bring it to front
worksheet.Range('a1:c1')['Value'] = ['Test', '25', 'result']
worksheet.Range('a2:a4')['Value'] = ['Test', '25', 'result']
excel['Visible'] = true
This results in:
Test 25 result
Test
Test
Test
while I expected:
Test 25 result
Test
25
result
Any ideas?
//F
Pit
(Pit)
2
Fredrik Jagenheim schrieb:
...
worksheet.Range('a1:c1')['Value'] = ['Test', '25', 'result']
worksheet.Range('a2:a4')['Value'] = ['Test', '25', 'result']
This results in:
Test 25 result
Test
Hi Fredrik,
just a guess, but maybe you need to feed values for more than one row as an array of arrays: [['Test'], ['25'], ['result']]
If this doesn't work, you could try to fill the values one cell at a time and look at the format of the data when reading the values:
worksheet.Range('a2:a2')['Value'] = ['Test']
worksheet.Range('a3:a3')['Value'] = ['25']
worksheet.Range('a4:a4')['Value'] = ['result']
p worksheet.Range('a2:a4')['Value']
HTH
Regards,
Pit