XML


link - github.com/OfficeDev/Word-Add-in-Load-and-write-Open-XML


Range.insertOoxml

    var ooxmlText = "<w:p xmlns:w='http://schemas.microsoft.com/office/word/2003/wordml'>" +  
    "<w:r><w:rPr><w:b/><w:b-cs/><w:color w:val='FF0000'/><w:sz w:val='28'/><w:sz-cs w:val='28'/>" +
    "</w:rPr><w:t>Hello world (this should be bold, red, size 14).</w:t></w:r></w:p>";
    var range = context.document.getSelection();
    range.insertOoxml(ooxmlText, Word.InsertLocation.end);

range.insertOoxml(" XML CODE", Word.InsertLocation.start); 

<pkg:package xmlns:pkg='http://schemas.microsoft.com/office/2006/xmlPackage'>

<pkg:part pkg:name='/_rels/.rels'
pkg:contentType='application/vnd.openxmlformats-package.relationships+xml'
pkg:padding='512'>

<pkg:xmlData>
<Relationships xmlns='http://schemas.openxmlformats.org/package/2006/relationships'>

<Relationship
Id='rId1'
Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument' Target='word/document.xml'/>

</Relationships>

</pkg:xmlData>
</pkg:part>

<pkg:part pkg:name='/word/document.xml'
pkg:contentType='application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'>

<pkg:xmlData>
<w:document xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' >
<w:body>
<w:p><w:pPr><w:spacing w:before='360' w:after='0' w:line='480' w:lineRule='auto'/>
<w:rPr><w:color w:val='70AD47' w:themeColor='accent6'/><w:sz w:val='28'/></w:rPr></w:pPr>
<w:r><w:rPr><w:color w:val='70AD47' w:themeColor='accent6'/><w:sz w:val='28'/></w:rPr>
<w:t>This text has formatting directly applied to achieve its font size, color, line spacing, and paragraph spacing.</w:t></w:r></w:p>
</w:body>
</w:document>
</pkg:xmlData>

</pkg:part>
</pkg:package>


Range.getOoxml




© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrev