Generating Word In Landscape Mode

Hello I am trying to generate a word file.

presently i am using headers to generate word

    header("Pragma: no-cache");

    header("Expires: 0");

    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

    header("Cache-Control: private", false);

    header("Content-type: application/");

    header("Content-Disposition: attachment; filename=\"test.doc");

    header("Content-Transfer-Encoding: binary");

this works fine…

But i need it to be generated in landscape mode. does any body know how to do it?

It has nothing to do with HTTP headers, you need to do it in the library that’s generating the Word file.

@ Keith ,I am not using any library for generating word. i am just using this header

header("Content-type: application/") in the controller

for generating word.

please refer this

generating word with header

As it’s pointed on the link you gave above



[color="#222222"] [/color][color="#222222"][font="Verdana"] [/font][/color]

[color="#222222"][font="Verdana"][size="2"]Using the header method can be compared to something like renaming a .TXT file to a .DOC file… that one will be opened with word but it will never be a word document.[/size][/font][/color]


[/color][/size][/font][color="#222222"] [/color][font="Verdana"][size="2"][color="#222222"]So if you understand that, you will understand why with this method you cannot generate a landscape mode file.[/color][/size][/font]

ok. I understand! so What is to be done to generate a word in landscape mode? Can u please suggest a library to do this.? I just saw PHPOffice / PHPWord . Any other options ?

Yep, try out PHPWord. I’ve used PHPExcel a few times and it’s quite powerful, although hard to use. I suspect that PHPWord is much the same.

I do agree with Keith. Although I have no experience in PHPWord, I hope it has the same virtue as PHPExcel.

I think this wiki will serve you well when you want to use PHPWord with Yii.

How to use PHPExcel external library with Yii

Ok. thanks .