Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1
Default Excel 2007 C# Charting problem

Hi

I'm having a problem with Excel 2007 and changing the colour of a
series of data in a chart. If a create a windows form app with code as
below I don't understand why myinterior.ColorIndex = 5 throws an
exception nor why if I look at s in the watch window, why half it's
entries are throwing exceptions.

If I change excelApp.Visible = true it works fine - why would this be?

Can anyone shed any light on this?

Cheers

Dave

(email me at D . S . Jenkins at gmail . com)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;

namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Excel.Application excelApp = new Excel.Application();
excelApp.Visible = false;
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATW orksheet);
Excel.Worksheet xlSheet =
(Excel.Worksheet)excelApp.Workbooks[1].Sheets[1];

Excel.Range c = (Excel.Range)xlSheet.Cells[1, 1];
Excel.Range d = (Excel.Range)xlSheet.Cells[2, 1];
c.Value2 = "A";
d.Value2 = 1;

Excel.Range i;
Excel.Range j;
Excel.Range xlrange;

i = (Excel.Range)xlSheet.Cells[1, 1];
j = (Excel.Range)xlSheet.Cells[2, 1];
xlrange = xlSheet.get_Range(i, j);



Excel.Chart g1 =
(Excel.Chart)newWorkbook.Sheets.Add(Type.Missing, Type.Missing,
Type.Missing, Excel.XlSheetType.xlChart);
g1.ChartType = Excel.XlChartType.xlColumnStacked;

Excel.Series s = g1.SeriesCollection(1) as Excel.Series;
Excel.Interior myinterior = s.Interior;
myinterior.ColorIndex = 5;

}
}
}

  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3
Default Excel 2007 C# Charting problem

This should be fixed in the final version of Excel 2007.

-Helen (Excel PM)

wrote in message
ups.com...
Hi

I'm having a problem with Excel 2007 and changing the colour of a
series of data in a chart. If a create a windows form app with code as
below I don't understand why myinterior.ColorIndex = 5 throws an
exception nor why if I look at s in the watch window, why half it's
entries are throwing exceptions.

If I change excelApp.Visible = true it works fine - why would this be?

Can anyone shed any light on this?

Cheers

Dave

(email me at D . S . Jenkins at gmail . com)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;

namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
Excel.Application excelApp = new Excel.Application();
excelApp.Visible = false;
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATW orksheet);
Excel.Worksheet xlSheet =
(Excel.Worksheet)excelApp.Workbooks[1].Sheets[1];

Excel.Range c = (Excel.Range)xlSheet.Cells[1, 1];
Excel.Range d = (Excel.Range)xlSheet.Cells[2, 1];
c.Value2 = "A";
d.Value2 = 1;

Excel.Range i;
Excel.Range j;
Excel.Range xlrange;

i = (Excel.Range)xlSheet.Cells[1, 1];
j = (Excel.Range)xlSheet.Cells[2, 1];
xlrange = xlSheet.get_Range(i, j);



Excel.Chart g1 =
(Excel.Chart)newWorkbook.Sheets.Add(Type.Missing, Type.Missing,
Type.Missing, Excel.XlSheetType.xlChart);
g1.ChartType = Excel.XlChartType.xlColumnStacked;

Excel.Series s = g1.SeriesCollection(1) as Excel.Series;
Excel.Interior myinterior = s.Interior;
myinterior.ColorIndex = 5;

}
}
}



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Excel 2000 problem copying drawingobjects between sheets SiriS Excel Discussion (Misc queries) 0 February 8th 06 10:31 AM
Excel Charting problem.. Alex Excel Discussion (Misc queries) 1 August 5th 05 01:57 PM
Excel Range Value issue (Excel 97 Vs Excel 2003) Keeno Excel Discussion (Misc queries) 2 June 13th 05 02:01 PM
Excel 2003 Slowness problem in Windows XP Elton Seng Yan Thung Excel Discussion (Misc queries) 2 May 18th 05 04:55 AM


All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"