Hi all,
I am trying to plot a graph in excel file using C#.Net.
I am using the name space excel .
If my graph has one series(2 columns), i am able to draw the graph.
if my graph has two series(4 columns), i am unable to draw the correct graph.
In this case i need graph with 2 series, one with first and second column
and the second one with third and fourth columns. But i am getting 3 curves,
one is for first and second column
second is for first and third column
third is for first and fourth column, which i dont want.
please clarify my problem if you hav answers.
Thanks in advance
Bye
5 20058
Welcome to the site. Please post your relevant code. Do receive any errors?
xla = new Excel.Applicati on();
xla.Visible = true;
Workbook wb = xla.Workbooks.A dd(XlSheetType. xlWorksheet);
Worksheet ws = (Worksheet)xla. ActiveSheet;
ChartObjects chartObjs = (ChartObjects)w s.ChartObjects( Type.Missing);
ChartObject chartObj = chartObjs.Add(1 00, 20, 300, 300);
Chart xlChart = chartObj.Chart;
int[,] v1 ={ { 1, 2 ,5, 10}, { 2, 4,10, 20 }, { 3, 6 ,15,30} };
Range rg;
rg = ws.get_Range("A 2", "D4");
rg.Value2 = v1;
xlChart.ChartTy pe = XlChartType.xlX YScatterSmoothN oMarkers;
xlChart.SetSour ceData(rg, Type.Missing);
in place of int[,] v1 ={ { 1, 2 ,5, 10}, { 2, 4,10, 20 }, { 3, 6 ,15,30} };(of my previous post), if i give int[,] v1 ={ { 1, 2 }, { 2, 4 }, { 3, 6} };, i am able to get
the curve. If i give int[,] v1 ={ { 1, 2 ,5, 10}, { 2, 4,10, 20 }, { 3, 6 ,15,30} };
i am getting 3 curves for the points
first curve (1,2),(2,4),(3, 6)
second curve (1,5),(2,10),(3 ,15)
Third curve (1,10),(2,20),( 3,30)
which i dont require.
What i require is
two curves
first one (1,2),(2,4),(3, 6)
second curve (5,10),(10,20), (15,30)
xla = new Excel.Applicati on();
xla.Visible = true;
Workbook wb = xla.Workbooks.A dd(XlSheetType. xlWorksheet);
Worksheet ws = (Worksheet)xla. ActiveSheet;
ChartObjects chartObjs = (ChartObjects)w s.ChartObjects( Type.Missing);
ChartObject chartObj = chartObjs.Add(1 00, 20, 300, 300);
Chart xlChart = chartObj.Chart;
int[,] v1 ={ { 1, 2 ,5, 10}, { 2, 4,10, 20 }, { 3, 6 ,15,30} };
Range rg;
rg = ws.get_Range("A 2", "D4");
rg.Value2 = v1;
xlChart.ChartTy pe = XlChartType.xlX YScatterSmoothN oMarkers;
xlChart.SetSour ceData(rg, Type.Missing);
Hi,
I am doing same but i am not able to understand how to draw a chart in side the excel. I am looking your code. What's taht xlChart ? and what is this ChartObject? do i need any assambly for that?
Thanks,
Naish
Ok so this is what you should do:
1.create a seriescollectio n cause you have several series (plots/lines) in one excel chart
2.create the seperate series
3. assign the values for each series. -
Excel.SeriesCollection seriesCollection;
-
Excel.Series series1, series2;
-
-
//this create the seriescollection and series
-
seriesCollection = xlChart.SeriesCollection(misValue)
-
series1 = seriesCollection.NewSeries();
-
series2 = seriesCollection.NewSeries();
-
-
//this gives each series the values. values are y values, xvalues are x values
-
series1.Values = ws.get_Range("A1", "A4") //assuming y values are in column //A, change range according to which column your values are
-
series2.XValues = ws.get_Range("B1", "B4") //if x values are in column B
-
-
//repeat for series2
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: george_y |
last post by:
I need some help to generate with a C++ programm a file in Excel format
(or at least in a way that all the information in it can be read by
Excel) containing a graph with the data I choose. As an example I
include a simple script that generates an output file with two columns
of integers and I` d like to add in it a graph in the same file so that
when you open the output file aaa.xls with Excel both the numrical data
and graph are...
|
by: KevinGPO |
last post by:
I am making a monitor program for the PC. My monitor program will grab
statistics about CPU and memory every 1 or 5 seconds. Then I want to
store this data so I have a history and hence be able to graph this out
in my GUI.
I thought about using a plain text file to store my graph data and plot
it out. Plot it out manually or use gnuplot.
I found this tool called RRDTool
(http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/). It's a...
|
by: Russ |
last post by:
I'm interested in setting up a web page where live data can be
displayed in real-time on the web page.
For example: I would like to display a (nice looking) graph of some
data value versus time and have the graph update every second without
the user having to do anything like hit a refresh button. The data to
plot is readily available from an application running on the server - I
can expose it in whatever way is needed (currently easily...
|
by: Chapman |
last post by:
Is it possible to plot the graph as an output of my program in C? It can be
a simple graph as quadratic curves for example
or a correlation between 2 variables only.
Thanks
|
by: wayne |
last post by:
i want to plot a line graph. The values that I obtain are the RGB value
of a TIFF image. i m plotting RGB values vs value(1,2,3..) so when
generated the RGB values, there will b a column of values for me t
plot the line graph
thanks alot
Peteroid wrote:
> What kind of 'plot' of the data do you want to do? A histogram ca
> be done
| |
by: diffuser78 |
last post by:
My python program spits lot of data. I take that data and plot graphs
using OfficeOrg spredsheet. I want to automate this task as this takes
so much of time. I have some questions.
1. Which is the best graph plotting utility in python or linux. Can I
write a code in such a way that my python code automatically gives me a
graph. I know little about gnuplot. If you know any better tool without
much learning curve please tell me in Linux.
...
|
by: Gouri |
last post by:
Hi,
Got a query regarding plotting a preview / thumbnail for a graph
which reads data from a binary file. The preview should should take
very less time, look exactly like the original graph i.e. not miss the
peaks and curves should look similar. Is there algorithm or anyway to
do this in C#.Net.
I have tried plotting points on regular intervals. Saves time but I
m missing peaks and curves don't resemble.
|
by: 9966 |
last post by:
Greetings, I'm currently having problem in plotting a simple graph in C++. I learned that we can actually use koolplot to do it. My question is whether it is possible to plot, let's say the performance of 6 algorithms into one graph? If so, how? Because when I refer to the koolplot documentation all I see is just plotting one thing at a time in a graph.
Thanks for any advice given.
|
by: Durand |
last post by:
Hi,
I'm trying to plot a simple graph against date or time using matplotlib. I've read about date_plot but I'm not really sure how to use it. At the moment, I have some data arranged into lists, where list1 contains x values (time) and list2 contains y values just like is needed for the normal plot function. The time values are simply the output of datetime.date.today(), etc which I don't mind changing the format of.
My question is, how do...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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
| |
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...
| |