Aspose.Word页的操作
一:某表格后面要复制n个表格:
int copytbs = buildnumlist.Count - 1;Aspose.Words.Tables.Table tb = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 1, true);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, 0, true);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);}
夜雨聆风