Support

Expand all | Collapse all

Velocity Report exporting to Word formatting

  • 1.  Velocity Report exporting to Word formatting

    Posted 01-27-2020 12:42
    I recently created a Velocity Report that correctly exports to HTML. I am now trying to modify the Report to export to Word instead. I am trying to specify the size and orientation of the page, but it is not changing anything. Here are some snippets of code that I think are relevant.
    <html xmlns:v=3D"urn:schemas-microsoft-com:vml"
    xmlns:o=3D"urn:schemas-microsoft-com:office:office"
    xmlns:w=3D"urn:schemas-microsoft-com:office:word"
    xmlns:x=3D"urn:schemas-microsoft-com:office:excel"
    xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml"
    xmlns=3D"http://www.w3.org/TR/REC-html40">
    
    	<meta name=3DProgId content=3DWord.Document>
    	<meta name=3DGenerator content=3D"Microsoft Word 15">
    	<meta name=3DOriginator content=3D"Microsoft Word 15">
    	
    	<head>
    		<title>Traceability Matrix</title>
    		<style>
    			body { 
    				font-family: sans-serif;
    			}
          
    			h1 { 
    				font-size: 1.5em;
    			}
          
    			table, th, td { 
    				border: 1px solid black;  
    				border-collapse: collapse;
    			}
    			
    			@page WordSection1 {
    				size:16.5in 11.7in;
    				mso-page-orientation:landscape;
    				margin:0.25in 0.25in 0.25in 0.25in;
    				mso-header-margin:.5in;
    				mso-footer-margin:.5in;
    				mso-paper-source:0;
    			}
    				
    			div.WordSection1 {
    				page:WordSection1;
    			}
    		</style>
    <div class=3DWordSection1>
    <h1>REQUIREMENT TRACEABILITY</h1>
    <table width="100%">
        ...​

    Also, I want the table rows to not break across pages. How could I specify this?

    Thanks,



    ------------------------------
    Jack
    ------------------------------


  • 2.  RE: Velocity Report exporting to Word formatting

    Posted 01-27-2020 13:14
    Hi Jack:

    I would first make a Word doc, to have the exact formatting specifications you need and then use that as your template to add the Velocity functionality to the HTML version. You have already done more than half the work. See this video: Velocity Reporting: Creating a basic template. This seems to be the general best practice I hear when dealing with formatting with Velocity.

    Best,

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------



  • 3.  RE: Velocity Report exporting to Word formatting

    Posted 01-27-2020 17:19
    Hi Chloe,

    Using your suggestion, I realised that I had placed the meta tags outside of the head instead of inside it. However, I am still getting the default A4 portrait document when exporting. Interesting enough, the template I created does not contain the 'mso-page-orientation:landscape' line anywhere, yet it still outputs as landscape. Otherwise, I'm not sure what else is missing from my report.

    ------------------------------
    Jack
    ------------------------------



  • 4.  RE: Velocity Report exporting to Word formatting

    Posted 10 days ago
    Edited by Michal Stanczyk 10 days ago
    I know it's old question, but googling this issue provides me to this topic. I was able to solve it by:
    - Saving Word document as HTML page
    - Finding proper settings for WordSection
    - Include section breaks in report


    Below you may find snippet from my report...

    ...
    <head>
        <style>
    	...
            @page WordSection1 {
                size: 8.5in 11.0in;
                margin: 1.0in .75in 1.0in 0.75in;
                mso-header-margin: .5in;
                mso-footer-margin: .2in;
                mso-title-page: yes;
                mso-header: h1;
                mso-footer: f1;
                mso-first-header: fh1;
                mso-first-footer: ff1;
                mso-paper-source: 0;
            }
    
            div.WordSection1 {
                page: WordSection1;
            }
    
            @page WordSection2 {
                size: 11.0in 8.5in;
                mso-page-orientation: landscape;
                margin: .75in 1.0in .75in 1.0in;
                mso-header-margin: .5in;
                mso-footer-margin: .2in;
                mso-title-page: yes;
                mso-header: h1;
                mso-footer: f1;
                mso-paper-source: 0;
            }
    
            div.WordSection2 {
                page: WordSection2;
            }
    
            @page WordSection3 {
                size: 8.5in 11.0in;
                margin: 1.0in .75in 1.0in .75in;
                mso-header-margin: .5in;
                mso-footer-margin: .2in;
                mso-title-page: yes;
                mso-header: h1;
                mso-footer: f1;
                mso-paper-source: 0;
            }
    
            div.WordSection3 {
                page: WordSection3;
            }
    	...
    	</style>
    </head>
    
    ...
    
    <div class=WordSection1>
      Portrait pages...
      
    <span><br clear=all style='page-break-before:always;mso-break-type:section-break'></span>
    <div class=WordSection2>
      Landscape pages
      
    <span><br clear=all style='page-break-before:always;mso-break-type:section-break'></span>
    <div class=WordSection3>
      Portrait pages again
     
    ...​


    ------------------------------
    Michal Stanczyk
    ------------------------------



  • 5.  RE: Velocity Report exporting to Word formatting

    Posted 10 days ago
    Edited by Chloe Elliott 10 days ago
    Michal:

    Thank you for taking the time to share your hard won technical solution with the Community! Take a peek at your profile, you have been awarded the Solver badge.

    Jama Community Badges

    ------------------------------
    Chloe Elliott
    Jama Software
    Portland OR
    ------------------------------