Delphi 操作EXCEL折线图
生活随笔
收集整理的這篇文章主要介紹了
Delphi 操作EXCEL折线图
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
//1.增加一個二維圖chartobjects.add(Left, Top, 寬,高)
chart1 := xlssheet1.chartObjects.Add(l_left,l_top,l_Width,l_Height);
//2.選擇二維圖的形態(tài)
chart1.Activate;
chart1.chart.charttype := xlXYScatterLines;
//線條說明位置
chart1.chart.Legend.Position := xlLegendPositionTop;
//chart1.chart.Legend.Top := 5;
//3.給二維圖賦值
series := chart1.chart.SeriesCollection;
//4.給二維圖加上標(biāo)題
chart1.chart.HasTitle := true;
chart1.chart.ChartTitle.Characters.Text := 'A';
chart1.chart.ChartTitle.Font.size := 12;
//(xlValue, xlPrimary) 左標(biāo)
chart1.Chart.Axes(xlValue, xlPrimary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := 'A';
//( xlCategory , xlPrimary )下標(biāo)
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 設(shè)定文字方向。
//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;
//設(shè)置數(shù)據(jù)集為次要坐標(biāo)軸
se.AxisGroup := xlSecondary;
//設(shè)置次有坐標(biāo)軸說明( xlValue , xlSecondary )右標(biāo)
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.選擇二維圖的形態(tài)
chart1.Activate;
chart1.chart.charttype := xlXYScatterLines;
//線條說明位置
chart1.chart.Legend.Position := xlLegendPositionTop;
//chart1.chart.Legend.Top := 5;
//3.給二維圖賦值
series := chart1.chart.SeriesCollection;
//4.給二維圖加上標(biāo)題
chart1.chart.HasTitle := true;
chart1.chart.ChartTitle.Characters.Text := 'A';
chart1.chart.ChartTitle.Font.size := 12;
//(xlValue, xlPrimary) 左標(biāo)
chart1.Chart.Axes(xlValue, xlPrimary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := 'A';
//( xlCategory , xlPrimary )下標(biāo)
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 設(shè)定文字方向。
//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;
//設(shè)置數(shù)據(jù)集為次要坐標(biāo)軸
se.AxisGroup := xlSecondary;
//設(shè)置次有坐標(biāo)軸說明( xlValue , xlSecondary )右標(biāo)
chart1.Chart.Axes(xlValue, xlSecondary).HasTitle := True;
chart1.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text := 'C';
總結(jié)
以上是生活随笔為你收集整理的Delphi 操作EXCEL折线图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 马尔可夫链基本定义
- 下一篇: 新浪下拉菜单案例淘宝服饰精品案例