Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stop excel from dropping the 0 in the beginning of a number? | Setting up and Configuration of Excel | |||
Excel 2000 problem copying drawingobjects between sheets | Excel Discussion (Misc queries) | |||
Excel Charting problem.. | Excel Discussion (Misc queries) | |||
Excel Range Value issue (Excel 97 Vs Excel 2003) | Excel Discussion (Misc queries) | |||
Excel 2003 Slowness problem in Windows XP | Excel Discussion (Misc queries) |