Answer the question
In order to leave comments, you need to log in
Yii Specify header and numbering when exporting to DOC?
Hello. To export data to DOC, I do this in a similar way:
View:
echo CHtml::link('Generate Word', array('Calculator/generateWord'));
Controller:
public function actionGenerateWord() {
$var = "Hello World!";
$div = $this->renderPartial('graphs/word', array('var'=>$var), true);
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/vnd.ms-word");
header("Content-Disposition: attachment; filename=\"test.doc");
header("Content-Transfer-Encoding: binary");
ob_clean();
flush();
echo $div;
Yii::app()->end();
}
Rendered view:
<table>
<tr>
<td>This is just a test</td>
</tr>
<tr>
<td><?php echo $var; ?></td>
</tr>
</table>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question