c# 操作word
我现在有一个word模板,里面有两个表格的模板,需要用户填写内容的,我在需要填写的地方插入了书签,等用户填完之后,找到对应的书签,替换上原先用户填写的内容,还有一张表格也是需要用户填写的,但是这个表的行数是不确定的,所以我在这边也加了一个书签,但是我要删除原先的第二个表格,换成我自动生成的datatable里的数据。代码
string modalFileName = Server.MapPath("~") + "\\template\\FG\\Lixidan.doc";
string tmpFileName = Server.MapPath("~") + "\\temp\\" + Guid.NewGuid().ToString() + ".doc";
File.Copy(modalFileName, tmpFileName);
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = false;
object fileName = tmpFileName;
oDoc = oWord.Documents.Open(ref fileName,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
object oMarkName = "projectNo";
oDoc.Bookmarks.get_Item(ref oMarkName).Range.Text = bb.ProjectNo;
object oMarkName = "list";
//在这里加入根据datatable的数据集,在word中生成对应的表格数据。 oDoc.SaveAs(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
byte[] fileContent = File.ReadAllBytes(tmpFileName);
File.Delete(tmpFileName);
return fileContent;
请问高手这个应该怎么写呢。 --------------------编程问答-------------------- http://www.ocxt.com/
补充:.NET技术 , ASP.NET