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

Created Unassigned: setValue() not working [57]

$
0
0
here is my php code:
```
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate(APPPATH.'files/test.docx');
$template->setValue('test1', 'hello');
$template->setValue('test2', 'whats');
$template->setValue('test3', 'up');
$template->setValue('test4', 'koby');
$template->setValue('test5', '!!!!!!');
$template->save('files/test.docx');
```

here is my word document text:

${test1}
${test2}
${test3}
${test4}
${test5}

The output word content:

hello
${test2}
${test3}
${test4}
${test5}

setValue(); only sets the value for the first line ${test1}

Any help would be great

Commented Unassigned: setValue() not working [57]

$
0
0
here is my php code:
```
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate(APPPATH.'files/test.docx');
$template->setValue('test1', 'hello');
$template->setValue('test2', 'whats');
$template->setValue('test3', 'up');
$template->setValue('test4', 'koby');
$template->setValue('test5', '!!!!!!');
$template->save('files/test.docx');
```

here is my word document text:

${test1}
${test2}
${test3}
${test4}
${test5}

The output word content:

hello
${test2}
${test3}
${test4}
${test5}

setValue(); only sets the value for the first line ${test1}

Any help would be great
Comments: The issue is with your template and not with the PHP code. If you open the template with a zip program and then view the document.xml file in the 'word' folder, you'll see the basic XML of the document. All of your template declarations are split in pieces, except #1. This is something I've run into with Word for years. You can safely delete everything between the pieces of your template variables. Here is an example of what I mean, with ${test5} being broken apart: ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14"> <w:body> <w:p w:rsidR="00AC49DC" w:rsidRDefault="00243DD6"> <w:r> <w:t>${test1}</w:t> </w:r> </w:p> <w:p w:rsidR="00243DD6" w:rsidRDefault="00243DD6"> <w:r> <w:t>${test2}</w:t> </w:r> </w:p> <w:p w:rsidR="00243DD6" w:rsidRDefault="00243DD6"> <w:r> <w:t>${test3}</w:t> </w:r> </w:p> <w:p w:rsidR="00243DD6" w:rsidRDefault="00243DD6"> <w:r> <w:t>${test4}</w:t> </w:r> </w:p> <w:p w:rsidR="00243DD6" w:rsidRDefault="00243DD6"> <w:r> <w:t>${</w:t> </w:r> <w:bookmarkStart w:id="0" w:name="_GoBack"/> <w:bookmarkEnd w:id="0"/> <w:r> <w:t>test5}</w:t> </w:r> </w:p> <w:sectPr w:rsidR="00243DD6" w:rsidSect="00C107D0"> <w:pgSz w:w="12240" w:h="15840" w:code="1"/> <w:pgMar w:top="907" w:right="907" w:bottom="907" w:left="907" w:header="720" w:footer="720" w:gutter="0"/> <w:cols w:space="720"/> <w:docGrid w:linePitch="272"/> </w:sectPr> </w:body> </w:document> ``` Adam

New Post: setValue() broken

$
0
0
You need to type "${test1} ${test2} ${test3} ${test4} ${test5}" on your template manually, not copy/paste. Encountered this just recently. Hope this helps.

New Post: add checkbox?

$
0
0
Hi everyone,

I am creating a .docx file automaticaly using PHPWord have several tables. I need add some checkboxes normally i put it from developer menu. How can i add checkboxes using PHPWord?

New Post: What are all the available file extensions?

$
0
0
I am curious about all the different file extensions PhpWord has to offer. If any one has a list of them it would be greatly appreciated.

New Post: addlistitem in a table?

$
0
0
Hi,

I have the same issue to add a List Item in an Table Cell. Has anybody an Idee?

Thanks!

Kind regards,
Buschdieb

New Post: Colspan and Rowspan

$
0
0
does it still work ? i edited this two files like u said in the post but i am not able to get it to work... my anyone can send me his edited cell.php and base.php ?

in my do_word.php i tryed this.
$styleCell = array('gridSpan' => 2);


$table = $section->addTable();
$table->addRow();
$table->addCell(1500, $styleCell)->addText('Test Colspan');
$table->addRow();
$table->addCell(750)->addText('Test');
$table->addCell(750)->addText('Test');
but nothing happends...
in the second row there are 2 cells

New Post: add checkbox?


New Post: Colspan and Rowspan

$
0
0
Colspan works great but i couldnT figure out how to make rowspan work

New Post: how to properly handle UTF-8 ? (UTF8)

$
0
0
@sauronpl Thank you soooo much you saved me a lot of time!! it worked for me using templates

New Post: Colspan and Rowspan

