Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 18th, 2005, 02:50 AM
Stephen Boulet
Guest
 
Posts: n/a
Default Embedding a chart in excel

I'm having trouble scripting Excel to embed a chart from python.

Say I have created a sheet object and a workbook object, "xlSheet" and
"xlBook".

Creating a chart in front of my sheet is as easy as:

xlSheet.Select()
xlChart = xlBook.Charts.Add()

Now how do I tell it to go embed itself in my sheet? In VBA, it might be
something like:

xlChart.Location Where:=xlLocationAsObject, Name:=xlSheet.Name

Thanks.

(Is there a newsgroup/list with more of a focus on issues like this than
c.l.py?)

-- Stephen

  #2  
Old July 18th, 2005, 02:52 AM
srijit@yahoo.com
Guest
 
Posts: n/a
Default Re: Embedding a chart in excel

Hello,
Refer the following link:
http://groups.google.com/groups?hl=e...gle.com#link11

Does it help you? If it doesn't, let me know what improvements are
required.

Regards,
Srijit

Stephen Boulet <Stephen.Boulet@no.spam.motorola.com> wrote in message news:<bi3gg3$8pk$1@newshost.mot.com>...[color=blue]
> I'm having trouble scripting Excel to embed a chart from python.
>
> Say I have created a sheet object and a workbook object, "xlSheet" and
> "xlBook".
>
> Creating a chart in front of my sheet is as easy as:
>
> xlSheet.Select()
> xlChart = xlBook.Charts.Add()
>
> Now how do I tell it to go embed itself in my sheet? In VBA, it might be
> something like:
>
> xlChart.Location Where:=xlLocationAsObject, Name:=xlSheet.Name
>
> Thanks.
>
> (Is there a newsgroup/list with more of a focus on issues like this than
> c.l.py?)
>
> -- Stephen[/color]
  #3  
Old July 18th, 2005, 02:53 AM
Stephen Boulet
Guest
 
Posts: n/a
Default Re: Embedding a chart in excel

Very nice. I was working on my own excel classes, but I see this does lots.

Im my example, I can see from the code that arguments to the Add method
aren't optional. Thanks.

Maybe this should be in the python cookbook?

-- Stephen

srijit@yahoo.com wrote:[color=blue]
> Hello,
> Refer the following link:
> http://groups.google.com/groups?hl=e...gle.com#link11
>
> Does it help you? If it doesn't, let me know what improvements are
> required.
>
> Regards,
> Srijit
>
> Stephen Boulet <Stephen.Boulet@no.spam.motorola.com> wrote in message news:<bi3gg3$8pk$1@newshost.mot.com>...
>[color=green]
>>I'm having trouble scripting Excel to embed a chart from python.
>>
>>Say I have created a sheet object and a workbook object, "xlSheet" and
>>"xlBook".
>>
>>Creating a chart in front of my sheet is as easy as:
>>
>>xlSheet.Select()
>>xlChart = xlBook.Charts.Add()
>>
>>Now how do I tell it to go embed itself in my sheet? In VBA, it might be
>>something like:
>>
>>xlChart.Location Where:=xlLocationAsObject, Name:=xlSheet.Name
>>
>>Thanks.
>>
>>(Is there a newsgroup/list with more of a focus on issues like this than
>>c.l.py?)
>>
>>-- Stephen[/color][/color]

  #4  
Old July 18th, 2005, 02:55 AM
srijit@yahoo.com
Guest
 
Posts: n/a
Default Re: Embedding a chart in excel

Hello,
Can you send me the code? In the mean time I shall check setcell.

Regards,
Srijit

Stephen Boulet <Stephen.Boulet@no.spam.motorola.com> wrote in message news:<bi5hm6$40t$1@newshost.mot.com>...[color=blue]
> There seems to be a problem with UseExcel.setcell:
>[color=green][color=darkred]
> >>> a.setcell(sht1.Name,1,(1,1))[/color][/color]
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "excel_from_google.py", line 139, in setcell
> sht.Cells(row, col).Font.FontSize = fontSize
> File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line
> 504, in __setattr__
> raise AttributeError, "Property '%s.%s' can not be set." %
> (self._username_, attr)
> AttributeError: Property '<unknown>.FontSize' can not be set.
>[/color]
  #5  
Old July 18th, 2005, 02:55 AM
srijit@yahoo.com
Guest
 
Posts: n/a
Default Re: Embedding a chart in excel

Hello,
Can you send me the code? In the mean time I shall check setcell.

Regards,
Srijit

Stephen Boulet <Stephen.Boulet@no.spam.motorola.com> wrote in message news:<bi5hm6$40t$1@newshost.mot.com>...[color=blue]
> There seems to be a problem with UseExcel.setcell:
>[color=green][color=darkred]
> >>> a.setcell(sht1.Name,1,(1,1))[/color][/color]
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "excel_from_google.py", line 139, in setcell
> sht.Cells(row, col).Font.FontSize = fontSize
> File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line
> 504, in __setattr__
> raise AttributeError, "Property '%s.%s' can not be set." %
> (self._username_, attr)
> AttributeError: Property '<unknown>.FontSize' can not be set.
>[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.