{"id":267,"date":"2014-05-12T11:31:43","date_gmt":"2014-05-12T01:31:43","guid":{"rendered":"http:\/\/www.docx4java.org\/blog\/?p=267"},"modified":"2014-05-12T11:31:43","modified_gmt":"2014-05-12T01:31:43","slug":"sql-server-reporting-services-ssrs-emits-dodgy-word-docx-documents","status":"publish","type":"post","link":"https:\/\/www.docx4java.org\/blog\/2014\/05\/sql-server-reporting-services-ssrs-emits-dodgy-word-docx-documents\/","title":{"rendered":"SQL Server Reporting Services (SSRS) emits dodgy Word docx documents"},"content":{"rendered":"<p>By now we&#8217;re used to products which emit docx files which are umm, not .. quite .. right.<\/p>\n<p>But its more noteworthy when the product in question is from Microsoft. \u00a0After all, its their file format (ECMA etc standardisation notwithstanding).<\/p>\n<p>The product in question here is SQL Server Reporting Services 2012 and its\u00a0<a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd283105.aspx\">Word export<\/a>.<\/p>\n<p>It seems they didn&#8217;t bother to validate their documents (eg using Open XML SDK 2.0 Productivity Tool):<\/p>\n<p><a href=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_sectPr1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-269\" title=\"ssrs_invalid_sectPr\" src=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_sectPr1.png\" alt=\"\" width=\"1309\" height=\"235\" srcset=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_sectPr1.png 1309w, https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_sectPr1-300x53.png 300w, https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_sectPr1-1024x183.png 1024w\" sizes=\"auto, (max-width: 1309px) 100vw, 1309px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_sectPr1.png\"><\/a>Apparently <a href=\"http:\/\/connect.microsoft.com\/SQLServer\/feedback\/details\/614558\/word-export-sets-margin-top-margin-bottom-to-0mm\">there&#8217;s a reason<\/a> for this:<\/p>\n<blockquote>\n<div id=\"_mcePaste\">&#8220;Word and SSRS treat page headers and footers differently. Word actually positions them inside the page margins, whereas SSRS positions them inside the area that the margins surround. As a result, in Word, the page margins do not control the distance between the top edge of the page and that of the page header (or similarly for the page footer). Instead, Word has separate &#8220;Header from Top&#8221; and &#8220;Footer from Bottom&#8221; properties to control those distances. Since RDL does not have equivalent properties, the Word renderer sets these properties<strong> to zero<\/strong>.&#8221;<\/div>\n<\/blockquote>\n<div id=\"_mcePaste\"><\/div>\n<div>But the problem is that it is actually setting them to blank (as opposed to zero), which is not valid.<\/div>\n<p>Another problem:<\/p>\n<p><a href=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_rPr_sz.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-270\" title=\"ssrs_invalid_rPr_sz\" src=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_rPr_sz.png\" alt=\"\" width=\"1268\" height=\"106\" srcset=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_rPr_sz.png 1268w, https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_rPr_sz-300x25.png 300w, https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_invalid_rPr_sz-1024x85.png 1024w\" sizes=\"auto, (max-width: 1268px) 100vw, 1268px\" \/><\/a><\/p>\n<p>JAXB doesn&#8217;t like invalid documents, so docx4j has to fix these sorts of things before it can construct a content model. \u00a0(Maybe that&#8217;s why SSRS calls it Word export, not docx export:- they just check Word can open the document, then call it job done)<\/p>\n<p>There are other problems with SSRS docx which the Productivity Tool doesn&#8217;t report.<\/p>\n<p>Take a look at the styles part:<\/p>\n<p><a href=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_dodgy_style.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-271\" title=\"ssrs_dodgy_style\" src=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_dodgy_style.png\" alt=\"\" width=\"337\" height=\"283\" srcset=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_dodgy_style.png 337w, https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_dodgy_style-300x251.png 300w\" sizes=\"auto, (max-width: 337px) 100vw, 337px\" \/><\/a><\/p>\n<p>Notice anything wrong? \u00a0It&#8217;d be better if the EmptyCellLayoutStyle had @w:styleId and @w:type, like so:<\/p>\n<p><a href=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_fixed_style.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-272\" title=\"ssrs_fixed_style\" src=\"http:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_fixed_style.png\" alt=\"\" width=\"467\" height=\"115\" srcset=\"https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_fixed_style.png 467w, https:\/\/www.docx4java.org\/blog\/wp-content\/uploads\/2014\/05\/ssrs_fixed_style-300x73.png 300w\" sizes=\"auto, (max-width: 467px) 100vw, 467px\" \/><\/a><\/p>\n<p>It&#8217;d also be nice if it defined the &#8220;Normal&#8221; style it is basedOn!<\/p>\n<p>docx4j and other consumers could\/should detect such problems and degrade gracefully in the face of them, but Microsoft (of all companies!) should exercise better quality control.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By now we&#8217;re used to products which emit docx files which are umm, not .. quite .. right. But its more noteworthy when the product in question is from Microsoft. \u00a0After all, its their file format (ECMA etc standardisation notwithstanding). The product in question here is SQL Server Reporting Services 2012 and its\u00a0Word export. It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[97,96,71,95,99],"tags":[87,88],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-docx","category-jaxb","category-microsoft-word","category-ooxml","category-openxml","tag-ssrs","tag-validation"],"_links":{"self":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/comments?post=267"}],"version-history":[{"count":2,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/267\/revisions\/274"}],"wp:attachment":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/media?parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/categories?post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/tags?post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}