我需要使用vb.net修改图上系列(1)的范围。图表在工作表3上,数据在工作表1上。我无法使用代码进行操作。
我创建新系列没有问题,但是我不知道如何修改现有系列。
下面是添加新系列的代码:
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Open(SciezkaZapisu & "\Wyniki ugięć.xlsx")
oSheet = oBook.Worksheets(1)
Dim t_Chart As Excel.Chart
Dim t_serCol As Excel.SeriesCollection
Dim t_series As Excel.Series
With oBook.Worksheets(3)
.ChartObjects(1).Activate()
t_Chart = oBook.ActiveChart
t_serCol = t_Chart.SeriesCollection
t_series = t_serCol.NewSeries
With t_series
.Name = "RDair"
.XValues = oBook.Worksheets(1).Range("A5" & ":A" & 5 + LiczbaWierszy)
.Values = oBook.Worksheets(1).Range("B5" & ":B" & 5 + LiczbaWierszy)
End With
End With
oBook.SaveAs(SciezkaZapisu & "\" & NazwaPliku & ".xlsx")
oExcel.Quit