473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Excel Chart - Scatter Lines

48
Hi,

Can anyone please help me in figuring out what change needs to be done to the below code in order to show the chart (the chart I want is displayed only when I click the "Switch Row/Column" button on the toolbar, I want it to be displayed automatically without manually clicking the button - please see the attached file). Below is my code:


Expand|Select|Wrap|Line Numbers
  1.  Private Sub DisplayGraph()
  2.         Try
  3.             Dim xlApp As Excel.Application
  4.             Dim xlWorkBook As Excel.Workbook
  5.             Dim xlWorkSheet As Excel.Worksheet
  6.             Dim misValue As Object = System.Reflection.Missing.Value
  7.  
  8.             xlApp = New Excel.ApplicationClass
  9.             xlWorkBook = xlApp.Workbooks.Add(misValue)
  10.             xlWorkSheet = xlWorkBook.Sheets("sheet1")
  11.             xlApp.Visible = True
  12.  
  13.             'Adding Data..
  14.             xlWorkSheet.Cells(1, 1) = 2
  15.             xlWorkSheet.Cells(1, 2) = 1
  16.             xlWorkSheet.Cells(2, 1) = 3
  17.             xlWorkSheet.Cells(2, 2) = 2
  18.             xlWorkSheet.Cells(3, 1) = 2
  19.             xlWorkSheet.Cells(3, 2) = 5
  20.             xlWorkSheet.Cells(4, 1) = 4
  21.             xlWorkSheet.Cells(4, 2) = 7
  22.             xlWorkSheet.Cells(5, 1) = 8
  23.             xlWorkSheet.Cells(5, 2) = 2
  24.             xlWorkSheet.Cells(6, 1) = 5
  25.             xlWorkSheet.Cells(6, 2) = 3
  26.  
  27.             Dim oChart As Excel._Chart
  28.             oChart = xlWorkBook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value)
  29.  
  30.             oChart.ChartWizard(xlWorkSheet.Range("A1", "B6"), Excel.XlChartType.xlXYScatterLines, Missing.Value, _
  31.                                 Excel.XlRowCol.xlRows, _
  32.                                 Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, _
  33.                                 Missing.Value, Missing.Value)
  34.         Catch ex As Exception
  35.             MessageBox.Show(ex.Message)
  36.         End Try
  37.  
  38.     End Sub
  39.  
Any help is highly appreciated.

Regards,
Aads
Attached Images
File Type: jpg Graph.jpg (11.9 KB, 115 views)
Dec 8 '09 #1
0 1261

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
0
by: mscir | last post by:
Date: Thu, 08 Jul 2004 17:02:27 -0700 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <10ero4l3kp2qa65@corp.supernews.com> Reply-To: mscir@usa.com User-Agent: Mozilla/5.0...
2
by: cfriedalek | last post by:
I'm driving Excel from python, largely successfully. Now I'm trying to add errorbars to XY scatter plots. Keep getting a com_error. Can't track down the problem. I modified a simple example to...
5
by: Takeadoe | last post by:
I'm doubtful that the group is unbiased, but I will ask anyhow :o). If one intends to plot lots of data, primarily XY line and scatter plots, and mass produce them (in many cases I will be doing...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
5
by: grant | last post by:
I'm trying to use a scatter chart to plot level reading for a pump station level sensor. The sensor takes a reading every 4 seconds, and there are 23,000 reading per chart There appears to be...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
9
by: AGP | last post by:
I have a VB6 application that has an OLE container with an embedded Excel chart. Our office updated to Excel 2007 and now although the app works the charts looks like crap. Since the app is fairly...
2
by: DaveD170 | last post by:
Hi everybody, I'm newbie in c# and I'm having trouble in creating an excel chart. I have vector of data that my program calculated. It's in the next format: X Y 0.1 100 0.2 90...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.