Skip to content

Please add more ways to remove header formatting when exporting to Excel #25398

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

Closed
reportgunner opened this issue Feb 21, 2019 · 4 comments
Closed
Labels
Duplicate Report Duplicate issue or pull request

Comments

@reportgunner
Copy link

reportgunner commented Feb 21, 2019

Code Sample, a copy-pastable example if possible

pandas.io.formats.excel.header_style = None
pandas.core.format.header_style = None
pandas.formats.format.header_style = None

Problem description

Every time I try to make a simple xlsx file out of a bunch of SQL results I end up spending most of my time trying to get rid of the awful default header format. I never remember how to do it so I try all the ways that are on the internet and usually none of them work.

Can you please add at least 4 different ways to disable the default formatting so I can spend more time trying to figure such a trivial action next time ?

Also it would be great if the default header font can be changed to Comic Sans with Yellow font color, I can then go and fix the header formatting manually for every file because nobody will be able to read it.

Best case scenario would be to somehow randomize this property that disables formatting so it changes from version to version and old ways to turn it off come and go so I can avoid more work by monkey patching the package every time I update.

Thank you !

Expected Output

pandas.io.formats.excel.header_style = None
pandas.core.format.header_style = None
pandas.formats.format.header_style = None
pandas.formats.io.excel.header = None
pandas.excel.formats.io.header = None
pandas.pandas.pandas.header = None
pandas.defaults.excel.headers.style = None
pandas.formats.excel.header.interior.color = None
pandas.formats.excel.header.borders.color = None
pandas.formats.excel.header.borders.style = None

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-8-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.24.1
pytest: None
pip: 19.0.2
setuptools: 40.6.3
Cython: None
numpy: 1.16.1
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: 1.1.4
lxml.etree: 4.3.1
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@jreback
Copy link
Contributor

jreback commented Feb 21, 2019

the tone of this post leaves a lot to be desired

not sure if this is a joke or not

please reformat to post an actual request

@WillAyd WillAyd added the Duplicate Report Duplicate issue or pull request label Feb 21, 2019
@WillAyd
Copy link
Member

WillAyd commented Feb 21, 2019

Yea the post here isn't very constructive so hard to say but I think this is a duplicate of #22773 and closing as such.

This is an open source project built off of volunteer work. If you see a way to improve it then we would certainly welcome contributions via pull requests

@WillAyd WillAyd closed this as completed Feb 21, 2019
@reportgunner
Copy link
Author

@WillAyd a simple way to improve the package is to remove the default header formatting or turn it into something very minimal (like bold font only for example).

Then you don't have to spend 6 months to try to give users a functionality that removes something that is not a part of MVP.

@reportgunner
Copy link
Author

change

{"font": {"bold": True},
                "borders": {"top": "thin",
                            "right": "thin",
                            "bottom": "thin",
                            "left": "thin"},
                "alignment": {"horizontal": "center",
                              "vertical": "top"}}

to

{"font": {"bold": True}}

Problem is solved. No need for jinja2, no need to import in a different way 3 months later.
As a cherry on top, if your column header is "VeryLongColumnHeader" and the longest column value is 6 characters long you will see "VeryLo" instead of "yLongH".

@reportgunner reportgunner changed the title Please add more ways to remove header formatting Please add more ways to remove header formatting when exporting to Excel Feb 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants