« Return to Thread: Using ruby to open an Excel file on a mac

Re: Using ruby to open an Excel file on a mac

by Matt Neuburg-2 :: Rate this Message:

Reply to Author | View in Thread

Ryan Westerberg <phoenix_016@...> wrote:

> I have another question pertaining to individual tabs in the excel
> workbook itself.  I looked through the link on appscript that you sent
> and maybe I missed it and if I did my apologies.
>
> In windows I'm able to to do the following in order to get data from
> different worksheets within the excel workbook
>
> worksheet1= workbook.Worksheets('Testdata')
> worksheet2= workbook.Worksheets('Items')
>
> I have workbook defined as:
> workbook = MacTypes::Alisas.path(/insert path here/workbookname.xls)
>
> This should be the last question I have.  Thanks for again for the help

But this is what I mean about learning AppleScript / appscript. What you
are really asking, I think, is just "how do I refer to worksheets of a
workbook?" But Excel's scripting dictionary tells you that, clearly.
This is very basic stuff. The stuff I linked you to tells you how to
read the scripting dictionary, discover the worksheets element of a
workbook object, and use it within rb-appscript. For the scripting
dictionary, see chapter 8 of the online book:

http://www.apeth.com/rbappscript/08dictionary.html

If nothing else, you could just say (assuming you've installed
ASDictionary, ):

require 'appscript'
excel = Appscript.app("Microsoft Excel")
excel.workbooks.help

And chapter 5 of the online book tells you how to form the desired
reference:

http://www.apeth.com/rbappscript/05propel.html

Incidentally, Hamish Sanderson has just released a new version of
rb-appscript so be sure to update it (along with ASDictionary and
ASTranslate). I'll be updating the online book Real Soon Now to take
account of the changes. m.

 « Return to Thread: Using ruby to open an Excel file on a mac