4 Quick Steps to Export HTML Content to Doc in CakePHP

4 Quick Steps to Export HTML Content to Doc in CakePHP

HTML Content to Doc
< 1 Minute Read

Please follow these Simple & Quick Steps to Export your HTML Content to Doc in CakePHP:-

Step#1: Build the <HTML> content dynamically according to the requirement.

Step#2: Store the <HTML>content in a variable (Example: $ExportContent)

[code language=”html”]
$ExportContent = ‘<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml">


<h2>Mark sheet Table</h2>

<table style="width:100%" border="1" cellspacing="0">
<th>First Name</th>
<th>Last Name</th>
<td align="center">1</td>
<td align="right">94</td>
<td align="center">2</td>
<td align="right">80</td>


Step#3: After building the content pass appropriate headers to convert this <HTML>content to Doc

[code language=”html”]
header("Content-type: application/vnd.ms-word");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

Step#4: Provide file name to “Content-Disposition” header that we want to give the doc file name

[code language=”html”]
header("Content-Disposition: attachment; Filename=myfile.doc");
echo $ExportContent;

Did you find above tips useful? Feel free to drop in your suggestion…

Interested in anything on CakePHP? Let’s have a quick discussion.

, ,
Jyotibhusan Roul

A Product Specialist, Opensource & SaaS expert for Startups and Enterprise needs. Revenue growth strategist, Market Analyst including Leadership and Mentoring - A proud husband and father!

No Comments

Post A Comment

Exit pop up

Before You Go...!

Subscribe to Andolasoft Blog

Stay up to date with the latest techniques of web & mobile app development service tips and our SaaS and open source product news.
Holler Box