with gappExcel
lsDayValues1 = "R4C" & llTemp & ":" & "R" & llColTemp + 3 & "C" & llTemp
lsDayName1 = "R3C" & llTemp
lsDayValues2 = "R4C" & llTemp + 2 & ":" & "R" & llColTemp + 3 & "C" & llTemp + 2
lsDayName2 = "R3C" & llTemp + 2
.Charts.Add
.ActiveChart.ChartType = xlLineMarkers
.ActiveChart.Location Where:=xlLocationAsObject, Name:="sheet1"
.ActiveChart.SeriesCollection.NewSeries
.ActiveChart.SeriesCollection.NewSeries
.ActiveChart.SeriesCollection(1).Values = "=" & .ActiveSheet.Name & "!" & lsDayValues1
.ActiveChart.SeriesCollection(1).Name = "=" & .ActiveSheet.Name & "!" & lsDayName1
.ActiveChart.SeriesCollection(2).Values = "=" & .ActiveSheet.Name & "!" & lsDayValues2
.ActiveChart.SeriesCollection(2).Name = "=" & .ActiveSheet.Name & "!" & lsDayName2
.ActiveSheet.ChartObjects(llCount * 4 - 3).Width = 310
.ActiveSheet.ChartObjects(llCount * 4 - 3).Left = 70 + (418 - 70) * (llCount - 1)
.ActiveSheet.ChartObjects(llCount * 4 - 3).Top = 540
.ActiveSheet.ChartObjects(llCount * 4 - 3).Height = 170
With .ActiveChart.Axes(xlCategory)
.CrossesAt = 1
.TickLabelSpacing = 1
.TickMarkSpacing = 1
.AxisBetweenCategories = True
.ReversePlotOrder = False
End With
With .ActiveChart
.SeriesCollection(1).XValues = ""
.SeriesCollection(2).XValues = ""
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "DATE"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "RMB"
End With
With .ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = objCommon.NullToString(lrRec.Fields("hmm03_storenm")) & "—" & getFormItems(lsfrmName, cstDayState) '每日状况"
End With
lsDayValues1 = "R4C" & llTemp & ":" & "R" & llColTemp + 3 & "C" & llTemp
lsDayName1 = "R3C" & llTemp
lsDayValues2 = "R4C" & llTemp + 2 & ":" & "R" & llColTemp + 3 & "C" & llTemp + 2
lsDayName2 = "R3C" & llTemp + 2
.Charts.Add
.ActiveChart.ChartType = xlLineMarkers
.ActiveChart.Location Where:=xlLocationAsObject, Name:="sheet1"
.ActiveChart.SeriesCollection.NewSeries
.ActiveChart.SeriesCollection.NewSeries
.ActiveChart.SeriesCollection(1).Values = "=" & .ActiveSheet.Name & "!" & lsDayValues1
.ActiveChart.SeriesCollection(1).Name = "=" & .ActiveSheet.Name & "!" & lsDayName1
.ActiveChart.SeriesCollection(2).Values = "=" & .ActiveSheet.Name & "!" & lsDayValues2
.ActiveChart.SeriesCollection(2).Name = "=" & .ActiveSheet.Name & "!" & lsDayName2
.ActiveSheet.ChartObjects(llCount * 4 - 3).Width = 310
.ActiveSheet.ChartObjects(llCount * 4 - 3).Left = 70 + (418 - 70) * (llCount - 1)
.ActiveSheet.ChartObjects(llCount * 4 - 3).Top = 540
.ActiveSheet.ChartObjects(llCount * 4 - 3).Height = 170
With .ActiveChart.Axes(xlCategory)
.CrossesAt = 1
.TickLabelSpacing = 1
.TickMarkSpacing = 1
.AxisBetweenCategories = True
.ReversePlotOrder = False
End With
With .ActiveChart
.SeriesCollection(1).XValues = ""
.SeriesCollection(2).XValues = ""
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "DATE"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "RMB"
End With
With .ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = objCommon.NullToString(lrRec.Fields("hmm03_storenm")) & "—" & getFormItems(lsfrmName, cstDayState) '每日状况"
End With
end with
这个是我做的添加的一个新chart的示里例 看有没有帮助呢
objCommon.NullToString 其中这个函数是为了返回数据库字段为空的时候 让他不为空 而且trim掉所有空格的函数