$
0
0
Finally i figured out to use rowspan and code i used is below for who can't use it.
   // Define table style arrays
$styleTable = array('cellMarginLeft'=>110, 'cellMarginRight'=>110, 'borderSize'=>1);
$styleCellMerged = array('valign'=>'center', 'gridSpan' => 2);
$styleCellBTLR1 = array('vMerge' => 'restart', 'valign'=>'center', 'textDirection'=>PHPWord_Style_Cell::TEXT_DIR_BTLR);
$styleCellBTLR2 = array('vMerge' => 'fusion', 'valign'=>'center', 'textDirection'=>PHPWord_Style_Cell::TEXT_DIR_BTLR);

// Add table style
$PHPWord->addTableStyle('tbl13', $styleTable);
// Add table
$table13 = $section->addTable('tbl13');
// Add rows
$PHPWord->addFontStyle('rStyle14', array('size'=>10));  
$PHPWord->addFontStyle('rStyle14Bold', array('bold'=>true, 'size'=>10));
$PHPWord->addFontStyle('rStyle14Italic', array('italic'=>true, 'size'=>8));
$PHPWord->addParagraphStyle('pStyle24', array('align'=>'left', 'spaceAfter'=>0));
$PHPWord->addParagraphStyle('pStyle24Header', array('align'=>'center', 'spaceAfter'=>0));
$PHPWord->addParagraphStyle('pStyle24Merged', array('align'=>'center', 'spaceAfter'=>0));

