Connecting Tech Pros Worldwide Help | Site Map

Embedding a chart in excel

  #1  
Old July 18th, 2005, 02:50 AM
Stephen Boulet
Guest
 
Posts: n/a
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

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

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

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

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]
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 embedded in VB app AGP answers 9 October 27th, 2008 04:05 PM
Change Datasource of embedded Excel Unbound Object Frame ghanley answers 0 November 13th, 2005 01:36 PM
Change Datasource of embedded Excel Unbound Object Frame ghanley answers 0 November 13th, 2005 01:36 PM
Getting to a Chart's Props? PeteCresswell answers 22 November 13th, 2005 10:58 AM