'read_excel_as_template()' don't work properly
Closed this issue · 5 comments
MrBeike commented
Env:
- python ==3.7.3
- openpyxl==3.0.3
- pandas==1.0.4
- styleframe==3.0.3
Code:
writer = pd.ExcelWriter(fileName, mode='a', engine='openpyxl')
sf = StyleFrame.read_excel_as_template('template.xlsx', df, use_df_boundaries=True)
sf.to_excel(writer, sheet_name=sheetName, index=False)
Problems:
in openpyxl append mode
- frist sheet: header row height don't adjust with the template.(other rows'height is good, columns'width is good)
- other sheet: except header row heigth wrong, all the cells losted vertical alignment.
Thanks.
AsafSH6 commented
Hey,
Please attach template file and DataFrame to reproduce the problem
MrBeike commented
Hi,
I appreciate your quick response.
this is my file:reproduce.zip
Thanks!
MrBeike commented
seems commit b25d532 has already solved header row height problem.
but it should be line212 :if header_arg is 0:
cause the default value is set to zero line209 header_arg = kwargs.get('header', 0).
but then the row 1 style shift to row 2.
AsafSH6 commented
Opened pull request to solve the headers height bug.
Couldn't find the reason why ExcelWriter
in append
mode losing its vertical alignment
you can use ExcelWriter
in write
mode with explicit sheet_name
instead
for example
ew = StyleFrame.ExcelWriter(path='output.xlsx')
sf1 = StyleFrame(...)
sf1.to_excel(excel_writer=ew, sheet_name='Sheet1')
sf2 = StyleFrame(...)
sf2.to_excel(excel_writer=ew, sheet_name='Sheet2')
ew.save()
DeepSpace2 commented
styleframe
3.0.5 is released and contains this fix