Quantcast
Channel: PHPWord
Viewing all 450 articles
Browse latest View live

New Post: about phpword work in linux

$
0
0
Sounds like a permissions problem.

New Post: Way to specify location of a table?

$
0
0
Is there a way to move a table to a particular location on the page? I tried the following:

$styleTable = array('borderSize'=>6, 'left'=>3000, 'top'=>3000, 'borderColor'=>'006699', 'cellMargin'=>80);

It didn't change anything. I'm trying to place text at a specific location on the page, like writing to pdf docs allows you to do. I was planning on using a 1 cell table if it worked.

What I'd really like is a TextBox field. If it's not available and someone could give me some ideas on where to start, I could maybe hack one in if it's not too complex. The one complexity seems to be in the fact that it needs to be embedded in a drawing area, so you'd need a drawing area object as well.

Thanks.

New Post: about phpword work in linux

$
0
0
Yestoday night ,I put the code in my other linux OS, works ok !
then ,I think maybe it's the problem of the LAMP,
wait me set up new LAMP(It's company's Test machine),
wait a moment !!!。。。。

New Post: about phpword work in linux

New Post: Way to specify location of a table?

$
0
0
I tested a bit of positioning code. This is for a hard coded position, but it's easy enough to make the positions variables. It's inside _writeTable inside Base.php.
2419 and 1239 are 1.68 inches and .86 inches, so the multiplier at least in my doc seems to be about 1440 to convert from inches. I still want to add a TextBox field.
                if(!empty($tblStyle)) {
                    $objWriter->startElement('w:tblPr');
                        $objWriter->startElement('w:tblStyle');
                            $objWriter->writeAttribute('w:val', $tblStyle);
                        $objWriter->endElement();

                        $objWriter->startElement('w:tblpPr');
                        $objWriter->writeAttribute("w:leftFromText","180");
                        $objWriter->writeAttribute("w:rightFromText","180");
                        $objWriter->writeAttribute("w:vertAnchor","page");
                        $objWriter->writeAttribute("w:horzAnchor","page");
                        $objWriter->writeAttribute("w:tblpX","2419");
                        $objWriter->writeAttribute("w:tblpY","1239");
                        $objWriter->endElement();

                    $objWriter->endElement();
                }

New Post: Variable on Footer of Docx Template

$
0
0
This works excellently for me.

Anyone know how to add x number of headers without having to add each one?

New Post: Fatal error: Call to a member function loadTemplate() on a non-object in..

$
0
0
Hi every body,
I'm just discovering PHPWord which seems to suit OK my needs.

I try to load template.docx to see how it complies to my requirements, but every time i run the script i get the flwg error
Fatal error: Call to a member function loadTemplate() on a non-object in /volume1/web/PHPWord_0/PHPWordEssai.php on line 6
My script code is
<?php
// Include the PHPWord.php, all other classes were loaded by an autoloader
require_once 'PHPWord.php';
require_once 'PHPWord/Template.php';

$template = $PHPWord->loadTemplate('Examples/Template.docx');
$template->setValue('Name', 'Somebody someone');
$template->setValue('Street', 'Coming-Undone-Street 32');

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('../ComperioV1/dossierPerso/Template.docx');

// 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('Bonjour tout le monde!', array('name'=>'Times', 'size'=>32, 'bold'=>true));

// You can directly style your text by giving the addText function an array:
$section->addText('Hello world! I am formatted.', array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));

// If you often need the same style again you can create a user defined style to the word document
// and give the addText function the name of the style:
$PHPWord->addFontStyle('myOwnStyle', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle');

// You can also putthe appended element to local object an call functions like this:
$myTextElement = $section->addText('Hello World!');
//$myTextElement->setBold();
//$myTextElement->setName('Verdana');
//$myTextElement->setSize(22);

// At least write the document to webspace:
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('../ComperioV1/dossierPerso/helloWorld.docx');
?>
The file helloWorld.docx is generated OK.

Any help would appreciated

Many thks

New Post: Fatal error: Call to a member function loadTemplate() on a non-object in..

$
0
0
u must instantiate the object $PHPWord ;)
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('Examples/Template.docx');

New Post: Fatal error: Call to a member function loadTemplate() on a non-object in..

$
0
0
Many thks Mourad now i run into into an other trouble : the issue from the template is empty !

My code :
<?php
// Include the PHPWord.php, all other classes were loaded by an autoloader
require_once 'PHPWord.php';
require_once 'PHPWord/Template.php';

