乐于分享
好东西不私藏

Aspose.Word页的操作

Aspose.Word页的操作

一:某表格后面要复制n个表格:

int copytbs = buildnumlist.Count - 1;Aspose.Words.Tables.Table tb = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 1true);for (int i = 0; i < copytbs; i++){    //创建段落    Paragraph lastParagraph = new Paragraph(doc);    //第一个表格末尾加段落    tb.ParentNode.InsertAfter(lastParagraph, tb);    //    Run pageBreakRun = new Run(doc, ControlChar.PageBreak);    lastParagraph.AppendChild(pageBreakRun);    Aspose.Words.Tables.Table cloneTable = (Aspose.Words.Tables.Table)tb.Clone(true);    //在文档末尾段落后面加入复制的表格    tb.ParentNode.InsertAfter(cloneTable, lastParagraph);    lastParagraph = new Aspose.Words.Paragraph(doc);}tb = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0true);for (int i = 0; i < copytbs; i++){    //创建段落    Paragraph lastParagraph = new Paragraph(doc);    //第一个表格末尾加段落    tb.ParentNode.InsertAfter(lastParagraph, tb);    //    Run pageBreakRun = new Run(doc, ControlChar.PageBreak);    lastParagraph.AppendChild(pageBreakRun);    Aspose.Words.Tables.Table cloneTable = (Aspose.Words.Tables.Table)tb.Clone(true);    //在文档末尾段落后面加入复制的表格    tb.ParentNode.InsertAfter(cloneTable, lastParagraph);    lastParagraph = new Aspose.Words.Paragraph(doc);}

二:一次性复制页:

Aspose.Words.Document docpage = AsposeWordHelper.GetDocPage(doc, 1);//先一次性复制表格页:for (int i = 1; i < buildnumlist.Count; i++){doc.AppendDocument(docpage, ImportFormatMode.KeepSourceFormatting);}