Search for:
Jump to: 
Your Ad Here
Post new topic Reply to topic
Author Message
 Post subject: How to create a Word .doc file
PostPosted: Fri Jun 06, 2008 9:32 am 
Offline

Joined: Mon May 12, 2008 11:43 am
Posts: 307
Hi friends,

I have to create a word document using php, if anybody knows code in php for creating word document please send me


thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 06, 2008 9:54 am 
Offline

Joined: Mon Nov 12, 2007 10:12 am
Posts: 355
Hi venkat,

By using COM you can create the msword document in php
com working in windows os only

the following the sample code to crate simple word document

<?php
$word = new COM("word.application");
//To see the version of Microsoft Word, just use $word->Version
echo "I'm using MS Word {$word->Version}";
//It's better to keep Word invisible
$word->Visible = 0;
//Creating new document
$word->Documents->Add();
//Setting 2 inches margin on the both sides
$word->Selection->PageSetup->LeftMargin = '2"';
$word->Selection->PageSetup->RightMargin = '2"';
//Setup the font
$word->Selection->Font->Name = 'Verdana';
$word->Selection->Font->Size = 8;
//Write some text
$word->Selection->TypeText("Hello, universe!");
//Save the document as DOC file
$word->Documents[1]->SaveAs("C:\htdocs\hello2.doc");
// or use: $word->Documents[1]->SaveAs("C:htdocshello2.rtf",6); to save as RTF file
// or use: $word->Documents[1]->SaveAs("C:htdocshello2.htm",8); to save as HTML file
//And of course, quit Word
$word->quit();
$word->Release();
$word = null;
//Give the user a download link
echo '<a href="hello2.doc">Download file as .doc</a>';
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic    [ 2 posts ] 

1, 2, 3, 4, 5 ... 414
Recent topics  Replies   Views   Last post 
No new posts Add Slide Notes & Images as Logos in MS PowerPoint

by aspose » Tue May 21, 2013 4:03 am in Miscellaneous

0

3

Tue May 21, 2013 4:03 am

aspose View the latest post

No new posts Jquery ajax Pagination using php

by rajkumar » Tue Apr 19, 2011 11:14 am in Coding Repository

8

17608

Mon May 20, 2013 2:46 am

gfsdfg View the latest post

No new posts Ecommerce website development and website Design

by iweballey » Fri May 17, 2013 7:15 am in PHP-Code Help

0

247

Fri May 17, 2013 7:15 am

iweballey View the latest post

No new posts How to upgrade and migrate Joomal site

by mallikharjuna rao » Mon Jan 21, 2013 1:40 pm in Joomla

1

356

Thu May 16, 2013 9:53 am

sunitha12 View the latest post

No new posts Benefits of PHP

by hirephpexpert » Fri Sep 07, 2012 4:41 am in CakePHP

6

1593

Wed May 15, 2013 6:25 am

PrettyPrincesG View the latest post


Your Ad Here