您的位置:首页 > 数据库

用C#把数据库中的记录按格式写入Word文档中。

2007-08-16 10:31 393 查看
用C#把数据库中的记录按格式写入Word文档中。

使用Word的COM组件。

Word._Application app = new Word.ApplicationClass();
app.Visible = false;

object nothing = System.Reflection.Missing.Value;
object temp = Environment.CurrentDirectory + @"/resume.doc"; //文档模板

Word.Document doc = app.Documents.Open(ref temp,ref nothing,ref nothing,ref nothing,
ref nothing,ref nothing,ref nothing, ref nothing, ref nothing,
ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing,ref nothing);//打开模板

doc.Tables[1].Cell(1,2).Range.Text = ""; // 给单元格添加内容

//给单元格插入图片
doc.Tables[1].Cell(1,5).Range.InlineShapes.AddPicture(ImgPath,ref nothing,ref nothing,ref nothing);

转自:http://blog.csdn.net/duwx/archive/2004/07/05/34188.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: