2017-09-29 3 views
-1

Von einer Dokumentendatei lese ich Kopfzeile des Dokuments von https://msdn.microsoft.com/en-us/library/ee413542(v=office.12).aspx Referenz. Ich bin in der Lage, die OOXML Header zu bekommen, aber ich bin nicht in der Lage, es in meinem Online-Wort mit Office 365 Add-in einfügen. Bitte helfen Sie mir, Header aus dem vollständigen Dokument ooxml in Online-Word einfügen.Wie Kopfzeile und Fußzeile in officejs von ooxml des vollständigen Dokuments einfügen

Grüße, Praveen

+0

Können Sie etwas mehr erarbeiten einzufügen. Ist der Header behoben oder möchten Sie Text in ein Dokument einfügen, in dem Ihr Add-In geöffnet ist? Welche Methode hast du versucht anzurufen? –

Antwort

0

diese Probe gefunden, die Header in dem Word-Dokument

function insertHeader() { 
    Word.run(function (context) { 
     var myHeader = context.document.sections.getFirst() 
      .getHeader("primary").insertText("This is a header", "start"); 
     return context.sync(); 
    }).catch(function(error) { 
     console.log(error); 
    }); 
} 

    function insertFooter() { 

    Word.run(function (ctx) { 

     // Create a proxy collection for the sections collection. 
     var mySections = ctx.document.sections; 

     // Queue a command to load style property of the sections. 
     ctx.load(mySections, 'body/style'); 

     // Synchronize the document state by executing the queued commands, 
     // and returning a promise to indicate task completion. 
     return ctx.sync().then(function() { 

      // Get the primary footer of the first section and create 
      // a proxy Body object for the footer. 
      var myFooter = mySections.items[0].getFooter("primary"); 

      // Queue a command to insert a paragraph at the end of the footer. 
      myFooter.insertParagraph("Confidential", "end"); 

      // Queue a command to insert a line break at the end of the footer. 
      myFooter.insertBreak("line", "end"); 
     }) 
     // Synchronize the document state by executing the queued commands. 
     .then(ctx.sync) 
     .then(function() { 
      handleSuccess(); 
     }) 
     .catch(function (error) { 
      handleError(error); 
     }) 
    }); 
} 
+0

Diese Probe scheint für mich gut zu funktionieren. –

Verwandte Themen