c#操作word,分页的问题~在线等~~~
我采用word模板,用数据库填充书签的方式做的,但现需要批量打印,需要在一个文档里面插入n页,我不知该怎么做。请大家帮帮忙~object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "endofdoc";
//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
//sql
string sql="select a.workid,a.year,a.pa_type,a.result1,a.result2,a.result3,a.result4,a.arrow,a.post,a.exaltation,a.abroad,a.others,a.m_result1,a.m_result2,a.m_result3,a.m_result4,b.cname,b.dept_id from members b,part4 a where a.workid=b.workid";
string Conn=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection myConn=new SqlConnection(Conn);
SqlCommand com=new SqlCommand(sql,myConn);
SqlDataAdapter da=new SqlDataAdapter(com);
DataSet ds=new DataSet();
da.Fill(ds);
object oTemplate = "c:\\1.dot";
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
.....
object oBookMark_l5 = "l5";
for(int i=0;i<ds.Tables[0].Rows.Count ;i++)
{
oDoc.Bookmarks.get_Item(ref oBookMark_dept).Range.Text = ds.Tables[0].Rows[i][17].ToString();
oDoc.Bookmarks.get_Item(ref oBookMark_z4).Range.Text = ds.Tables[0].Rows[i][15].ToString();
}
--------------------编程问答-------------------- 帮顶一下 --------------------编程问答-------------------- mark --------------------编程问答-------------------- 帮顶,我也需要 --------------------编程问答-------------------- 我也想做,顶。。。 --------------------编程问答-------------------- 我也想做,顶。。。 --------------------编程问答-------------------- object oPageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;//分页符
WordDoc.Characters.Last.InsertBreak(ref oPageBreak);
补充:.NET技术 , C#