-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Changing Color of text in setValue() #1448
Comments
TemplateProcessor only change simple line, if you open docx by zip software, you'll find a file named "document.xml" contains all the structure in it. I mean , if you tried open it, you will know this kind of "setValue" function is not possible exists...except using regular expression |
Thank you very much I have already done it with regular, but the effect is not very good.
Who can optimize this regularity or have a better plan? My current plan: `<?php namespace PhpOffice\PhpWord; class Template extends TemplateProcessor
}` |
@Allen-Yufeng you can try “Simple HTML DOM Parser” to extract xml, come here to find the document translated by me...... |
I'm currently working on a method to allow replacing a ${macro} with for instance a TextRun, which can contain formatting. Like this $title = new TextRun();
$title->addText('This title has been set ', array('bold' => true, 'italic' => true, 'color' => 'blue'));
$title->addText('dynamically', array('bold' => true, 'italic' => true, 'color' => 'red', 'underline' => 'single'));
$templateProcessor->setComplexBlock('title', $title); |
@troosan that's amazing and when can I see this new characteristic, just give me a probable time, I am looking forward to it |
Pull request is ready ! If you have any remarks, they're welcome |
This is useful, but would it be possible to allow a complex type/ $missing = new TextRun();
$missing->addText('Missing Value', array('color' => 'red'));
$templateProcessor->cloneRowAndSetValues("first_value", $items->values()->map(function($item) use ($missing) {
return [
"first_value" => $item->first_value ?? $missing,
"second_value" => $item->second_value ?? $missing,
"third_value" => $item->third_value ?? $missing,
];
})); Then TemplateProcessor could determine how to replace the placeholder based on the type of what gets passed in. That would sure make for simpler code, and I'm not even sure I could do this within cloned table rows the way thing work right now. |
This is:
I am a Chinese PHP development engineer.
I do the word scan software. I want to have some wrong words or sentences in the word file. Add the background color.
What shall I do?
I'd like to change the following way, but I don't know how to change it.
$document ->setValue('rowValue', 'Sun', array("color"=>"0000ff", "bgColor" => "fbbb10"));
Ask the expert to give a suggestion.
This question has been asked by codeplex in the past
The text was updated successfully, but these errors were encountered: