Auto Adjusting Column Length and Row Height
See original GitHub issueHi! Thanks for contributing to StyleFrame. Please make sure to mention the Python, StyleFrame, pandas and openpyxl versions you are using.
I am having an issue with the excel sheet auto adjusting the column to the widest length, below is some sample code I am having an issue with.
import pandas as pd
from StyleFrame import StyleFrame, Styler, utils
df = pd.DataFrame({'WW': ['WWWW', 'WWWWWWWWWWWWWWWWWW']})
sf = StyleFrame(df)
ew = StyleFrame.ExcelWriter('pandas_simple.xlsx')
sf.to_excel(ew)
ew.save()
Here are the versions I am using
Python: 3.5.2 StyleFrame: 1.3.1 Pandas 0.20.3 openpyxl: 2.2.5
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Change the column width or row height in Excel
On the Home tab, select Format > Column Width (or Column Height). Type the column width and select OK. Automatically resize all columns...
Read more >How to AutoFit in Excel: adjust columns and rows to match ...
To AutoFit row height, select the row(s) of interest, go to the Home tab > Cells group, and click Format > AutoFit Row...
Read more >Where is Autofit in Excel – How to Adjust Column Width and ...
Resizing the columns in the worksheet needs you to choose “Autofit Column Width” from the “Format” menu. Choose the “Autofit Row Height” option ......
Read more >Excel AUTOFIT: Make Rows/Columns Fit the Text Automatically
AutoFit is a feature in Excel that allows you to quickly adjust the row height or column width to fit the text completely...
Read more >Steps to size column width/row height automatically
Steps to size column width/row height automatically · Run a report. (How?) · On the Grid menu, select Options. · On the Columns...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Solved in version 1.4. See information about
best_fit
argument ofto_excel
method and the note at the bottom: http://styleframe.readthedocs.io/en/latest/api_documentation.html#to-excelI’ll need to look into this.
As a temporary workaround, a possible solution would be using
sf.set_column_width_dict
to set each column’s width according to the longest string in it multiplied by some factor:This is obviously quick and dirty, and isn’t perfect (it won’t work with all fonts and font sizes).