I've searched high and low and played around for a couple of hours, but I can't seem to figure out if there's a way to format the output to Word. For example, I don't want a table format. I want to display the fields:

<strong>Title</strong><br>
Body
<a href="%link">Read the original.</a>

Is there an interface tool for this? Is there a way to hack it? If neither is possible, could I make a feature request.

Thanks for your thoughts and assistance!

Comments

steven jones’s picture

Status: Active » Fixed

You will need to override the templates for building the word file export. Have a look at the theming guide for how to override templates.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

seanenroute’s picture

Issue summary: View changes

The simplest way to do this is to grab all your fields in the View and set their display status to Exclude. Then bring all your fields into a single Global Text Field using tokens. That way you only have one column.

Alternatively if you want to bring a full page into the view use the "Content: Rendered Node" views field.

Bonus info! If you want to bring CSS into the Word doc (and you know you want to) you have to add a <style> markup to the views-data-export-doc-header.tpl template between the <head> tags.

ex.

<head>
<style>
p {color: blue;}
</style>
</head>
kristofferrom’s picture

@Seanenroute, great tip about the 'rendered...' field (which is now called 'Rendered Content' for future reference.

Could you also provide a tip to get the width of each node/field span maximum 1. a4 page in the Doc export?

seanenroute’s picture

@kristofferrom, the current version of Window docs is basically a fancied up html page. So as long as you apply html coding (styles not css) to keep things in check you should be okay. Paragraphs and such should automatically word wrap for the page.

The online resource I found most useful was http://sebsauvage.net/wiki/doku.php?id=word_document_generation - this got me going in the right direction.

Their code for output in A4 format was:

<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>
<head><title>Microsoft Office HTML Example</title>
<style> <!-- 
@page
{
    size: 21cm 29.7cm;  /* A4 */
    margin: 2cm 2cm 2cm 2cm; /* Margins: 2 cm on each side */
    mso-page-orientation: portrait;  
}
--></style>
kristofferrom’s picture

@Seanenroute. Great thanks. Can I persuade you to tell me exactly where to add this code?

seanenroute’s picture

You add it right to the doc template file itself. It can be found in the theme folder of the the views_data_export module. In the case of the doc file you are looking for "views-data-export-doc-header.tpl".

Make a copy of that file and add it to your theme templates folder. Add the style code and it'll override the original doc template.

delacosta456’s picture

hi
nice thanks .. but look like default views class are stripped .. so i am a littleconfuse on how to control Th,Td etc of specific field specific field is