i have no problem in formatting columns as currency, i did with this function:
def style_excel_currency(writer):
wb = writer.book
ws = writer.sheets['Fatture']
money_fmt = wb.add_format({'num_format': '€#.###,##0'})
ws.set_column('A:A', 10, money_fmt)
if __name__=='__main__':
filename='attempt.xlsx'
with pd.ExcelWriter(filename) as writer:
df.to_excel(writer,
sheet_name='Fatture',
index=False,
engine='openpyxl')
style_excel_currency(writer)
The issue is that some very low number get rendered weirdly in excel.
For example numbers in the hundreds or thousands of euros works well:
it fails to format correctly number in the cents area: ( 0,06 and 0,66)
I don't get if something is wrong with my formatting. Example datasets:
df = pd.DataFrame(data={'col1':[100,101,200,0.06,0.66]})
Thanks
source https://stackoverflow.com/questions/73884259/xlsxwriter-format-currency-problem-with-cents-quantity
Comments
Post a Comment