Excel图表控制问题(100分)

  • 主题发起人 主题发起人 wenweiya
  • 开始时间 开始时间
W

wenweiya

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
filename:string;
msexcel:variant;
msexcelworkbook:variant;
msexcelworksheet,achart:variant;
begin
filename:='C:/PO统计复件12.xls';
if filename<>'' then
begin
msexcel:=createoleobject('Excel.application');
msexcelworkbook:=msexcel.workbooks.open(filename);
msexcelworksheet:=msexcel.workbooks[1].worksheets[1];
msexcelworksheet.Activate;
achart:=msexcelworksheet.chartobjects.add(100,100,800,300);
achart.chart.charttype:=51;
achart.chart.SetSourceData('sheet1!$A$31:$B$47',2);
achart.chart.seriescollection.NewSeries;
achart.chart.seriescollection.NewSeries;
achart.chart.SeriesCollection[1].name:='坐标轴说明1';
achart.chart.SeriesCollection[1].values:='总!$B$31:$B$45';
achart.chart.seriescollection[2].name:='坐标轴说明2';
achart.chart.SeriesCollection[2].values:='总!$B$31:$B$45';
achart.Chart.HasTitle:=True;
achart.Chart.ChartTitle.Characters.Text:='Excle二维图';
achart.Chart.ChartTitle.Font.size:=16;
achart.Chart.PlotArea.Left:=10;
achart.Chart.PlotArea.Width:=423;
achart.Chart.PlotArea.Height:=908;
msexcel.visible:=true;
msexcelworksheet:=null;
msexcelworkbook:=null;
msexcel:=null;
end;
end;

achart.chart.SetSourceData('sheet1!$A$31:$B$47',2);
这些语句应该如何表示?
用achart.chart.seriescollection.add('=sheet1!R31C1:R44C1',true)这个语句执行后没有效果.望高手指点指点.
 
try
GetA;
except
A:=NA;
end;
 
xiammy:
能详细介绍一下吗?
谢谢.
 
msexcelworksheet.range[chr(65+ll)+inttostr(mm+2)].value用变量转存,先判断它的值
 
Application.Calculation 使用这个属性
Can be one of the following XlCalculation constants: xlCalculationAutomatic, xlCalculationManual, or xlCalculationSemiautomatic
Application.Calculation = xlCalculationManual //设置成手工计算
Calculate Method
Calculates all open workbooks, a specific worksheet in a workbook, or a specified range of cells on a worksheet, as shown in the following table.
Sheet1.Cells(x, y).Calculate //调用手工计算
 

Similar threads

I
回复
0
查看
610
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
843
import
I
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部