Home All Groups Group Topic Archive Search About

Creating a chart in Excel using VC++ .net 2005

Author
16 Oct 2007 11:37 AM
antarikshv
Hi,
Can any one please help me in creating chart in VC++ .net 2005 and
Excel 2003.
I am stuck at the point when i want to give a specific column as the X-
axis and a specific column as Y-axis. currently i am able to specify a
range and draw the chart. If you could give the code then it will be
the best thing. the following is the code i am referring to.

// The following code draws the chart
Excel::ChartObjects^ chartobjects =
safe_cast<Excel::ChartObjects^>(worksheet->ChartObjects(oMissing));

            Excel::ChartObject^ chartobject =
safe_cast<Excel::ChartObject^>(chartobjects->Add(10 /*Left*/, 100 /
*Top*/, 450 /*Width*/, 250 /*Height*/));
            Excel::_Chart^ chart = safe_cast<Excel::_Chart^>(chartobject-
>Chart);


            // Call to chart.ChartWizard() is shown using late binding
technique solely for the demonstration purposes
            array<Object^>^ args7 = gcnew array<Object^>(11);
            args7[0] = ran; // Source
            args7[1] = Excel::XlChartType::xlLineMarkers; // Gallery - note,
we're using implicit boxing here
            args7[2] = oMissing; // Format
            args7[3] = Excel::XlRowCol::xlRows; // PlotBy - note, we're using
implicit boxing here
            args7[4] = nullptr; // CategoryLabels
            args7[5] = nullptr; // SeriesLabels
            args7[6] = true; // HasLegend - note, we're using implicit boxing
here
            args7[7] = "Sample Chart"; // Title
            args7[8] = "Sample Category Type"; // CategoryTitle
            args7[9] = "Sample Value Type"; // ValueTitle
            args7[10] = oMissing; // ExtraTitle
            // The last parameter is lcid, but as we use late binding here it
should be omited
            //args7[11] = 0; // lcid
            chart->GetType()->InvokeMember("ChartWizard",
System::Reflection::BindingFlags::InvokeMethod, nullptr, chart,
args7);


Also i am unaware of late bindings. Can anyone help with what it means
and what effect does it have on performance.

Author
17 Oct 2007 12:18 AM
Alvin Bruney [MVP]
you can find code to build a chart in C# at the
office.developer.web.components newsgroup. You'll then need to do some
translation

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$24.99


Show quote
"antarikshv" <antarik***@gmail.com> wrote in message
news:1192534641.495221.92700@y27g2000pre.googlegroups.com...
> Hi,
> Can any one please help me in creating chart in VC++ .net 2005 and
> Excel 2003.
> I am stuck at the point when i want to give a specific column as the X-
> axis and a specific column as Y-axis. currently i am able to specify a
> range and draw the chart. If you could give the code then it will be
> the best thing. the following is the code i am referring to.
>
> // The following code draws the chart
> Excel::ChartObjects^ chartobjects =
> safe_cast<Excel::ChartObjects^>(worksheet->ChartObjects(oMissing));
>
> Excel::ChartObject^ chartobject =
> safe_cast<Excel::ChartObject^>(chartobjects->Add(10 /*Left*/, 100 /
> *Top*/, 450 /*Width*/, 250 /*Height*/));
> Excel::_Chart^ chart = safe_cast<Excel::_Chart^>(chartobject-
>>Chart);
>
>
> // Call to chart.ChartWizard() is shown using late binding
> technique solely for the demonstration purposes
> array<Object^>^ args7 = gcnew array<Object^>(11);
> args7[0] = ran; // Source
> args7[1] = Excel::XlChartType::xlLineMarkers; // Gallery - note,
> we're using implicit boxing here
> args7[2] = oMissing; // Format
> args7[3] = Excel::XlRowCol::xlRows; // PlotBy - note, we're using
> implicit boxing here
> args7[4] = nullptr; // CategoryLabels
> args7[5] = nullptr; // SeriesLabels
> args7[6] = true; // HasLegend - note, we're using implicit boxing
> here
> args7[7] = "Sample Chart"; // Title
> args7[8] = "Sample Category Type"; // CategoryTitle
> args7[9] = "Sample Value Type"; // ValueTitle
> args7[10] = oMissing; // ExtraTitle
> // The last parameter is lcid, but as we use late binding here it
> should be omited
> //args7[11] = 0; // lcid
> chart->GetType()->InvokeMember("ChartWizard",
> System::Reflection::BindingFlags::InvokeMethod, nullptr, chart,
> args7);
>
>
> Also i am unaware of late bindings. Can anyone help with what it means
> and what effect does it have on performance.
>
Author
17 Oct 2007 4:02 AM
antarikshv
On Oct 17, 5:18 am, "Alvin Bruney [MVP]" <some guy without an email
address> wrote:
> you can find code to build a chart in C# at the
> office.developer.web.components newsgroup. You'll then need to do some
> translation
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
Hi, Can please give me some link for it? currently i am not able to
find the reference. Please help

AddThis Social Bookmark Button