Project (系列对象)
表示在图表中生成行或列的相关数据的集合。
Series 对象是 SeriesCollection 集合的成员,该集合包括图表中的所有数据系列。 系列的名称通常显示在图表图例中。
以下示例打印图表上数据系列集合的系列名称、X (水平) 值和 Y (垂直) 值。
Sub TestChartSeries()
Dim reportName As String
Dim theReportIndex As Integer
Dim theChart As Chart
Dim seriesCollec As SeriesCollection
Dim chartSeries As Series
Dim i As Integer
Dim j As Integer
reportName = "Simple scalar chart"
theReportIndex = -1
If (ActiveProject.Reports.IsPresent(reportName)) Then
' Make the report active.
theReportIndex = ActiveProject.Reports(reportName).Index
ActiveProject.Reports(theReportIndex).Apply
Set theChart = ActiveProject.Reports(theReportIndex).Shapes(1).Chart
Set seriesCollec = theChart.SeriesCollection()
For i = 1 To seriesCollec.Count
Set chartSeries = seriesCollec(i)
If (IsEmpty(chartSeries.Name)) Then
Debug.Print "Series " & i & " name is an empty string."
Else
Debug.Print "Series " & i & ": " & chartSeries.Name
End If
For j = 1 To seriesCollec.Count
Debug.Print vbTab & "X, Y values(" & j & "): " & chartSeries.XValues(j) _
& ", " & chartSeries.Values(j); ""
Next j
Next i
End If
End Sub
以下示例输出来自图表,例如 Chart 对象文档中的示例。
Series 1: Actual Work
X, Y values(1): T1, 16
X, Y values(2): T2 - new, 32
X, Y values(3): T3, 7
Series 2: Remaining Work
X, Y values(1): T1, 0
X, Y values(2): T2 - new, 16
X, Y values(3): T3, 17
Series 3: Work
X, Y values(1): T1, 16
X, Y values(2): T2 - new, 48
X, Y values(3): T3, 24
名称 |
---|
Application |
名称 |
Parent |
值 |
XValues |
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。