>> We recommend you to run the included examples to check if the library is working fine.
In examples/LayoutAndGeneral/importStyles/sample_1.php, the file works fine as written:
$docx->importStyles('../../files/TemplateStyles.docx', 'merge', array('crazyStyle'));
The file has the comment:
//You may also import a complete XML style sheet by
//$docx->importStyles('../files/TemplateStyles.docx', $type= 'replace');
I replaced this line:
$docx->importStyles('../../files/TemplateStyles.docx', 'merge', array('crazyStyle'));
with this:
$docx->importStyles('../../files/TemplateStyles.docx', $type= 'replace');
The styles were not imported.
>> If the styles are not being applied is because in your script or DOCX there must be something wrong: maybe mispelled styles names, wrong styles in the DOCX source...
As I noted, when I "merge" the styles from my template, they work fine, so nothing is misspelled and they are not wrong. When I "replace" the styles, nothing is imported.
Also:
I added this line into sample_1.php just below the $docx->addText() line:
$docx->embedHTML('<p>new paragraph</p>
<div class="crazystyle">this is a div class="crazystyle"</div>
<p class="crazystyle">this is a paragraph class="crazystyle"</p>',
array('strictWordStyles' => true,
'wordStyles' => array('.crazystyle' => 'crazyStyle')
));
The crazyStyle is applied to the <p class="crazystyle">, but not to <div class="crazystyle">. This is the exact behavior I am seeing in my code.
Thanks.