怎样往word中插入图表

wgzaaa 2007-09-11 02:44:12
是插入图表,而不是图片,要求能选择图表类型,能介绍对图表中数据及其它对象的控制更好,多谢了,所在问题解决另开贴加分,我用delphi7,office2000,(office2003也可),各位高手帮忙!
...全文
10706 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wgzaaa 2007-10-09
  • 打赏
  • 举报
回复
多谢三位
pengxuan 2007-09-22
  • 打赏
  • 举报
回复
使用Delphi 控制Excle二维图
在Form中分别放入ExcelApplication, ExcelWorkbook和ExcelWorksheet
var asheet1,achart, range:variant;

1)选择当第一个工作薄第一个工作表
asheet1:=ExcelApplication1.Workbooks[1].Worksheets[1];

2)增加一个二维图
achart:=asheet1.chartobjects.add(100,100,200,200);

3)选择二维图的形态
achart.chart.charttype:=4;

4)给二维图赋值
series:=achart.chart.seriescollection;
range:=sheet1!r2c3:r3c9;
series.add(range,true);

5)加上二维图的标题
achart.Chart.HasTitle:=True;
achart.Chart.ChartTitle.Characters.Text:=’ Excle二维图’

6)改变二维图的标题字体大小
achart.Chart.ChartTitle.Font.size:=6;

7)给二维图加下标说明
achart.Chart.Axes(xlCategory, xlPrimary).HasTitle := True;
achart.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text := '下标说明';

8)给二维图加左标说明
achart.Chart.Axes(xlValue, xlPrimary).HasTitle := True;
achart.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := '左标说明';

9)给二维图加右标说明
achart.Chart.Axes(xlValue, xlSecondary).HasTitle := True;
achart.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text := '右标说明';

10)改变二维图的显示区大小
achart.Chart.PlotArea.Left := 5;
achart.Chart.PlotArea.Width := 223;
achart.Chart.PlotArea.Height := 108;

11)给二维图坐标轴加上说明
achart.chart.seriescollection[1].NAME:='坐标轴说明';


pengxuan 2007-09-22
  • 打赏
  • 举报
回复
hsmserver 的方法没有问题,是不是
word:=createoleobject( 'word.application ');
worddoc.Shapes.AddOleObject( 'MSGraph.Chart.8 ');
这两句里的字符串空格你没有去掉才出的错,
建议用Excel的图表
wgzaaa 2007-09-21
  • 打赏
  • 举报
回复
感谢两位,问题还是没解决
wgzaaa 2007-09-14
  • 打赏
  • 举报
回复
再顶顶
wgzaaa 2007-09-12
  • 打赏
  • 举报
回复
谢谢楼上老大,这样的话报如下错误,你说用excel是说用delphi控制excel吗?望不吝赐教
[Error] inquiry1.pas(557): Types of actual and formal var parameters must be identical
我的语句:worddoc.Shapes.AddOleObject('MSGraph.Chart.8');
may_05 2007-09-12
  • 打赏
  • 举报
回复
可能是Word版本问题,我的2003版本用雨晖的语句没有任何问题

hsmserver 2007-09-11
  • 打赏
  • 举报
回复


uses
comobj;

var
word,worddoc:variant;
begin
word:=createoleobject('word.application');
word.visible:=true;
worddoc:=word.Documents.Add;
worddoc.Shapes.AddOleObject('MSGraph.Chart.8');
end;
不过图表不好控制,这样的话没有意义,不如用excel

5,927

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