使用 xlwt 格式字符串设置单元格格式 [英] Setting Cell Formats with xlwt format strings

查看:185
本文介绍了使用 xlwt 格式字符串设置单元格格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为单元格寻找了几种不同的 xlwt 格式,但找不到完整的列表.Excel 为单元格内容格式提供了以下选项:(一般、数字、货币、会计、日期、时间、百分比、分数、科学、文本、特殊、自定义)显然 custom 不是我想要的,但是所有这些不同选项的格式字符串是什么?例如,我见过:

I've looked around for several different xlwt formats for cells, but I can't find a comprehensive list. Excel provides the following options for cell content formatting: (general, number, currency, accounting, date, time, percentage, fraction, scientific, text, special, custom) Obviously custom isn't what I want, but what are the formatting strings for all these different options? For example, I've seen:

date_format = XFStyle()
date_format.num_format_str = 'dd/mm/yyyy'

currency_format = XFStyle()
currency_format.num_format_str = '$#,##0.00'

有什么地方可以获得这些格式字符串的完整列表吗?http://www.python-excel.org/ 的文档不多,底部教程似乎只有日期.

Is there somewhere I can get a comprehensive list of those formatting strings? The documentation on http://www.python-excel.org/ doesn't have much, and the tutorial at the bottom only seems to have dates.

推荐答案

我找到了一个列表.我只是愚蠢地寻找它.
GitHub 项目在这里有一个数字格式字符串列表:
https://github.com/python-excel/xlwt/blob/master/examples/num_formats.py

I've found a list. I was just being stupid about looking for it.
The GitHub project has a list of number format strings here:
https://github.com/python-excel/xlwt/blob/master/examples/num_formats.py

这篇关于使用 xlwt 格式字符串设置单元格格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