I have following code:
@xl = WIN32OLE.new(‘Excel.Application’)
@xl[‘Visible’] = TRUE
@wb = @xl.Workbooks.Add
@ws = @xb.Worksheets(“XXXXX”)
@wb.Sheets.Add #this adds a new ‘generic’ worksheet to your workbook
(also note that you have a typo in the last line of the code above @xb
new_sheet = @wb.Worksheets(4)
new_sheet.Name = “XXXXX”
The problem is that last line throws exception: moethod_missing:
Why? I had read examples from net and did everything according to them.
If you poke around in irb you can get the OLE methods that you can use
via a method called “ole_methods”
Another question is how to create a chart in excel and:
add several series to it
assign names to axis
assign names to the series
set chart type.
If you’re really set on using ruby, I’d build a macro in XL to do what
you want and then work backwards from the macro-code to try and automate
this process via ruby.
Alternatively (and perhaps easier) is to simply build a workbook with an
embedded macro to build a chart of your choosing it in the first place
and use this as a starting point–you could even call the macro from
Or if the data will always be in the same cells, you can pre-build the
chart and simply use ruby (or whatever) to populate the relevant cells
and the chart will already be there!
There are many possibilities, but the best probably depends on the
specifics of what you’re trying to do.
Posted via http://www.ruby-forum.com/.
This email and any attached files are confidential and intended solely
for the intended recipient(s). If you are not the named recipient you
should not read, distribute, copy or alter this email. Any views or
opinions expressed in this email are those of the author and do not
represent those of the company. Warning: Although precautions have been
taken to make sure no viruses are present in this email, the company
cannot accept responsibility for any loss or damage that arise from the
use of this email or attachments.