The following PHP code to export content in MS Word document.
<?php
$doc_body ="
<h1>PHP - Export Content to MS Word document</h1>
<p>This is a test.<p>
<p>This is a test.<p>
";
?>
<form name="proposal_form" action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post"">
<input type="submit" name="submit_docs" value="Export as MS Word" class="input-button" />
</form>
<?php
if(isset($_POST['submit_docs'])){
header("Content-Type: application/vnd.msword");
header("Expires: 0");//no-cache
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");//no-cache
header("content-disposition: attachment;filename=sampleword.doc");
}
echo "<html>";
echo "$doc_body";
echo "</html>";
?>
video:Export Content to MS Word document
Thanks for this code which is going to save my life. Please, how do you create a page break
ReplyDeleteJiansen Lu'S Computing Blog: Php - Export Content To Ms Word Document >>>>> Download Now
Delete>>>>> Download Full
Jiansen Lu'S Computing Blog: Php - Export Content To Ms Word Document >>>>> Download LINK
>>>>> Download Now
Jiansen Lu'S Computing Blog: Php - Export Content To Ms Word Document >>>>> Download Full
>>>>> Download LINK 6J
How can I style the document?
ReplyDeletethanks for the code, but i gonna to how some sql query in the doc_body, how is the syntax to write php code inside the doc_body?
ReplyDeletewhen i click export button word doc generated and this should be attached to email. is it possible ?
ReplyDelete
ReplyDeleteA great content and very much useful to the visitors. Looking for more updates in future.
Selenium Training in Chennai
This comment has been removed by the author.
ReplyDeletei wrote the same code. when i download the file on mobile it is working fine but that downloaded file is shown as currepted file and not open
ReplyDeletethank you so much
ReplyDeleteGreat job!!!! ty very much
ReplyDelete