[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Excel scripting

Fredrik Jagenheim

6/17/2005 7:46:00 AM

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


3 Answers

Pit Capitain

6/17/2005 8:57:00 AM

0

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
> Test
> 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


Fredrik Jagenheim

6/17/2005 9:26:00 AM

0

On 6/17/05, Pit Capitain <pit@capitain.de> wrote:
>
> just a guess, but maybe you need to feed values for more than one row as
> an array of arrays: [['Test'], ['25'], ['result']]

This did it, thanks.

//F


Bodie

10/20/2011 6:31:00 PM

0


<inchanga@telus.net> wrote in message
news:055c9a77-74a5-4331-a695-3ebafd1adc47@u24g2000pru.googlegroups.com...
On Oct 16, 1:32 pm, "Bodie" <bo...@home.net> wrote:
> "Etienne Marais" <etienne.mar...@gmail.com> wrote in message
>
> news:083ef7be-c331-4136-a680-a1b9a7a0a280@k29g2000yqf.googlegroups.com...
> More than R100 000 000 to be spent on monuments and museums honouring
> terrorists and communists.
> ===
>
> Absoluteluy fucking disgusting!!!
>
> The only fitting honour for these terrorist bastards is a hole in the
> ground.
>
> 'Nuff said!

But who would dig the hole old friend. Leave 'em for the hyenas.

Bodie old buddy I'm coming home for a visit at Christmas. If you're
there still email me & I'll buy you a beer. (or are you still in
Ireland?

Hey there me old friend, hope you are well.

Nope ... I am back in good old ZA .. family came back in 2010 after the
soccer world cup.

Bastard french cost Ireland their place in the tournament at the time.

If you down south pop me a mail ... I think I'll buy the beers ....

Nice to see somebody else familiar on the forum ..
Be Blessed.