This project is read-only.

Prompted for Download

Mar 12, 2011 at 10:01 PM

Hello, I'm having difficulty getting a downloaded word document to display any information. I have tried with both $objWriter setups.  Please help!  I have a deadline.  :(

include 'config/sf_config.php';
include 'functions/site_functions.php';
require_once 'functions/PHPWord.php';
require_once 'functions/PHPWord/Writer/Word2007.php';

$con = mysql_connect($sf_server,$sf_user,$sf_pass);

// Create a new PHPWord Object
$PHPWord = new PHPWord();

// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();

// After creating a section, you can append elements:
$section->addText('Hello world!');
/* Output to file */
$date = date("m-d-y");
//$objWriter = new PHPWord_Writer_Word2007($PHPWord);
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
header('Content-Type: application/');
header("Content-Disposition: attachment;filename=\"Awards_Booklet_$date.docx\"");
header('Cache-Control: max-age=0');

Mar 14, 2011 at 7:19 AM

replace code under /* output to file*/ with the one below..

/* output to file */
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');



hope this will help