473,662 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 18 '05 #1
4 7845
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 <St************ @no.spam.motoro la.com> wrote in message news:<bi******* ***@newshost.mo t.com>...
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

Jul 18 '05 #2
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

sr****@yahoo.co m wrote:
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 <St************ @no.spam.motoro la.com> wrote in message news:<bi******* ***@newshost.mo t.com>...
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


Jul 18 '05 #3
Hello,
Can you send me the code? In the mean time I shall check setcell.

Regards,
Srijit

Stephen Boulet <St************ @no.spam.motoro la.com> wrote in message news:<bi******* ***@newshost.mo t.com>...
There seems to be a problem with UseExcel.setcel l:
>>> a.setcell(sht1. Name,1,(1,1))

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.

Jul 18 '05 #4
Hello,
Can you send me the code? In the mean time I shall check setcell.

Regards,
Srijit

Stephen Boulet <St************ @no.spam.motoro la.com> wrote in message news:<bi******* ***@newshost.mo t.com>...
There seems to be a problem with UseExcel.setcel l:
>>> a.setcell(sht1. Name,1,(1,1))

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.

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
6775
by: PeteCresswell | last post by:
I've been to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mschrt/html/vbobjtitleobject.asp, but still don't have a clue. For example, I've got a chart object namde 'grphStats' in a form named frmChart. ?Forms!frmChart!grphStats.Name returns "grphStats" as expected, but I can't get any further.
8
3851
by: deko | last post by:
When using automation (and especially with early binding) I've heard it is best to use explicit references to everything. For example: Dim xlChart as Excel.Chart rather than Dim objChart as Object
0
3171
by: Zero | last post by:
A B C D E Date Open High Low Close Chart = (Excel._Chart)oWB.Charts.Add(missing,missing,missing,missing); Chart.HasLegend = false; Chart.ChartWizard( DMISheet.get_Range("A1", "E201" ), Excel.XlChartType.xlStockOHLC, Missing.Value, Excel.XlRowCol.xlColumns, Missing.Value,
1
7627
by: Robin Tucker | last post by:
Heres and interesting problem: I have a VB.NET program that creates reports via. Word Automation. This all works fine. What I want to do as part of this report generation process is to embed a graph/chart within the report, once again from VB.NET. I have chosen to use Excel.Chart.8. So, to embed I do this from VB.NET: Dim theNewShape As InlineShape = m_Document.InlineShapes.AddOLEObject (ClassType:="Excel.Chart", _
1
5846
by: Jaime Lucci | last post by:
Hi everyone! I need to show an excel chart in my application. I can open an excel file and make the chart, but I want to show the chart inside my form insted of the excel GUI. I use the PrintPreview command, but it open another window for the excel application with the chart. Can I do that, to place an Excel Chart into the from? I mean, can I use any object that let me do that?
0
3648
by: c0dergirl | last post by:
This c# program allows you to select multiple items from a listbox. For each selected item, a worksheet is created in the workbook with some information. Right now I create a chart that plots some information from one of the sheets. What I want to do is have a line on the graph for every sheet. I assume I use multiple datasources to do this, but I don't know how to use the SeriesCollection class to accomplish this. Here's my code....
1
1631
by: =?Utf-8?B?U00=?= | last post by:
Hi, We have developed an application that transforms xsl into excel file and present xsl file to the user with data. We use open xml features of excel 2003. Our user is now asking for a chart to be part of transformed xl file. We tried to save the chart properties in the xsl and it is not saving the xsl with chart properties ( chart we are trying is simple pie chart) Appreciate if any one has a solution or idea for this to happen.
0
2516
by: madhatter84gn | last post by:
I am trying to automate an excel spreadsheet and then create a chart. Dim chartRange As Excel.Range If rollup Then chartRange = sheet.Range("O2:Q14", Type.Missing) chartRange.Select() Else chartRange = sheet.Range("N:N,M:M,A:A", Type.Missing) chartRange.Select() End If
0
1021
by: j2flk1234 | last post by:
Hi, I am trying to graph in VB6 but am having lots of difficulty using MSChart. I switched my strategy to try and use the excel graphing method from VB. I have an excel worksheet with 2 rows, one for the X axis and one for the Y axis as follows: A B 1 6 2 7 3 8 4 9 5 10
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.