Embedding a chart in excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen Boulet

    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.A dd()

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

    xlChart.Locatio n Where:=xlLocati onAsObject, Name:=xlSheet.N ame

    Thanks.

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

    -- Stephen

  • srijit@yahoo.com

    #2
    Re: Embedding a chart in excel

    Hello,
    Refer the following link:


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

    Regards,
    Srijit

    Stephen Boulet <Stephen.Boulet @no.spam.motoro la.com> wrote in message news:<bi3gg3$8p k$1@newshost.mo t.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.A dd()
    >
    > Now how do I tell it to go embed itself in my sheet? In VBA, it might be
    > something like:
    >
    > xlChart.Locatio n Where:=xlLocati onAsObject, Name:=xlSheet.N ame
    >
    > Thanks.
    >
    > (Is there a newsgroup/list with more of a focus on issues like this than
    > c.l.py?)
    >
    > -- Stephen[/color]

    Comment

    • Stephen Boulet

      #3
      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.co m 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.motoro la.com> wrote in message news:<bi3gg3$8p k$1@newshost.mo t.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.Selec t()
      >>xlChart = xlBook.Charts.A dd()
      >>
      >>Now how do I tell it to go embed itself in my sheet? In VBA, it might be
      >>something like:
      >>
      >>xlChart.Locat ion Where:=xlLocati onAsObject, Name:=xlSheet.N ame
      >>
      >>Thanks.
      >>
      >>(Is there a newsgroup/list with more of a focus on issues like this than
      >>c.l.py?)
      >>
      >>-- Stephen[/color][/color]

      Comment

      • srijit@yahoo.com

        #4
        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.motoro la.com> wrote in message news:<bi5hm6$40 t$1@newshost.mo t.com>...[color=blue]
        > There seems to be a problem with UseExcel.setcel l:
        >[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_goo gle.py", line 139, in setcell
        > sht.Cells(row, col).Font.FontS ize = fontSize
        > File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py", line
        > 504, in __setattr__
        > raise AttributeError, "Property '%s.%s' can not be set." %
        > (self._username _, attr)
        > AttributeError: Property '<unknown>.Font Size' can not be set.
        >[/color]

        Comment

        • srijit@yahoo.com

          #5
          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.motoro la.com> wrote in message news:<bi5hm6$40 t$1@newshost.mo t.com>...[color=blue]
          > There seems to be a problem with UseExcel.setcel l:
          >[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_goo gle.py", line 139, in setcell
          > sht.Cells(row, col).Font.FontS ize = fontSize
          > File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py", line
          > 504, in __setattr__
          > raise AttributeError, "Property '%s.%s' can not be set." %
          > (self._username _, attr)
          > AttributeError: Property '<unknown>.Font Size' can not be set.
          >[/color]

          Comment

          Working...