I've got some VB.NET code which uses Excel to create a chart from some data. The chart works how it should but I'm finding the switch from VBA to VB formatting-wise difficult.
I want just series 1 in the legend to be deleted and the data in the chart itself to either have transparency set to 100 or to have fill set to no fill. I've played with charpage.seriescollection(1).format.fill
etc. but I'm not getting it.
My code:
Dim xlApp As Excel.Application = New Microsoft.Office.Interop.Excel.Application()
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkbooks As Excel.Workbooks = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
Dim chartPage As Excel.Chart
Dim xlCharts As Excel.ChartObjects
Dim myChart As Excel.ChartObject
Dim chartRange As Excel.Range
Dim Chartarea As Excel.ChartArea
xlCharts = xlWorkSheet.ChartObjects
myChart = xlCharts.Add(10, 80, 900, 500)
chartPage = myChart.Chart
chartRange = xlWorkSheet.Range("B1", "E2000")
chartPage.SetSourceData(Source:=chartRange)
chartPage.ChartType = Excel.XlChartType.xlBarStacked
chartPage.ChartWizard(Title:="Gantt Chart of Offshore Operations")
chartPage.Legend.Position = Excel.XlLegendPosition.xlLegendPositionTop
'Y axis
With chartPage.Axes(Excel.XlAxisType.xlCategory)
.categorytype = Excel.XlCategoryType.xlTimeScale
.BaseUnit = Excel.XlTimeUnit.xlDays
End With
'X axis
With chartPage.Axes(Excel.XlAxisType.xlValue)
.HasTitle = True
.AxisTitle.Caption = "Time (Days)"
End With