Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add styleref #1349

Closed
SomayaMomtaz opened this issue Apr 15, 2018 · 2 comments
Closed

how to add styleref #1349

SomayaMomtaz opened this issue Apr 15, 2018 · 2 comments

Comments

@SomayaMomtaz
Copy link

SomayaMomtaz commented Apr 15, 2018

How to add styleref i tried
$header->addField('StyleRef', array('stylename' => 'Heading 1'), null, $text)
but it show this error
Uncaught exception 'InvalidArgumentException' with message 'Invalid type 'StyleRef''

then i added in field.php
at the $fieldsArray :
'StyleRef' => array(
'properties' => array( 'stylename'=> array('Heading 1')),
'options' => array('PreserveFormat'),
),

it didn't show error but it shows "Error! No style name given." in generated word docx

@troosan
Copy link
Contributor

troosan commented Apr 15, 2018

maybe you can try with a PreserveText (https://phpword.readthedocs.io/en/latest/elements.html#preserve-texts)

$header->addPreserveText('{ STYLEREF "Heading 1" \* MERGEFORMAT }');

@SomayaMomtaz
Copy link
Author

Thanks .. it works 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants