how to format specific cells in excel using xlsx package in python

房东的猫 提交于 2019-11-29 15:38:00

You can insert more than one dataframe, with offsets, into an XlsxWriter file. See this example from the docs.

It isn't possible to format cells after they are written (apart from column/row formats, see this example).

If you need very fine grained formatting you would be best to just use XlsxWriter directly with the data from the dataframe.

Some people use conditional formatting in XlsxWriter to get the effect they need, like this SO answer. However, that isn't applicable to single cells.

Try this:

money_italic_fmt = workbook.add_format({'num_format':'$#,##0',
                                        'font_name':'Batang',
                                        'italic':True})
worksheet.write(12, # <-- The cell row (zero indexed).
                3,  # <-- The cell column (zero indexed).
                13, # <-- Value to write
                money_italic_fmt  # <-- Format
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!