//1.增加一个二维图chartobjects.add(Left, Top, 宽,高)
chart1 := xlssheet1.chartObjects.Add(l_left,l_top,l_Width,l_Height);
//2.选择二维图的形态
chart1.Activate;
chart1.chart.charttype := xlXYScatterLines;
//线条说明位置
chart1.chart.Legend.Position := xlLegendPositionTop;
//chart1.chart.Legend.Top := 5;
//3.给二维图赋值
series := chart1.chart.SeriesCollection;
//4.给二维图加上标题
chart1.chart.HasTitle := true;
chart1.chart.ChartTitle.Characters.Text := 'A';
chart1.chart.ChartTitle.Font.size := 12;
//(xlValue, xlPrimary) 左标
chart1.Chart.Axes(xlValue, xlPrimary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := 'A';
//( xlCategory , xlPrimary )下标
chart1.Chart.Axes(xlCategory, xlPrimary).HasTitle := True;
chart1.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text := 'B';
chart1.Chart.Axes(xlCategory, xlPrimary).HasMinorGridlines := True;
chart1.Chart.Axes(xlCategory, xlPrimary).HasMajorGridlines := True;
chart1.Chart.Axes(xlCategory, xlPrimary).MaximumScaleIsAuto := True;
chart1.Chart.Axes(xlCategory, xlPrimary).MinimumScaleIsAuto := True;
chart1.Chart.Axes(xlCategory, xlPrimary).MinorUnitIsAuto := True;
chart1.chart.Axes(xlCategory, xlPrimary).ScaleType := xlScaleLinear;
//xlTickLabelOrientationAutomatic -4105 由 Microsoft Word 設定文字方向。
//xlTickLabelOrientationDownward -4170 文字向下。
//xlTickLabelOrientationHorizontal -4128 字元水平排列。
//xlTickLabelOrientationUpward -4171 文字向上。
//xlTickLabelOrientationVertical -4166 字元垂直排列。
chart1.chart.Axes(xlCategory, xlPrimary).ticklabels.Orientation := xlTickLabelOrientationUpward;
//第一条线
ExcelCount := xlssheet3.Usedrange.Rows.Count;
series.NewSeries;
se := chart1.chart.seriescollection(1);
se.Name :='线条说明';
AX := 'A' +InttoStr(ExcelCount);
se.XValues := '=sheet3!A2:'+ AX;
BX := 'B' +InttoStr(ExcelCount);
se.Values := '=sheet3!B2:'+BX;
//第二条线
series.NewSeries;
se := chart1.chart.seriescollection(2);
se.Name :='线条说明';
AX := 'A' +InttoStr(ExcelCount);
se.XValues := '=sheet3!A2:'+AX;
CX := 'C' +InttoStr(ExcelCount);
se.Values := '=sheet3!C2:'+CX;
//设置数据集为次要坐标轴
se.AxisGroup := xlSecondary;
//设置次有坐标轴说明( xlValue , xlSecondary )右标
chart1.Chart.Axes(xlValue, xlSecondary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text := 'C';
chart1 := xlssheet1.chartObjects.Add(l_left,l_top,l_Width,l_Height);
//2.选择二维图的形态
chart1.Activate;
chart1.chart.charttype := xlXYScatterLines;
//线条说明位置
chart1.chart.Legend.Position := xlLegendPositionTop;
//chart1.chart.Legend.Top := 5;
//3.给二维图赋值
series := chart1.chart.SeriesCollection;
//4.给二维图加上标题
chart1.chart.HasTitle := true;
chart1.chart.ChartTitle.Characters.Text := 'A';
chart1.chart.ChartTitle.Font.size := 12;
//(xlValue, xlPrimary) 左标
chart1.Chart.Axes(xlValue, xlPrimary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := 'A';
//( xlCategory , xlPrimary )下标
chart1.Chart.Axes(xlCategory, xlPrimary).HasTitle := True;
chart1.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text := 'B';
chart1.Chart.Axes(xlCategory, xlPrimary).HasMinorGridlines := True;
chart1.Chart.Axes(xlCategory, xlPrimary).HasMajorGridlines := True;
chart1.Chart.Axes(xlCategory, xlPrimary).MaximumScaleIsAuto := True;
chart1.Chart.Axes(xlCategory, xlPrimary).MinimumScaleIsAuto := True;
chart1.Chart.Axes(xlCategory, xlPrimary).MinorUnitIsAuto := True;
chart1.chart.Axes(xlCategory, xlPrimary).ScaleType := xlScaleLinear;
//xlTickLabelOrientationAutomatic -4105 由 Microsoft Word 設定文字方向。
//xlTickLabelOrientationDownward -4170 文字向下。
//xlTickLabelOrientationHorizontal -4128 字元水平排列。
//xlTickLabelOrientationUpward -4171 文字向上。
//xlTickLabelOrientationVertical -4166 字元垂直排列。
chart1.chart.Axes(xlCategory, xlPrimary).ticklabels.Orientation := xlTickLabelOrientationUpward;
//第一条线
ExcelCount := xlssheet3.Usedrange.Rows.Count;
series.NewSeries;
se := chart1.chart.seriescollection(1);
se.Name :='线条说明';
AX := 'A' +InttoStr(ExcelCount);
se.XValues := '=sheet3!A2:'+ AX;
BX := 'B' +InttoStr(ExcelCount);
se.Values := '=sheet3!B2:'+BX;
//第二条线
series.NewSeries;
se := chart1.chart.seriescollection(2);
se.Name :='线条说明';
AX := 'A' +InttoStr(ExcelCount);
se.XValues := '=sheet3!A2:'+AX;
CX := 'C' +InttoStr(ExcelCount);
se.Values := '=sheet3!C2:'+CX;
//设置数据集为次要坐标轴
se.AxisGroup := xlSecondary;
//设置次有坐标轴说明( xlValue , xlSecondary )右标
chart1.Chart.Axes(xlValue, xlSecondary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text := 'C';