Delphi 操作EXCEL折线图

//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';
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值