Support more styles for xlsxwriter
State: closed

I was surprised to find that despite the interchangeable representation of Excel styles, xlsxwriter did not have good style support.

I've not added direct tests for this functionality, but test some of it through `test_styler_to_excel`.

 - [x] ~~closes #xxxx~~
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry

Labels:
name: IO Excel
description: read_excel, to_excel

Comments:
There is a consistent test failure, but not one I've managed to replicate locally.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=h1) Report
> Merging [#16149](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/3b80ed33e00957fec4a79cde19df66d809b5d3a7?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `89.65%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16149/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16149      +/-   ##
==========================================
- Coverage   90.83%   90.83%   -0.01%     
==========================================
  Files         159      159              
  Lines       50796    50809      +13     
==========================================
+ Hits        46143    46153      +10     
- Misses       4653     4656       +3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.61% <89.65%> (-0.01%)` | :arrow_down: |
| #single | `40.3% <3.44%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/excel.py](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree#diff-cGFuZGFzL2lvL2V4Y2VsLnB5) | `80.55% <89.65%> (-0.07%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=footer). Last update [3b80ed3...c935f5d](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=h1) Report
> Merging [#16149](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5959ee3e133723136d4862864988a63ef3cc2a2f?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `92.1%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16149/graphs/tree.svg?token=eZ4WkYLtcO&src=pr&height=150&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #16149      +/-   ##
==========================================
- Coverage   91.24%   91.21%   -0.03%     
==========================================
  Files         163      163              
  Lines       50091    50106      +15     
==========================================
+ Hits        45704    45706       +2     
- Misses       4387     4400      +13
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.02% <92.1%> (-0.01%)` | :arrow_down: |
| #single | `40.23% <10.52%> (-0.07%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/excel.py](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree#diff-cGFuZGFzL2lvL2V4Y2VsLnB5) | `80.39% <92.1%> (-0.01%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.1%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.41% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=footer). Last update [5959ee3...80ed56a](https://codecov.io/gh/pandas-dev/pandas/pull/16149?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Finally passing tests after identifying a recently fixed openpyxl bug that got in the way
I'm happy to make an issue aiming to refactor excel writing code. But how do you feel about this PR?
can you rebase.
I've moved the what's new to 0.20.
this looks reasonable, can you rebase
Yes, sorry I've not managed to do the refactoring you'd like to see. I've been unsure what you would like, and have had my attentions elsewhere.
cc @chris-b1 @TomAugspurger 
Merge into 0.21 and avoid future what's new conflicts?
you need to rebase and some comments to respond
Well, your comments suggested a refactor, and I've previously commented that I do not understand your vision of a refactor in this space, and certainly have not found capacity within my other FOSS commitments to to do a general code quality improvement here.

Since those comments, you announced "this looks reasonable". I'll have another very brief look at refactoring.
I made the requested change as I interpret it. I do not find it improves code quality.
I haven't understood the cause of the travis failure, apparently in lint.sh but without error message that I can see.

I've merged in master and moved what's new to the next version.
> Linting  *.py
pandas/io/excel.py:1794:1: E305 expected 2 blank lines after class or function definition, found 1

you can check this locally via:

``make lint-diff`` (or just directly run flake8 on that file)

Okay. I tried to run ci/lint.sh but got not flags. Thanks.

On 30 October 2017 at 10:25, Jeff Reback <notifications@github.com> wrote:

> Linting *.py
> pandas/io/excel.py:1794:1: E305 expected 2 blank lines after class or
> function definition, found 1
>
> you can check this locally via:
>
> make lint-diff (or just directly run flake8 on that file)
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/16149#issuecomment-340311772>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAEz6yq4SKK71rbuRtXNVmBX6vxySOpjks5sxQllgaJpZM4NJIfp>
> .
>

thanks @jnothman