$table13->addRow(396);  
$table13->addCell(9810, $styleCellMerged)->addText('DENETİM SONUCUNA İLİŞKİN DENETİM EKİBİNİN TAVSİYE KARARI', 'rStyle14', 'pStyle24Merged');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR1)->addText('İLK{brbr}BEGELENDİRME', 'rStyle14', 'pStyle24Header');
$table13->addCell(7010, $styleCell)->addText('${box} Sertifika verilmesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Uygunsuzlukların doküman bazında takibi yapılarak, eksiklerin tamamlanması halinde sertifika verilmesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Uygunsuzlukların takibinin yerinde denetimle yapılması ve eksiklerin tamamlanması halinde sertifika verilmesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Sertifika verilmemesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR1)->addText('GÖZETİM', 'rStyle14', 'pStyle24Header');
$table13->addCell(7010, $styleCell)->addText('Belgelendirmenin devamı', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Uygunsuzlukların doküman bazında takibi yapılarak, eksiklerin tamamlanması halinde belgelendirmenin devamı', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Uygunsuzlukların takibinin yerinde denetimle yapılması ve eksiklerin tamamlanması halinde belgelendirmenin devamı', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Belgelendirmenin askıya alınması', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Belgelendirmenin iptali', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR1)->addText('YENİDEN{brbr}BELGELENDİRME', 'rStyle14', 'pStyle24Header');
$table13->addCell(7010, $styleCell)->addText('Belgelendirmenin yenilenmesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Uygunsuzlukların doküman bazında takibi yapılarak, eksiklerin tamamlanması halinde belgelendirmenin yenilenmesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Uygunsuzlukların takibinin yerinde denetimle yapılması ve eksiklerin tamamlanması halinde belgelendirmenin yenilenmesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCellBTLR2);
$table13->addCell(7010, $styleCell)->addText('Belgelendirmenin yenilenmemesi', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCell)->addText(' ', 'rStyle14', 'pStyle24');
$table13->addCell(7010, $styleCell)->addText('Kapsam değişikliği yapılması', 'rStyle14', 'pStyle24');

$table13->addRow(396);  
$table13->addCell(2800, $styleCell)->addText(' ', 'rStyle14', 'pStyle24');
$table13->addCell(7010, $styleCell)->addText('Adres değişikliği yapılması', 'rStyle14', 'pStyle24');

New Post: Unable to Open PHPWord Documents on Mac Computers and iPads

$
0
0
I can't seem to open PHPWord generated documents on Mac computers. I have no problem opening them on PCs. Any idea why?

New Post: How to output the docx file after using the template

$
0
0
I was facing same issue - Please check your image type and test with new image.

Created Unassigned: Paragraph "justify" not working [58]

$
0
0
here my php code

$PHPWord = new PHPWord();

$section = $PHPWord->createSection();

$PHPWord->addParagraphStyle('pJustify', array('align' => 'justify', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0));
$section->addText('I am styled by two style definitions.', 'pJustify', 'pJustify');
$section->addText('I have only a paragraph style definition.', null, 'pJustify')

.......
but when i open word file this warning below image


New Post: Colspan and Rowspan

$
0
0
Need to set below code in Style/Cell.php constructor .
    } elseif($key == '_gridSpan') {
        $this->setGridSpan($value);
    } elseif($key == '_vMerge') {
        $this->setVMerge($value);
    } else {
and below functions
public function setGridSpan($pValue = null) 
{ 
   $this->_gridSpan = $pValue; 
} 
public function getGridSpan() 
{ 
   return $this->_gridSpan; 
}
public function setVMerge($pValue = null) 
{ 
   $this->_vMerge = $pValue; 
} 
public function getVMerge() 
{ 
   return $this->_vMerge; 
}

New Post: How to merge several files into one docx?

$
0
0
how to merge several files into one docx?
I have tried:
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$document = $PHPWord->loadTemplate('dir1/file1.docx');
$section->addPageBreak();
$document = $PHPWord->loadTemplate('dir1/file2.docx');
$document->save('dir2/test.docx');
but saves only the last

Commented Issue: problem with template [15]

$
0
0
I have a problem using the template function.

The code of my PHP script is:



require_once 'Classes/PHPWord.php';

$PHPWord = new PHPWord();

$document = $PHPWord->loadTemplate($Template);

$document->setValue('Value1', $Cliente.' ('.$CodiceFiscale.')');
$document->setValue('Value2', $Classificazione1);
$document->setValue('Value3', $Classificazione2);
$document->setValue('Value4', $Classificazione3);
$document->setValue('Value5', $PianoFabbisogni1);
$document->setValue('Value6', $PianoFabbisogni2);
$document->setValue('Value7', $NotePianoFabbisogni);
$document->setValue('Value8', $ContrattoFornitura1);
$document->setValue('Value9', $ContrattoFornitura2);
$document->setValue('Value10', $NoteContrattoFornitura);
$document->setValue('Value11', $AltraDocumentazione);
$document->setValue('Value12', $Intranet1);
$document->setValue('Value13', $Infranet1);
$document->setValue('Value14', $Internet1);
$document->setValue('Value15', $TipologiaServizi);
$document->setValue('Value16', $CanoneAnnuo);
$document->setValue('Value17', $UnaTantum);
$document->setValue('Value18', $NumeroServizi);
$document->setValue('Value19', $DataContratto);
$document->setValue('Value20', $Difformita1);
$document->setValue('Value21', $Difformita2);
$document->setValue('Value22', $AltreNote);
$document->setValue('Value23', $RisultatoRiesame1);
$document->setValue('Value24', $RisultatoRiesame2);
$document->setValue('Value25', $Funzione1);
$document->setValue('Value26', $Data1);
$document->setValue('Value27', $NomeCognome1);
$document->setValue('Value28', $Funzione2);
$document->setValue('Value29', $Data2);
$document->setValue('Value30', $NomeCognome2);

$document->save($NomeFile);



I've modified the word template and now the values are from "Value1" to "Value30".

The output file is saved but, when I open that, only values from 1 to 10 are modified.

Please.....help me

Comments: To get something like this $document->setValue('Value3', $Classificazione2); to work. In your word document (not template file - no need) and filling in the values you must type straight. ${Value3}. If you are like me and you do something like ${}, come back to fill the Value3, it would not work. just type ${Value3} continuously, without using the back space, back space has a way of messing up the variable.

New Post: Template setValue doesn't work proberly

$
0
0
To get something like this
$document->setValue('Value3', $Classificazione2); to work.

In your word document (not template file - no need) and filling in the values
you must type straight. ${Value3}.

If you are like me and you do something like ${}, come back to fill the Value3, it would not work.
just type ${Value3} continuously, without using the back space, back space has a way of messing up the variable.

New Post: I can't install PHPWORD on my website and make a little script working...

$
0
0
Hello World!,

I don't understand how I have to install PHPWORLD on my website, neither how to make a first php-script that could work... Can somebody give me the 'basic' explanations?...

What have I to do with the 'zip'-file? Where and how (Fillezilla?) have I to place this files on my website (on the directory 'www'? on the directory 'libraries', of on an other directory?).

Can you also give me the first lines of a workable script? What are the first sentences of that script? ('include "PHPWORD"'? or must that be 'include \libraries\PHPWORD\phpword.php', or something like that?...

You see, I miss the essentiels to make working PHPWORD...

Many thanks in advance for your reply, World!...

Created Unassigned: How to use UTF-8 [59]

$
0
0
Hello,

I'd like to use UTF-8 with phpword ... but
```
header('content-type: text/html; charset: utf-8');
```
doesn't work ...
How can I use it (for the french language like 'é' or 'à' ...) ?
Thanks


Viewing all 450 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>