Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
I can't believe how complicated this is...
Continued from my previous question on Charting...
I now have this code, it will get to the second series and then it dies with this error. System.InvalidCastException was unhandled OleAut reported a type mismatch. ....on this line... mySeries[1] = mySeriesCollection.Add((Excel.Range)myWorksheet.ge t_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); I'm not seeing where the Casting issue is here. After all it, completes the series line on the chart, then gets the exception. Here is the method in full: mySeries = new Microsoft.Office.Interop.Excel.Series[4]; myChart = myWorkbook.Charts.Add(missing, missing, missing, missing) as Excel.Chart; myExcelApp.ActiveChart.ChartType = Excel.XlChartType.xlXYScatterSmooth; myExcelApp.ActiveChart.Name = "Time Analysis Chart"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(1) ; myExcelApp.ActiveChart.SetSourceData(myWorksheet.g et_Range("D2", "D13"), Excel.XlRowCol.xlColumns); mySeriesCollection = (Excel.SeriesCollection)myChart.SeriesCollection(m issing); mySeries[0] = mySeriesCollection.Item(mySeriesCollection.Count); mySeries[0].Name = "5442"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(2) ; mySeries[1] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[1].Name = "5441"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(3) ; mySeries[2] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[2].Name = "5440"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(4) ; mySeries[3] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[3].Name = "5439"; Thanks, in advance:) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
I can't believe how complicated this is...
I am sorry I did not formulate my question right. In my example I have only
one range (a8:a30). I need it, after it matches the cell = 1122 in column A, to go to column B and meet another condition. Basically, I need it to match column A with column B and then I want it to evaluate IF. -- Sergei D "ChartsToBe" wrote: Continued from my previous question on Charting... I now have this code, it will get to the second series and then it dies with this error. System.InvalidCastException was unhandled OleAut reported a type mismatch. ...on this line... mySeries[1] = mySeriesCollection.Add((Excel.Range)myWorksheet.ge t_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); I'm not seeing where the Casting issue is here. After all it, completes the series line on the chart, then gets the exception. Here is the method in full: mySeries = new Microsoft.Office.Interop.Excel.Series[4]; myChart = myWorkbook.Charts.Add(missing, missing, missing, missing) as Excel.Chart; myExcelApp.ActiveChart.ChartType = Excel.XlChartType.xlXYScatterSmooth; myExcelApp.ActiveChart.Name = "Time Analysis Chart"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(1) ; myExcelApp.ActiveChart.SetSourceData(myWorksheet.g et_Range("D2", "D13"), Excel.XlRowCol.xlColumns); mySeriesCollection = (Excel.SeriesCollection)myChart.SeriesCollection(m issing); mySeries[0] = mySeriesCollection.Item(mySeriesCollection.Count); mySeries[0].Name = "5442"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(2) ; mySeries[1] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[1].Name = "5441"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(3) ; mySeries[2] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[2].Name = "5440"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(4) ; mySeries[3] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[3].Name = "5439"; Thanks, in advance:) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
I can't believe how complicated this is...
I think you submitted that reply to the wrong thread:|
"Sergei D" wrote: I am sorry I did not formulate my question right. In my example I have only one range (a8:a30). I need it, after it matches the cell = 1122 in column A, to go to column B and meet another condition. Basically, I need it to match column A with column B and then I want it to evaluate IF. -- Sergei D "ChartsToBe" wrote: Continued from my previous question on Charting... I now have this code, it will get to the second series and then it dies with this error. System.InvalidCastException was unhandled OleAut reported a type mismatch. ...on this line... mySeries[1] = mySeriesCollection.Add((Excel.Range)myWorksheet.ge t_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); I'm not seeing where the Casting issue is here. After all it, completes the series line on the chart, then gets the exception. Here is the method in full: mySeries = new Microsoft.Office.Interop.Excel.Series[4]; myChart = myWorkbook.Charts.Add(missing, missing, missing, missing) as Excel.Chart; myExcelApp.ActiveChart.ChartType = Excel.XlChartType.xlXYScatterSmooth; myExcelApp.ActiveChart.Name = "Time Analysis Chart"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(1) ; myExcelApp.ActiveChart.SetSourceData(myWorksheet.g et_Range("D2", "D13"), Excel.XlRowCol.xlColumns); mySeriesCollection = (Excel.SeriesCollection)myChart.SeriesCollection(m issing); mySeries[0] = mySeriesCollection.Item(mySeriesCollection.Count); mySeries[0].Name = "5442"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(2) ; mySeries[1] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[1].Name = "5441"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(3) ; mySeries[2] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[2].Name = "5440"; myWorksheet = (Excel.Worksheet)myWorkbook.Worksheets.get_Item(4) ; mySeries[3] = mySeriesCollection.Add(myWorksheet.get_Range("D2", "D13"), Excel.XlRowCol.xlColumns, false, false, false); mySeries[3].Name = "5439"; Thanks, in advance:) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Complicated Look-Up | Excel Discussion (Misc queries) | |||
a little complicated | Excel Worksheet Functions | |||
This is more complicated than it looks. | Excel Worksheet Functions | |||
Complicated | Excel Worksheet Functions | |||
Complicated One! | Excel Programming |