Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > Book: Wrox's Visual C# 2005 Express Edition Starter Kit
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Book: Wrox's Visual C# 2005 Express Edition Starter Kit
This is the forum to discuss the Wrox book Wrox's Visual C# 2005 Express Edition Starter Kit by F. Scott Barker; ISBN: 9780764589553
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Book: Wrox's Visual C# 2005 Express Edition Starter Kit section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 13th, 2009, 02:24 AM
Registered User
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post Using "microsoft.office.interop.Graph.Chart"

Hi,

i have a written a piece of code to generate graph using c# application. The problem i am facing is to display valuelabels in the graph. how to achieve this?
The piece of code is given below.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using Microsoft.Office.Core;
using Microsoft.Office;
using System.Runtime.InteropServices;

private
void ShowPresentation()
{
String strTemplate, strPic;
strTemplate =
"C:\\Program Files\\Microsoft Office\\Templates\\Presentation Designs\\Blends.pot";
strPic =
"C:\\Windows\\Blue Lace 16.bmp";
bool bAssistantOn;
PowerPoint.
Application objApp;
PowerPoint.
Presentations objPresSet;
PowerPoint.
_Presentation objPres;
PowerPoint.
Slides objSlides;
PowerPoint.
_Slide objSlide;
PowerPoint.
TextRange objTextRng;
PowerPoint.
Shapes objShapes;
PowerPoint.
Shape objShape;
PowerPoint.
SlideShowWindows objSSWs;
PowerPoint.
SlideShowTransition objSST;
PowerPoint.
SlideShowSettings objSSS;
PowerPoint.
SlideRange objSldRng;
Graph.
Chart objChart;
Graph.
DataSheet dataSheet;

//Create a new presentation based on a template.
objApp = new PowerPoint.Application();
objApp.Visible =
MsoTriState.msoTrue;
objPresSet = objApp.Presentations;
objPres = objPresSet.Open(strTemplate,
MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
objSlides = objPres.Slides;
//Build Slide #1:
//Add text to the slide, change the font and insert/position a
//picture on the first slide.
objSlide = objSlides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
objTextRng.Text =
"My Sample Presentation";
objTextRng.Font.Name =
"Comic Sans MS";
objTextRng.Font.Size = 48;
objSlide.Shapes.AddPicture(strPic,
MsoTriState.msoFalse, MsoTriState.msoTrue,
150, 150, 500, 350);
//Build Slide #2:
//Add text to the slide title, format the text. Also add a chart to the
//slide and change the chart type to a 3D pie chart.
objSlide = objSlides.Add(2, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
objTextRng.Text =
"My Chart";
objTextRng.Font.Name =
"Comic Sans MS";
objTextRng.Font.Size = 48;
objChart = (Graph.
Chart)objSlide.Shapes.AddOLEObject(150, 150, 480, 320,
"MSGraph.Chart.8", "", MsoTriState.msoFalse, "", 0, "",
MsoTriState.msoFalse).OLEFormat.Object;
dataSheet = objChart.Application.DataSheet;

dataSheet.Cells[1, 2] =
"abc";
dataSheet.Cells[2, 2] =
"50";
dataSheet.Cells[2, 3] =
"40";
dataSheet.Cells[2, 4] =
"50";
dataSheet.Cells[2, 5] =
"50";
dataSheet.Cells[3, 2] =
"60";
dataSheet.Cells[3, 3] =
"70";
dataSheet.Cells[3, 4] =
"80";
dataSheet.Cells[3, 5] =
"60";
//dataSheet.Cells[3, 6] = "0";
dataSheet.Cells[4, 2] = "50";
dataSheet.Cells[4, 3] =
"40";
dataSheet.Cells[4, 4] =
"50";
dataSheet.Cells[4, 5] =
"50";
//dataSheet.Cells[4, 6] = "0";
objChart.Application.Update();
//objChart.ChartType = Graph.XlChartType.xl3DPie;
objChart.Legend.Position = Graph.XlLegendPosition.xlLegendPositionBottom;
//objChart.ApplyDataLabels(Graph.XlDataLabelsType.xl DataLabelsShowLabel, true, false, false);
objChart.HasTitle = true;
objChart.ChartTitle.Text =
"Here it is...";
//Build Slide #3:
//Change the background color of this slide only. Add a text effect to the slide
//and apply various color schemes and shadows to the text effect.
objSlide = objSlides.Add(3, PowerPoint.PpSlideLayout.ppLayoutBlank);
objSlide.FollowMasterBackground =
MsoTriState.msoFalse;
objShapes = objSlide.Shapes;
objShape = objShapes.AddTextEffect(
MsoPresetTextEffect.msoTextEffect27,
"The End", "Impact", 96, MsoTriState.msoFalse, MsoTriState.msoFalse, 230, 200);
//Modify the slide show transition settings for all 3 slides in
//the presentation.
int[] SlideIdx = newint[3];
for (int i = 0; i < 3; i++) SlideIdx[i] = i + 1;
objSldRng = objSlides.Range(SlideIdx);
objSST = objSldRng.SlideShowTransition;
objSST.AdvanceOnTime =
MsoTriState.msoTrue;
objSST.AdvanceTime = 3;
objSST.EntryEffect = PowerPoint.
PpEntryEffect.ppEffectBoxOut;
//Prevent Office Assistant from displaying alert messages:
bAssistantOn = objApp.Assistant.On;
objApp.Assistant.On =
false;
//Run the Slide show from slides 1 thru 3.
objSSS = objPres.SlideShowSettings;
objSSS.StartingSlide = 1;
objSSS.EndingSlide = 3;
objSSS.Run();
//Wait for the slide show to end.
objSSWs = objApp.SlideShowWindows;
while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);
//Reenable Office Assisant, if it was on:
if (bAssistantOn)
{
objApp.Assistant.On =
true;
objApp.Assistant.Visible =
false;
}
//Close the presentation without saving changes and quit PowerPoint.
objPres.SaveAs("C:\\abc.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, MsoTriState.msoTrue);
objPres.Close();
objApp.Quit();

}
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading a files general property of "Type of file" GregSivers Visual Basic 2008 Essentials 7 June 3rd, 2009 09:38 AM
Which storage engine for "Post for sell goods" website taev MySQL 2 May 8th, 2009 02:53 PM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM
Chapter-5 on Intents:ContactPickerTester does not show the button "Pick a Contact" sunilm12 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 April 15th, 2009 11:55 AM
How to download Code in "Professional Active Server Page 3.0 " book. renjith0 All Other Wrox Books 2 April 2nd, 2009 05:06 AM



All times are GMT -4. The time now is 10:49 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.