Word - копи. из 1 дока во 2-й ... хелп плс
От: ywlepak  
Дата: 06.02.07 10:30
Оценка:
Добрый день, снова вынужден обратиться за помощью

Необходимо из 2-х документов создавать 3-й, тоесть есть документы из которых нада собрать один, необходимо в один документ в конец, добавлять содержимое другого документа, причем несколько раз, тоесть в цыкле.

Вот нашл интересную статью касающуюся таких задачь — http://www.aspose.com/Wiki/default.aspx/Aspose.Words/ExSectionCombineDocuments.html

Но проблема в том что я что то несовсем пойму код, вот в этом примере(ниже) параметр Node insertAfterNode
Что это за тип такой — Node? мне вроде бы подходит подобное решение, но я непойму что за Node.

/// <summary>
/// Inserts content of the external document after the specified node.
/// Section breaks and section formatting of the inserted document are ignored.
/// The insertion is going on the story child level, so the specified node should be either paragraph or table.
/// </summary>
/// <param name="insertAfterNode">Node in the destination document after which the external document content should be inserted.
/// This node should be a story child level node (paragraph or table).</param>
/// <param name="srcDoc">Document to insert.</param>
public void InsertDocument(Node insertAfterNode, Document srcDoc)
{
        // We need to make sure that the specified node is either pargraph or table.
        if (!((insertAfterNode.NodeType == NodeType.Paragraph) || (insertAfterNode.NodeType == NodeType.Table)))
                throw new ArgumentException("The destination node should be either paragraph or table.");

        // We will be inserting into the parent of the destination paragraph.
        CompositeNode dstStory = insertAfterNode.ParentNode;

        // This object will be translating styles and lists during the import.
        NodeImporter importer = new NodeImporter(srcDoc, insertAfterNode.Document, ImportFormatMode.KeepSourceFormatting);

        // Loop through all sections in the source document.
        foreach (Section srcSection in srcDoc.Sections)
        {
                // Loop through all block level nodes (paragraphs and tables) in the body of the section.
                foreach (Node srcNode in srcSection.Body)
                {
                        // Do not insert node if it is a last empty paragarph in the section.
                        Paragraph para = srcNode as Paragraph;
                        if ((para != null) && para.IsEndOfSection && !para.HasChildNodes)
                                break;

                        // This creates a clone of the node, suitable for insertion into the destination document.
                        Node newNode = importer.ImportNode(srcNode, true);

                        // Insert new node after the reference node.
                        dstStory.InsertAfter(newNode, insertAfterNode);
                        insertAfterNode = newNode;
                }
        }
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.