beanman101283
2[H]4U
- Joined
- Nov 4, 2004
- Messages
- 3,051
I'm playing with different ways to show simulation output in a VB form. I've been messing around with the Office Web Components Chart component, but i'm having trouble getting my data to show up. First off, i've had a hard time finding decent documentation and/or examples, but i finally found what seemed to be an up-to-date tutorial. Just to test it out, i've got a spreadsheet with three values that i want to display in a column chart.
This is my code:
And this is what shows up on the form:
The series name shows up in the legend, but none of the data appears. The three values for the graph are supposed to all be 528. You can see commented out that i tried using hard coded values for my data as well but that didn't work either. I've followed the sample code i've found to the letter (i think), so can anyone lend a hand?
This is my code:
Code:
Imports Microsoft.Office.Interop
Public Class frmSean
Dim xlExcel As New Excel.Application
Private Sub frmSean_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
xlExcel.Workbooks.Open("C:\Documents and Settings\Sean Beanland\My Documents\BFAMS\Output\Output sample sheet 2.xls")
Dim strCategories() As String = {xlExcel.Range("B5").Value.ToString, _
xlExcel.Range("C5").Value.ToString, _
xlExcel.Range("D5").Value.ToString}
'Dim strCategories() As String = {"March", "April", "June"}
'Dim strValues() As String = {"546", "453", "345"}
Dim strValues() As String = {xlExcel.Range("B6").Value.ToString, _
xlExcel.Range("C6").Value.ToString, _
xlExcel.Range("D6").Value.ToString}
'Clear any chart objects then add one new one
AxChartSpace1.Clear()
AxChartSpace1.Charts.Add(0)
'Make chart legend visible,
AxChartSpace1.Charts(0).HasLegend = True
AxChartSpace1.Charts(0).Type = Owc11.ChartChartTypeEnum.chChartTypeColumn3D
'Add series to the chart
AxChartSpace1.Charts(0).SeriesCollection.Add(0)
'bind series name, category names, and values
AxChartSpace1.Charts(0).SeriesCollection(0).SetData(Owc11.ChartDimensionsEnum.chDimSeriesNames, _
Convert.ToInt32(Owc11.ChartSpecialDataSourcesEnum.chDataLiteral), xlExcel.Range("A6").Value)
AxChartSpace1.Charts(0).SeriesCollection(0).SetData(Owc11.ChartDimensionsEnum.chDimCategories, _
Convert.ToInt32(Owc11.ChartSpecialDataSourcesEnum.chDataLiteral), strCategories)
AxChartSpace1.Charts(0).SeriesCollection(0).SetData(Owc11.ChartDimensionsEnum.chDimValues, _
Convert.ToInt32(Owc11.ChartSpecialDataSourcesEnum.chDataLiteral), strValues)
End Sub
End Class
And this is what shows up on the form:
The series name shows up in the legend, but none of the data appears. The three values for the graph are supposed to all be 528. You can see commented out that i tried using hard coded values for my data as well but that didn't work either. I've followed the sample code i've found to the letter (i think), so can anyone lend a hand?