$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('Examples/Template.docx');
$template->setValue('Name', 'Somebody someone');
$template->setValue('Street', 'Coming-Undone-Street 32');
${Value1} = 101;
${Value2} = 102;
${Value3} = 103;
${Value4} = 104;
${Value5} = 105;
${Value6} = 106;
${Value7} = 107;
${Value8} = 1008;
${Value9} = 1000;
${Value10} = 10067;

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('../ComperioV1/dossierPerso/Template.docx');
?>
Why that ?

New Post: Problem w/ Template.docx

$
0
0
Hi every body,

The issue from the template is empty !
What's wrong with may code ?

My code :
<?php
// Include the PHPWord.php, all other classes were loaded by an autoloader
require_once 'PHPWord.php';
require_once 'PHPWord/Template.php';

$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('Examples/Template.docx');

$template->setValue('Value1', '101');
$template->setValue('Value2', '102');
$template->setValue('Value3', '103');
$template->setValue('Value4', '104');
$template->setValue('Value5', '105');
$template->setValue('Value6', '106');
$template->setValue('Value7', '107');
$template->setValue('Value8', '1008');
$template->setValue('Value9', '1000');
$template->setValue('Value10', '10067');

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('../ComperioV1/dossierPerso/Template.docx');
?>
Why that ?

Many thks for your advises !

New Post: Fatal error: Call to a member function loadTemplate() on a non-object in..

$
0
0
File names do not accept the ":", tried to change the shape of the time to H-i-s

New Post: Fatal error: Call to a member function loadTemplate() on a non-object in..

$
0
0
Just great, it perfectly works.
Thousands of thanks !!!!

New Post: How to solve this problem? Thank you

$
0
0
Warning: ZipArchive::getFromName() [ziparchive.getfromname]: Invalid or unitialized Zip object in D:\PHPnow\htdocs\tmgc\admin0\PHPWord\PHPWord\Template.php on line 74

Warning: ZipArchive::close() [ziparchive.close]: Invalid or unitialized Zip object in D:\PHPnow\htdocs\tmgc\admin0\PHPWord\PHPWord\Template.php on line 108

New Post: Problem w/ Template.docx

$
0
0
create template file "Template.docx" under the same directory of Template.php then edit the template file using microsoft word. you may put variable ${Value1}, ${Value2} .... to replace the value of setValue.

New Post: Problem w/ Template.docx

$
0
0
replace :

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('../ComperioV1/dossierPerso/Template.docx');

by :

$template->save('../ComperioV1/dossierPerso/Template.docx');

New Post: Problem w/ Template.docx

$
0
0
Thank U guys for good advises.

Now i would like to know if i can have several templates and i can i manage this ?

I issued, with MS Word, 3 templates (Templates1.docx, Templates2.docx, Templates2.docx) located in my site root folder. Any things worked out ...

Many thanks

New Post: How to divide long code into sections?

$
0
0
My word document is usually 5 pages sometimes it is longer. When I create my word document my code gets messy. I am trying to divide my code into sections but it doesn't seem to work. This is what I am doing.ing.
public function createProposalDocument($p) {
        require (__INCLUDE__ . 'PHPWord.php');
        $PHPWord = new PHPWord();
        ... // Rest of the codes it is very long
        
        // Insert Descriptions
        $this->insertProposalDocumentDescription($PHPWord, $myStyle)

        // Insert Types
        $this->insertProposalDocumentTypes($PHPWord, $myStyle)
}
Now my word document consists of sections. I would like to separate these sections by calling them different methods as shown above. For example I have a Descriptions section in my word document, in the createProposalDocument($p) method I would like to call $this->insertProposalDocumentDescription($PHPWord) I tried to add $section but it didn't insert into the word document. Here is the code
private function insertProposalDocumentDescription(PHPWord $PHPWord, $style) {
        $PHPWord->addTitleStyle(1, $style['title'], array('spaceAfter' => 0));
        $section = $PHPWord->createSection();
        return $section->addTitle("DESCRIPTIONSECTION");
    }
Could you please tell me why this is not working? Thanks

New Post: How to use MS Word built in style sheet with PHPWord template

$
0
0
Hi every body,

My query is in the subject;

Many Thks

New Post: Downloading doc file without saving file on server

$
0
0
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');

$filename = 'myfile.docx';//krishna

$objWriter->save($filename);

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
flush();
readfile($filename);
unlink($filename); // deletes the temporary file
exit;

New Post: Downloading doc file without saving file on server

$
0
0
Krishna-Winnou systems and services
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');

$filename = 'myfile.docx';//krishna

$objWriter->save($filename);

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
flush();
readfile($filename);
unlink($filename); // deletes the temporary file
exit;
Viewing all 450 articles
Browse latest View live