打印本文 打印本文 关闭窗口 关闭窗口
用ASP.NET把数据库中的记录按格式写入Word文档中
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1338  更新时间:2009/6/9 2:35:15  文章录入:mintao  责任编辑:mintao

使用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);

 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=34188

打印本文 打印本文 关闭窗口 关闭窗口