2017-09-29 1 views
-1

doc 파일에서 나는 https://msdn.microsoft.com/en-us/library/ee413542(v=office.12).aspx 참조 문서의 헤더를 읽습니다. 헤더의 OOXML을 가져올 수 있지만 Office 365를 사용하여 온라인 단어에 삽입 할 수 없습니다. 온라인 문서 ooxml의 헤더를 삽입하는 데 도움이됩니다.전체 문서의 ooxml에서 officejs에 머리말과 꼬리말을 삽입하는 방법

감사합니다, 프라 빈

+0

에서 헤더를 삽입이 샘플을 발견. 머리글이 고정되어 있습니까? 아니면 추가 기능이 열리는 문서에 텍스트를 삽입 하시겠습니까? 어떤 방법으로 전화를 했습니까? –

답변

0

는 좀 더 정교한 Word 문서

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

이 샘플은 저에게 잘 작동하는 것 같습니다. –

관련 문제