Skip to content

AddTable setStyleName and custom style #1666

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ You can of course also manually edit your composer.json file
}
```

### Extras ###
If you are having issues with missing dependencies, you can run the following to update all the project dependencies
```sh
composer update
```

Run the following to install / generate the project without dev tools (production)
```sh
composer install --no-dev
```
[Composer deploy info](https://stackoverflow.com/questions/21721495/how-to-deploy-correctly-when-using-composers-develop-production-switch)

## Getting started

The following is a basic usage example of the PHPWord library.
Expand Down
10 changes: 9 additions & 1 deletion src/PhpWord/Writer/Word2007/Style/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ private function writeStyle(XMLWriter $xmlWriter, TableStyle $style)
{
// w:tblPr
$xmlWriter->startElement('w:tblPr');


//Support table style name and custom styles at the same time
//set style name 1st (so word sets its style 1st then any custom styles)
if($style->getStyleName() != ''){
$xmlWriter->startElement('w:tblStyle');
$xmlWriter->writeAttribute('w:val', $style->getStyleName());
$xmlWriter->endElement();
}

// Table alignment
if ('' !== $style->getAlignment()) {
$tableAlignment = new TableAlignment($style->getAlignment());
Expand Down