火
火鸟
Unregistered / Unconfirmed
GUEST, unregistred user!
如何用d5+excel97对excel的数据表制作出一张图表?
我的代码如下:
procedure genchart;
var exapp:texcelapplication;
exsheet:texcelworksheet;
exbook:texcelworkbook;
begin
exapp:=texcelapplication.create(nil);
exbook:=texcelworkbook.create(nil);
exsheet:=texcelworksheet.create(nil);
try
exapp.Connect
exbook.connectto(exapp.workbooks.add(emptyparam,0));
exsheet.ConnectTo (exbook.worksheets.item[1] as _worksheet);
exapp.Visible [0]:=true;
...//这里是对单元格赋值的代码
exbook.Charts.Add(emptyparam,emptyparam,1,xlchart,1);//一运行到这,就出错误信息:缓冲器太小?
exbook.ActiveChart.HasTitle[1]:=true;
exbook.activechart.ChartTitle[1].Caption :='中华人民共和国';
exbook.activechart.charttitle[1].Font.name:='黑体';
exbook.activechart.charttitle[1].Font.color:=clred;
exbook.activechart.charttitle[1].Font.size:=20;
exbook.activechart.charttitle[1].Caption :='箱量分布';
exbook.activechart.SetSourceData(exsheet.range['a1','b7'],xlcolumns);
finally
exsheet.disconnect;
exbook.Disconnect
exapp.Disconnect
exsheet.free;
exbook.free;
exapp.free;
end;
end;
请教大狭,这段代码怎么写?
我的代码如下:
procedure genchart;
var exapp:texcelapplication;
exsheet:texcelworksheet;
exbook:texcelworkbook;
begin
exapp:=texcelapplication.create(nil);
exbook:=texcelworkbook.create(nil);
exsheet:=texcelworksheet.create(nil);
try
exapp.Connect
exbook.connectto(exapp.workbooks.add(emptyparam,0));
exsheet.ConnectTo (exbook.worksheets.item[1] as _worksheet);
exapp.Visible [0]:=true;
...//这里是对单元格赋值的代码
exbook.Charts.Add(emptyparam,emptyparam,1,xlchart,1);//一运行到这,就出错误信息:缓冲器太小?
exbook.ActiveChart.HasTitle[1]:=true;
exbook.activechart.ChartTitle[1].Caption :='中华人民共和国';
exbook.activechart.charttitle[1].Font.name:='黑体';
exbook.activechart.charttitle[1].Font.color:=clred;
exbook.activechart.charttitle[1].Font.size:=20;
exbook.activechart.charttitle[1].Caption :='箱量分布';
exbook.activechart.SetSourceData(exsheet.range['a1','b7'],xlcolumns);
finally
exsheet.disconnect;
exbook.Disconnect
exapp.Disconnect
exsheet.free;
exbook.free;
exapp.free;
end;
end;
请教大狭,这段代码怎么写?