{"id":1600,"date":"2013-03-08T12:36:22","date_gmt":"2013-03-08T12:36:22","guid":{"rendered":"https:\/\/copyright.lboro.ac.uk\/lorls\/?p=1600"},"modified":"2013-03-08T12:36:22","modified_gmt":"2013-03-08T12:36:22","slug":"exporting-to-word-document","status":"publish","type":"post","link":"https:\/\/blog.lboro.ac.uk\/lorls\/lorls\/exporting-to-word-document","title":{"rendered":"Exporting to a Word document"},"content":{"rendered":"<p>A new feature we have been working on in our development version of CLUMP, is the option for a list editor to export their reading list as a word document (specifically in a docx format). \u00a0This will be particularly beneficial for academics extract a copy of their list in a suitable format for inclusion into a course\/module handbook. A key requirement we had when developing it was that it should be easy to alter the styles used for headings, citations, notes, etc.<\/p>\n<p>As <a title=\"Extracting Harvard citations from Word documents\" href=\"https:\/\/blog.lboro.ac.uk\/lorls\/lorls\/extracting-harvard-citations-from-word-documents\">previously mentioned by Jon<\/a> the docx format is actually a zip file containing a group of XML files. \u00a0The text content of a document is stored within the &#8220;w:body&#8221; element\u00a0in the document.xml file. \u00a0The style details are stored in another of the xml files. \u00a0Styles and content being stored in separate files allows us to create a template.docx file in word, in which we define our styles. \u00a0The export script then takes this template and populates it with the actual content.<\/p>\n<p>When generating an export the script takes a copy of the template file, treats it as a zip file and extracts the document.xml file. \u00a0Then it replaces the contents of the w:body element in that extracted file with our own xml before overwriting the old document.xml with our new one. \u00a0Finally we then pass this docx file from the servers memory to the user. \u00a0All of this process is done in memory which avoids the overheads associated with generating and handling temporary files.<\/p>\n<p><a href=\"https:\/\/blog.lboro.ac.uk\/lorls2\/wp-content\/uploads\/sites\/3\/2013\/03\/wordExport1.png\" rel=\"lightbox[1600]\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1638\" alt=\"wordExport\" src=\"https:\/\/blog.lboro.ac.uk\/lorls2\/wp-content\/uploads\/sites\/3\/2013\/03\/wordExport1-1024x448.png\" width=\"640\" height=\"280\" srcset=\"https:\/\/blog.lboro.ac.uk\/lorls\/wp-content\/uploads\/sites\/3\/2013\/03\/wordExport1-1024x448.png 1024w, https:\/\/blog.lboro.ac.uk\/lorls\/wp-content\/uploads\/sites\/3\/2013\/03\/wordExport1-300x131.png 300w, https:\/\/blog.lboro.ac.uk\/lorls\/wp-content\/uploads\/sites\/3\/2013\/03\/wordExport1-900x394.png 900w, https:\/\/blog.lboro.ac.uk\/lorls\/wp-content\/uploads\/sites\/3\/2013\/03\/wordExport1.png 1071w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>To adjust the formatting of the styles in the template it can simply be loaded into Word, where the desired changes to the styles can be made. \u00a0After it has been saved it can be uploaded to the server to replace its existing template.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A new feature we have been working on in our development version of CLUMP, is the option for a list editor to export their reading list as a word document (specifically in a docx format). \u00a0This will be particularly beneficial for academics extract a copy of their list in a suitable format for inclusion into [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9,3],"tags":[32,93],"class_list":["post-1600","post","type-post","status-publish","format-standard","hentry","category-clump","category-lorls","tag-export","tag-word-documents","count-0","even alt","author-lbjlclboro-ac-uk","last"],"_links":{"self":[{"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/posts\/1600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/comments?post=1600"}],"version-history":[{"count":0,"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/posts\/1600\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/media?parent=1600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/categories?post=1600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lboro.ac.uk\/lorls\/wp-json\/wp\/v2\/tags?post=1600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}